blob: 2c80d777fe0f05c566ea40475e554f08be952d80 [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);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800146 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700147 pe_err("qdf_mem_malloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800148 /* Free the active command list
149 * Probably the malloc is going to fail there as well?!
150 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530151 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152 }
153
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800154 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530155 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800156 /* Other parameters are not needed for WMA */
157
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800158 message.bodyptr = req_msg;
159 message.type = SIR_HAL_PDEV_SET_HW_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800160
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700161 pe_debug("Posting SIR_HAL_SOC_SET_HW_MOD to WMA");
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530162 status = scheduler_post_message(QDF_MODULE_ID_PE,
163 QDF_MODULE_ID_WMA,
164 QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530165 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700166 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800167 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530168 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800169 goto fail;
170 }
171 return status;
172fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530173 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800174 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700175 pe_err("HW mode resp failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530176 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800177 }
178 param->status = SET_HW_MODE_STATUS_ECANCELED;
179 param->cfgd_hw_mode_index = 0;
180 param->num_vdev_mac_entries = 0;
181 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
182 resp_msg.bodyptr = param;
183 resp_msg.bodyval = 0;
184 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530185 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800186}
187
188/**
189 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
190 * @mac: Global MAC pointer
191 * @msg: Message containing the dual mac config parameter
192 *
193 * Send the set dual mac config command to WMA
194 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530195 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800196 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530197static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800198 uint32_t *msg)
199{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530200 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700201 struct scheduler_msg message = {0};
Srinivas Girigowdaeb6ecf32018-02-15 17:04:22 -0800202 struct policy_mgr_dual_mac_config *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203 uint32_t len;
204 struct sir_set_dual_mac_cfg *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700205 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800206 struct sir_dual_mac_config_resp *param;
207
208 buf = (struct sir_set_dual_mac_cfg *) msg;
209 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700210 pe_err("Set Dual mac config is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800211 /* To free the active command list */
212 goto fail;
213 }
214
215 len = sizeof(*req_msg);
216
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530217 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800218 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700219 pe_err("qdf_mem_malloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800220 /* Free the active command list
221 * Probably the malloc is going to fail there as well?!
222 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530223 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800224 }
225
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800226 req_msg->scan_config = buf->set_dual_mac.scan_config;
227 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
228 /* Other parameters are not needed for WMA */
229
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800230 message.bodyptr = req_msg;
231 message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800232
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700233 pe_debug("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800234 req_msg->scan_config, req_msg->fw_mode_config);
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530235 status = scheduler_post_message(QDF_MODULE_ID_PE,
236 QDF_MODULE_ID_WMA,
237 QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530238 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700239 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800240 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530241 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800242 goto fail;
243 }
244 return status;
245fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530246 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800247 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700248 pe_err("Dual mac config resp failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530249 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800250 }
251 param->status = SET_HW_MODE_STATUS_ECANCELED;
252 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
253 resp_msg.bodyptr = param;
254 resp_msg.bodyval = 0;
255 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530256 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800257}
258
259/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800260 * lim_process_set_antenna_mode_req() - Set antenna mode command
261 * to WMA
262 * @mac: Global MAC pointer
263 * @msg: Message containing the antenna mode parameter
264 *
265 * Send the set antenna mode command to WMA
266 *
267 * Return: QDF_STATUS_SUCCESS if message posting is successful
268 */
269static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
270 uint32_t *msg)
271{
272 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700273 struct scheduler_msg message = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800274 struct sir_antenna_mode_param *req_msg;
275 struct sir_set_antenna_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700276 struct scheduler_msg resp_msg = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800277 struct sir_antenna_mode_resp *param;
278
279 buf = (struct sir_set_antenna_mode *) msg;
280 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700281 pe_err("Set antenna mode is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800282 /* To free the active command list */
283 goto fail;
284 }
285
286 req_msg = qdf_mem_malloc(sizeof(*req_msg));
287 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700288 pe_err("qdf_mem_malloc failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800289 return QDF_STATUS_E_NOMEM;
290 }
291
292 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
293 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
294
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800295 message.bodyptr = req_msg;
296 message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800297
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700298 pe_debug("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800299 req_msg->num_rx_chains,
300 req_msg->num_tx_chains);
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530301 status = scheduler_post_message(QDF_MODULE_ID_PE,
302 QDF_MODULE_ID_WMA,
303 QDF_MODULE_ID_WMA, &message);
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800304 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700305 pe_err("scheduler_post_msg failed!(err=%d)",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800306 status);
307 qdf_mem_free(req_msg);
308 goto fail;
309 }
310 return status;
311fail:
312 param = qdf_mem_malloc(sizeof(*param));
313 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700314 pe_err("antenna mode resp failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800315 return QDF_STATUS_E_NOMEM;
316 }
317 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
318 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
319 resp_msg.bodyptr = param;
320 resp_msg.bodyval = 0;
321 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
322 return QDF_STATUS_SUCCESS;
323}
324
325/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800326 * __lim_is_sme_assoc_cnf_valid()
327 *
328 ***FUNCTION:
329 * This function is called by __lim_process_sme_assoc_cnf_new() upon
330 * receiving SME_ASSOC_CNF.
331 *
332 ***LOGIC:
333 * Message validity checks are performed in this function
334 *
335 ***ASSUMPTIONS:
336 *
337 ***NOTE:
338 *
339 * @param pMeasReq Pointer to Received ASSOC_CNF message
340 * @return true When received SME_ASSOC_CNF is formatted
341 * correctly
342 * false otherwise
343 */
344
345static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
346{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530347 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800348 return false;
349 else
350 return true;
351} /*** end __lim_is_sme_assoc_cnf_valid() ***/
352
353/**
354 * __lim_get_sme_join_req_size_for_alloc()
355 *
356 ***FUNCTION:
357 * This function is called in various places to get IE length
358 * from tSirBssDescription structure
359 * number being scanned.
360 *
361 ***PARAMS:
362 *
363 ***LOGIC:
364 *
365 ***ASSUMPTIONS:
366 * NA
367 *
368 ***NOTE:
369 * NA
370 *
371 * @param pBssDescr
372 * @return Total IE length
373 */
374
375static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
376{
377 uint16_t len = 0;
378
379 if (!pBuf)
380 return len;
381
382 pBuf += sizeof(uint16_t);
383 len = lim_get_u16(pBuf);
Arif Hussainc9651922017-04-16 14:08:23 -0700384 return len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800385}
386
387/**
388 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
389 * @pMac: Global MAC context
390 * @pMsg: Pointer to message posted from SME to LIM.
391 *
392 * Has role only if 11h is enabled. Not used on STA side.
393 * Defers the message if SME is in learn state and brings
394 * the LIM back to normal mode.
395 *
396 * Return: true - If defered false - Otherwise
397 */
398
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800399static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac,
400 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800401{
402 if (lim_is_system_in_scan_state(pMac)) {
403 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700404 pe_err("Could not defer Msg: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800405 return false;
406 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700407 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800408 pMsg->type);
409 return true;
410 }
411 return false;
412}
413
414/**
415 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
416 * @mac_ctx: Pointer to Global MAC structure
417 * @message: Pointer to message posted from SME to LIM.
418 *
419 * Has role only if 11h is enabled. Not used on STA side.
420 * Defers the message if radar is detected.
421 *
422 * Return: true, if defered otherwise return false.
423 */
424static bool
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800425__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx,
426 struct scheduler_msg *message)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427{
428 /*
429 * fRadarDetCurOperChan will be set only if we
430 * detect radar in current operating channel and
431 * System Role == AP ROLE
432 *
433 * TODO: Need to take care radar detection.
434 *
435 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
436 */
437 if (0) {
438 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700439 pe_err("Could not defer Msg: %d", message->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800440 return false;
441 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700442 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800443 message->type);
444 return true;
445 }
446 return false;
447}
448
449/**
450 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
451 * @pMac: Global MAC context
452 * @pMsgBuf: Message from WMA
453 *
454 * handles the notification from HDD. PE just forwards this message to HAL.
455 *
456 * Return: true-Posting to HAL failed, so PE will consume the buffer.
457 * false-Posting to HAL successful, so HAL will consume the buffer.
458 */
459
460static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
461{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700462 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800463 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
464
465 msg.type = WMA_SYS_READY_IND;
466 msg.reserved = 0;
467 msg.bodyptr = pMsgBuf;
468 msg.bodyval = 0;
469
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700470 if (ANI_DRIVER_TYPE(pMac) != QDF_DRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800471 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +0530472 pe_register_mgmt_rx_frm_callback(pMac);
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700473 pe_register_callbacks_with_wma(pMac, ready_req);
Sandeep Puligilla1426d612017-04-12 18:22:06 -0700474 pMac->lim.sme_msg_callback = ready_req->sme_msg_cb;
Vignesh Viswanathan3d478032018-08-02 20:18:53 +0530475 pMac->lim.stop_roaming_callback = ready_req->stop_roaming_cb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800476 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700477
478 pe_debug("sending WMA_SYS_READY_IND msg to HAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800479 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
480
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700481 if (QDF_STATUS_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700482 pe_err("wma_post_ctrl_msg failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800483 return true;
484 }
485 return false;
486}
487
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800488/**
489 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
490 *@mac_ctx: Pointer to Global MAC structure
491 *@session: A pointer to session entry
492 *@sme_start_bss_req: Start BSS Request from upper layers.
493 *
494 * This function is used to configure the start bss parameters
495 * in to the session.
496 *
497 * Return: None.
498 */
499static void
500lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
501 tpSirSmeStartBssReq sme_start_bss_req)
502{
503 session->limSystemRole = eLIM_AP_ROLE;
504 session->privacy = sme_start_bss_req->privacy;
505 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
506 session->authType = sme_start_bss_req->authType;
507 /* Store the DTIM period */
508 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
509 /* Enable/disable UAPSD */
510 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530511 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800512 session->proxyProbeRspEn = 0;
513 } else {
514 /*
515 * To detect PBC overlap in SAP WPS mode,
516 * Host handles Probe Requests.
517 */
518 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
519 session->proxyProbeRspEn = 1;
520 else
521 session->proxyProbeRspEn = 0;
522 }
523 session->ssidHidden = sme_start_bss_req->ssidHidden;
524 session->wps_state = sme_start_bss_req->wps_state;
525 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530526 session->vendor_vht_sap =
527 sme_start_bss_req->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800528 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
529 &session->shortSlotTimeSupported);
530 session->isCoalesingInIBSSAllowed =
531 sme_start_bss_req->isCoalesingInIBSSAllowed;
532
Jiachao Wu712d4fd2017-08-23 16:52:34 +0800533 session->beacon_tx_rate = sme_start_bss_req->beacon_tx_rate;
534
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800535}
536
537/**
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530538 * lim_send_start_vdev_req() - send vdev start request
539 *@session: pe session
540 *@mlm_start_req: vdev start req
541 *
542 * Return: QDF_STATUS
543 */
Abhishek Singh3d30a3b2018-09-12 15:49:18 +0530544#ifdef CONFIG_VDEV_SM
545static QDF_STATUS
546lim_send_start_vdev_req(tpPESession session, tLimMlmStartReq *mlm_start_req)
547{
548 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
549 WLAN_VDEV_SM_EV_START,
550 sizeof(*mlm_start_req),
551 mlm_start_req);
552}
553#else
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530554static QDF_STATUS
555lim_send_start_vdev_req(tpPESession session, tLimMlmStartReq *mlm_start_req)
556{
557 lim_process_mlm_start_req(session->mac_ctx, mlm_start_req);
558
559 return QDF_STATUS_SUCCESS;
560}
Abhishek Singh3d30a3b2018-09-12 15:49:18 +0530561#endif
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530562
563/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800564 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
565 *@mac_ctx: Pointer to Global MAC structure
566 *@msg_buf: A pointer to the SME message buffer
567 *
568 * This function is called to process SME_START_BSS_REQ message
569 * from HDD or upper layer application.
570 *
571 * Return: None
572 */
573static void
574__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
575{
576 uint16_t size;
577 uint32_t val = 0;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700578 QDF_STATUS ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800579 tSirMacChanNum channel_number;
580 tLimMlmStartReq *mlm_start_req = NULL;
581 tpSirSmeStartBssReq sme_start_bss_req = NULL;
582 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
583 /* Flag Used in case of IBSS to Auto generate BSSID. */
584 uint32_t auto_gen_bssid = false;
585 uint8_t session_id;
586 tpPESession session = NULL;
Krunal Sonib37bb352016-12-20 14:12:21 -0800587 uint8_t sme_session_id = 0xFF;
588 uint16_t sme_transaction_id = 0xFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800589 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700590 struct vdev_type_nss *vdev_type_nss;
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530591 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
gaurank kathpaliad88ef882018-08-14 15:20:11 +0530592 struct policy_mgr_hw_mode_params hw_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800593
594/* FEATURE_WLAN_DIAG_SUPPORT */
595#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
596 /*
597 * Since the session is not created yet, sending NULL.
598 * The response should have the correct state.
599 */
600 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
601 NULL, 0, 0);
602#endif /* FEATURE_WLAN_DIAG_SUPPORT */
603
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700604 pe_debug("Received START_BSS_REQ");
Krunal Sonib37bb352016-12-20 14:12:21 -0800605 size = sizeof(tSirSmeStartBssReq);
606 sme_start_bss_req = qdf_mem_malloc(size);
607 if (NULL == sme_start_bss_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700608 pe_err("Allocate Memory fail for LimStartBssReq");
Krunal Sonib37bb352016-12-20 14:12:21 -0800609 /* Send failure response to host */
610 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
611 goto free;
612 }
613 qdf_mem_copy(sme_start_bss_req, msg_buf, sizeof(tSirSmeStartBssReq));
614 sme_session_id = sme_start_bss_req->sessionId;
615 sme_transaction_id = sme_start_bss_req->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800616
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800617 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
618 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800619 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
620 sme_start_bss_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700621 pe_warn("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800622 ret_code = eSIR_SME_INVALID_PARAMETERS;
623 goto free;
624 }
625
626 /*
627 * This is the place where PE is going to create a session.
628 * If session is not existed, then create a new session
629 */
630 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800631 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800632 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700633 pe_warn("Session Already exists for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800634 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
635 session = NULL;
636 goto free;
637 } else {
638 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800639 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800640 &session_id, mac_ctx->lim.maxStation,
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +0530641 sme_start_bss_req->bssType,
642 sme_start_bss_req->sessionId);
643 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700644 pe_warn("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800645 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
646 goto free;
647 }
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +0530648
649 /* Update the beacon/probe filter in mac_ctx */
650 lim_set_bcn_probe_filter(mac_ctx, session,
651 &sme_start_bss_req->ssId,
652 sme_start_bss_req->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800653 }
654
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700655 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
656 /* Probe resp add ie */
657 lim_start_bss_update_add_ie_buffer(mac_ctx,
658 &session->addIeParams.probeRespData_buff,
659 &session->addIeParams.probeRespDataLen,
660 sme_start_bss_req->addIeParams.
661 probeRespData_buff,
662 sme_start_bss_req->addIeParams.
663 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800664
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700665 /* Probe Beacon add ie */
666 lim_start_bss_update_add_ie_buffer(mac_ctx,
667 &session->addIeParams.probeRespBCNData_buff,
668 &session->addIeParams.probeRespBCNDataLen,
669 sme_start_bss_req->addIeParams.
670 probeRespBCNData_buff,
671 sme_start_bss_req->addIeParams.
672 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800673
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700674 /* Assoc resp IE */
675 lim_start_bss_update_add_ie_buffer(mac_ctx,
676 &session->addIeParams.assocRespData_buff,
677 &session->addIeParams.assocRespDataLen,
678 sme_start_bss_req->addIeParams.
679 assocRespData_buff,
680 sme_start_bss_req->addIeParams.
681 assocRespDataLen);
682 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800683 /* Store the session related params in newly created session */
684 session->pLimStartBssReq = sme_start_bss_req;
685
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800686 session->transactionId = sme_start_bss_req->transactionId;
687
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530688 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800689 &(sme_start_bss_req->htConfig),
690 sizeof(session->htConfig));
691
Sandeep Puligilla98917432016-06-10 13:50:28 -0700692 qdf_mem_copy(&(session->vht_config),
693 &(sme_start_bss_req->vht_config),
694 sizeof(session->vht_config));
695
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800696 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800697 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800698
699 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530700 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800701 (uint8_t *) &sme_start_bss_req->ssId,
702 (sme_start_bss_req->ssId.length + 1));
703
704 session->bssType = sme_start_bss_req->bssType;
705
706 session->nwType = sme_start_bss_req->nwType;
707
708 session->beaconParams.beaconInterval =
709 sme_start_bss_req->beaconInterval;
710
711 /* Store the channel number in session Table */
712 session->currentOperChannel =
713 sme_start_bss_req->channelId;
714
715 /* Store Persona */
716 session->pePersona = sme_start_bss_req->bssPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +0530717 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800718 FL("PE PERSONA=%d"), session->pePersona);
719
720 /* Update the phymode */
721 session->gLimPhyMode = sme_start_bss_req->nwType;
722
723 session->maxTxPower =
724 cfg_get_regulatory_max_transmit_power(mac_ctx,
725 session->currentOperChannel);
726 /* Store the dot 11 mode in to the session Table */
727 session->dot11mode = sme_start_bss_req->dot11mode;
728#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
729 session->cc_switch_mode =
730 sme_start_bss_req->cc_switch_mode;
731#endif
732 session->htCapability =
733 IS_DOT11_MODE_HT(session->dot11mode);
734 session->vhtCapability =
735 IS_DOT11_MODE_VHT(session->dot11mode);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800736
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700737 pe_debug("HT[%d], VHT[%d]",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800738 session->htCapability, session->vhtCapability);
739
740 if (IS_DOT11_MODE_HE(session->dot11mode)) {
741 lim_update_session_he_capable(mac_ctx, session);
742 lim_copy_bss_he_cap(session, sme_start_bss_req);
743 }
744
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800745 session->txLdpcIniFeatureEnabled =
746 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800747#ifdef WLAN_FEATURE_11W
748 session->limRmfEnabled =
749 sme_start_bss_req->pmfCapable ? 1 : 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700750 pe_debug("Session RMF enabled: %d", session->limRmfEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800751#endif
752
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530753 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800754 (void *)&sme_start_bss_req->operationalRateSet,
755 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530756 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800757 (void *)&sme_start_bss_req->extendedRateSet,
758 sizeof(tSirMacRateSet));
759
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700760 if (IS_5G_CH(session->currentOperChannel))
761 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
762 else
763 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
764
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800765 switch (sme_start_bss_req->bssType) {
766 case eSIR_INFRA_AP_MODE:
767 lim_configure_ap_start_bss_session(mac_ctx, session,
768 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700769 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700770 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700771 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700772 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800773 break;
774 case eSIR_IBSS_MODE:
775 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
776 lim_get_short_slot_from_phy_mode(mac_ctx, session,
777 session->gLimPhyMode,
778 &session->shortSlotTimeSupported);
779
780 /*
781 * initialize to "OPEN".
782 * will be updated upon key installation
783 */
784 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700785 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800786
787 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700788 case eSIR_NDI_MODE:
789 session->limSystemRole = eLIM_NDI_ROLE;
790 break;
791
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800792
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800793 /*
794 * There is one more mode called auto mode.
795 * which is used no where
796 */
797
798 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
799
800 default:
801 /* not used anywhere...used in scan function */
802 break;
803 }
804
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700805 pe_debug("persona - %d, nss - %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700806 session->pePersona, session->vdev_nss);
807 session->nss = session->vdev_nss;
Kiran Kumar Lokerebc6fb2f2018-05-09 19:04:11 -0700808 if (!mac_ctx->roam.configParam.enable2x2)
809 session->nss = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800810 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700811 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800812 * parsed (Re)Assoc request structure
813 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700814 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530816 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700817 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800818 if (NULL == session->parsedAssocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700819 pe_warn("AllocateMemory() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800820 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
821 goto free;
822 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800823 }
824
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700825 if (!sme_start_bss_req->channelId &&
826 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700827 pe_err("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800828 ret_code = eSIR_SME_INVALID_PARAMETERS;
829 goto free;
830 }
831 channel_number = sme_start_bss_req->channelId;
832#ifdef QCA_HT_2040_COEX
833 if (sme_start_bss_req->obssEnabled)
834 session->htSupportedChannelWidthSet =
835 session->htCapability;
836 else
837#endif
838 session->htSupportedChannelWidthSet =
839 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
840 session->htSecondaryChannelOffset =
841 sme_start_bss_req->sec_ch_offset;
842 session->htRecommendedTxWidthSet =
843 (session->htSecondaryChannelOffset) ? 1 : 0;
Abhishek Singh4294f802017-08-10 16:37:07 +0530844 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800845 FL("cbMode %u"), sme_start_bss_req->cbMode);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800846 if (lim_is_session_he_capable(session) ||
847 session->vhtCapability || session->htCapability) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848 chanwidth = sme_start_bss_req->vht_channel_width;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700849 pe_debug("vht_channel_width %u htSupportedChannelWidthSet %d",
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800850 sme_start_bss_req->vht_channel_width,
851 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800852 session->ch_width = chanwidth;
853 if (session->htSupportedChannelWidthSet) {
854 session->ch_center_freq_seg0 =
855 sme_start_bss_req->center_freq_seg0;
856 session->ch_center_freq_seg1 =
857 sme_start_bss_req->center_freq_seg1;
858 } else {
859 session->ch_center_freq_seg0 = 0;
860 session->ch_center_freq_seg1 = 0;
861 }
862 }
gaurank kathpaliad88ef882018-08-14 15:20:11 +0530863 if (policy_mgr_is_hw_dbs_capable(mac_ctx->psoc) &&
864 (policy_mgr_get_current_hw_mode(mac_ctx->psoc, &hw_mode) ==
865 QDF_STATUS_SUCCESS) &&
866 hw_mode.dbs_cap) {
867 session->nss = 1;
868 pe_debug("HW is in DBS mode. Nss set to [%d]",
869 session->nss);
870 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800871 if (session->vhtCapability &&
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800872 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873 session->nss = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700874 pe_debug("nss set to [%d]", session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800875 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700876 pe_debug("vht su tx bformer %d",
Krunal Soni53993f72016-07-08 18:20:03 -0700877 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800878
879 /* Delete pre-auth list if any */
880 lim_delete_pre_auth_list(mac_ctx);
881
882 /*
883 * keep the RSN/WPA IE information in PE Session Entry
884 * later will be using this to check when received (Re)Assoc req
885 */
886 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
887 &sme_start_bss_req->rsnIE, session);
888
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700889 if (LIM_IS_AP_ROLE(session) ||
890 LIM_IS_IBSS_ROLE(session) ||
891 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800892 session->gLimProtectionControl =
893 sme_start_bss_req->protEnabled;
894 /*
895 * each byte will have the following info
896 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
897 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
898 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530899 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800900 (void *)&sme_start_bss_req->ht_capab,
901 sizeof(uint16_t));
902 /* Initialize WPS PBC session link list */
903 session->pAPWPSPBCSession = NULL;
904 }
905 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530906 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800907 if (NULL == mlm_start_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700908 pe_err("Allocate Memory failed for mlmStartReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800909 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
910 goto free;
911 }
912
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800913 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530914 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800915 (uint8_t *) &sme_start_bss_req->ssId,
916 sme_start_bss_req->ssId.length + 1);
917 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
918 mlm_start_req->obssProtEnabled =
919 sme_start_bss_req->obssProtEnabled;
920
921 mlm_start_req->bssType = session->bssType;
922
923 /* Fill PE session Id from the session Table */
924 mlm_start_req->sessionId = session->peSessionId;
925
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700926 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
927 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800928 /*
929 * Copy the BSSId from sessionTable to
930 * mlmStartReq struct
931 */
932 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
933 } else {
934 /* ibss mode */
935 mac_ctx->lim.gLimIbssCoalescingHappened = false;
936
937 ret_status = wlan_cfg_get_int(mac_ctx,
938 WNI_CFG_IBSS_AUTO_BSSID,
939 &auto_gen_bssid);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700940 if (ret_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700941 pe_err("Get Auto Gen BSSID fail,Status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800942 ret_status);
Abhishek Singh4294f802017-08-10 16:37:07 +0530943 ret_code = eSIR_LOGE_EXCEPTION;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800944 goto free;
945 }
946
947 if (!auto_gen_bssid) {
948 /*
949 * We're not auto generating BSSID.
950 * Instead, get it from session entry
951 */
952 sir_copy_mac_addr(mlm_start_req->bssId,
953 session->bssId);
954 /*
955 * Start IBSS group BSSID
956 * Auto Generating BSSID.
957 */
958 auto_gen_bssid = ((mlm_start_req->bssId[0] &
959 0x01) ? true : false);
960 }
961
962 if (auto_gen_bssid) {
963 /*
964 * if BSSID is not any uc id.
965 * then use locally generated BSSID.
966 * Autogenerate the BSSID
967 */
968 lim_get_random_bssid(mac_ctx,
969 mlm_start_req->bssId);
970 mlm_start_req->bssId[0] = 0x02;
971
972 /*
973 * Copy randomly generated BSSID
974 * to the session Table
975 */
976 sir_copy_mac_addr(session->bssId,
977 mlm_start_req->bssId);
978 }
979 }
980 /* store the channel num in mlmstart req structure */
981 mlm_start_req->channelNumber = session->currentOperChannel;
982 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
983 mlm_start_req->beaconPeriod =
984 session->beaconParams.beaconInterval;
Arif Hussain671a1902017-03-17 09:08:32 -0700985 mlm_start_req->cac_duration_ms =
986 sme_start_bss_req->cac_duration_ms;
987 mlm_start_req->dfs_regdomain =
988 sme_start_bss_req->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800989 if (LIM_IS_AP_ROLE(session)) {
990 mlm_start_req->dtimPeriod = session->dtimPeriod;
991 mlm_start_req->wps_state = session->wps_state;
992
993 } else {
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530994 val = mac_ctx->mlme_cfg->sap_cfg.dtim_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995 mlm_start_req->dtimPeriod = (uint8_t) val;
996 }
997
Karthik Kantamneni22dd0f62018-08-07 14:53:50 +0530998 mlm_start_req->cfParamSet.cfpPeriod =
999 mac_ctx->mlme_cfg->rates.cfp_period;
1000 mlm_start_req->cfParamSet.cfpMaxDuration =
1001 mac_ctx->mlme_cfg->rates.cfp_max_duration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001002
1003 /*
1004 * this may not be needed anymore now,
1005 * as rateSet is now included in the
1006 * session entry and MLM has session context.
1007 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301008 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001009 (void *)&session->rateSet,
1010 sizeof(tSirMacRateSet));
1011
1012 /* Now populate the 11n related parameters */
1013 mlm_start_req->nwType = session->nwType;
1014 mlm_start_req->htCapable = session->htCapability;
1015
1016 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1017 /* Unused */
1018 mlm_start_req->dualCTSProtection =
1019 mac_ctx->lim.gHTDualCTSProtection;
1020 mlm_start_req->txChannelWidthSet =
1021 session->htRecommendedTxWidthSet;
1022
1023 session->limRFBand = lim_get_rf_band(channel_number);
1024
1025 /* Initialize 11h Enable Flag */
1026 session->lim11hEnable = 0;
gaolez76d2a162017-03-21 19:23:58 +08001027 if (mlm_start_req->bssType != eSIR_IBSS_MODE &&
1028 (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001029 BAND_5G == session->limRFBand)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001030 if (wlan_cfg_get_int(mac_ctx,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001031 WNI_CFG_11H_ENABLED, &val) != QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001032 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001033 else
1034 session->lim11hEnable = val;
1035
1036 if (session->lim11hEnable &&
1037 (eSIR_INFRA_AP_MODE ==
1038 mlm_start_req->bssType)) {
Abhishek Singhdfa69c32018-08-30 15:39:34 +05301039 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 wlan_cfg_get_int(mac_ctx,
1041 WNI_CFG_DFS_MASTER_ENABLED,
1042 &val);
1043 session->lim11hEnable = val;
1044 }
Abhishek Singhdfa69c32018-08-30 15:39:34 +05301045 if (QDF_IS_STATUS_ERROR(qdf_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001046 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001047 pe_err("Get Fail, CFG DFS ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048 }
1049
1050 if (!session->lim11hEnable) {
1051 if (cfg_set_int(mac_ctx,
1052 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001053 QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001054 /*
1055 * Failed to set the CFG param
1056 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1057 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001058 pe_err("Set LOCAL_POWER_CONSTRAINT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001059 }
1060
Jiachao Wu712d4fd2017-08-23 16:52:34 +08001061 mlm_start_req->beacon_tx_rate = session->beacon_tx_rate;
1062
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063 session->limPrevSmeState = session->limSmeState;
1064 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1065 MTRACE(mac_trace
1066 (mac_ctx, TRACE_CODE_SME_STATE,
1067 session->peSessionId,
1068 session->limSmeState));
1069
Abhishek Singhdfa69c32018-08-30 15:39:34 +05301070 qdf_status = lim_send_start_vdev_req(session, mlm_start_req);
1071 if (QDF_IS_STATUS_ERROR(qdf_status))
1072 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001073 return;
1074 } else {
1075
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001076 pe_err("Received unexpected START_BSS_REQ, in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001077 mac_ctx->lim.gLimSmeState);
1078 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001079 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001080 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1081
1082free:
1083 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001084 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001085 session->pLimStartBssReq = NULL;
1086 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001087 if (NULL != sme_start_bss_req)
1088 qdf_mem_free(sme_start_bss_req);
1089 if (NULL != mlm_start_req)
1090 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001091 if (NULL != session) {
1092 pe_delete_session(mac_ctx, session);
1093 session = NULL;
1094 }
1095 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1096 session, sme_session_id, sme_transaction_id);
1097}
1098
1099/**
1100 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1101 *
1102 * @pMac: Global MAC context
1103 * @pMsg: Message pointer
1104 *
1105 * Wrapper for the function __lim_handle_sme_start_bss_request
1106 * This message will be defered until softmac come out of
1107 * scan mode or if we have detected radar on the current
1108 * operating channel.
1109 *
1110 * return true - If we consumed the buffer
1111 * false - If have defered the message.
1112 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001113static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1114 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001115{
1116 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1117 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1118 /**
1119 * If message defered, buffer is not consumed yet.
1120 * So return false
1121 */
1122 return false;
1123 }
1124
1125 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1126 return true;
1127}
1128
1129/**
1130 * lim_get_random_bssid()
1131 *
1132 * FUNCTION:This function is called to process generate the random number for bssid
1133 * This function is called to process SME_SCAN_REQ message
1134 * from HDD or upper layer application.
1135 *
1136 * LOGIC:
1137 *
1138 * ASSUMPTIONS:
1139 *
1140 * NOTE:
1141 * 1. geneartes the unique random number for bssid in ibss
1142 *
1143 * @param pMac Pointer to Global MAC structure
1144 * @param *data Pointer to bssid buffer
1145 * @return None
1146 */
1147void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1148{
1149 uint32_t random[2];
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001150
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001151 random[0] = tx_time_get();
1152 random[0] |= (random[0] << 15);
1153 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301154 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001155}
1156
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001157/**
1158 * __lim_process_clear_dfs_channel_list()
1159 *
1160 ***FUNCTION:
Jeff Johnsonc00ae5b2018-05-06 16:06:35 -07001161 ***Clear DFS channel list when country is changed/acquired.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001162 .*This message is sent from SME.
1163 *
1164 ***LOGIC:
1165 *
1166 ***ASSUMPTIONS:
1167 *
1168 ***NOTE:
1169 *
1170 * @param pMac Pointer to Global MAC structure
1171 * @param *pMsgBuf A pointer to the SME message buffer
1172 * @return None
1173 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001174static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1175 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001176{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301177 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001178}
1179
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301180#ifdef WLAN_FEATURE_SAE
1181
1182/**
1183 * lim_update_sae_config()- This API update SAE session info to csr config
1184 * from join request.
1185 * @session: PE session
1186 * @sme_join_req: pointer to join request
1187 *
1188 * Return: None
1189 */
1190static void lim_update_sae_config(tpPESession session,
1191 tpSirSmeJoinReq sme_join_req)
1192{
1193 session->sae_pmk_cached = sme_join_req->sae_pmk_cached;
1194
1195 pe_debug("pmk_cached %d for BSSID=" MAC_ADDRESS_STR,
1196 session->sae_pmk_cached,
1197 MAC_ADDR_ARRAY(sme_join_req->bssDescription.bssId));
1198}
1199#else
1200static inline void lim_update_sae_config(tpPESession session,
1201 tpSirSmeJoinReq sme_join_req)
1202{}
1203#endif
1204
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001205/**
1206 * lim_send_join_req() - send vdev start request
1207 *@session: pe session
1208 *@mlm_join_req: join req
1209 *
1210 * Return: QDF_STATUS
1211 */
1212
1213#ifdef CONFIG_VDEV_SM
1214static QDF_STATUS lim_send_join_req(tpPESession session,
1215 tLimMlmJoinReq *mlm_join_req)
1216{
1217 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
1218 WLAN_VDEV_SM_EV_START,
1219 sizeof(*mlm_join_req),
1220 mlm_join_req);
1221}
1222#else
1223static QDF_STATUS lim_send_join_req(tpPESession session,
1224 tLimMlmJoinReq *mlm_join_req)
1225{
1226 lim_process_mlm_join_req(session->mac_ctx, mlm_join_req);
1227
1228 return QDF_STATUS_SUCCESS;
1229}
1230#endif
1231
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301232
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001233/**
1234 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1235 * @mac_ctx: Pointer to Global MAC structure
1236 * @msg_buf: A pointer to the SME message buffer
1237 *
1238 * This function is called to process SME_JOIN_REQ message
1239 * from HDD or upper layer application.
1240 *
1241 * Return: None
1242 */
1243static void
1244__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1245{
1246 tpSirSmeJoinReq sme_join_req = NULL;
1247 tLimMlmJoinReq *mlm_join_req;
1248 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1249 uint32_t val = 0;
1250 uint16_t n_size;
1251 uint8_t session_id;
1252 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301253 uint8_t sme_session_id = 0;
1254 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001255 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001256 uint16_t ie_len;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001257 const uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001258 tSirBssDescription *bss_desc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001259
Arif Hussain995fcaf2016-07-18 11:28:22 -07001260 if (!mac_ctx || !msg_buf) {
1261 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1262 FL("JOIN REQ with invalid data"));
1263 return;
1264 }
1265
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001266/* FEATURE_WLAN_DIAG_SUPPORT */
1267#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1268 /*
1269 * Not sending any session, since it is not created yet.
1270 * The response whould have correct state.
1271 */
1272 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1273#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1274
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001275 /*
1276 * Expect Join request in idle state.
1277 * Reassociate request is expected in link established state.
1278 */
1279
1280 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1281 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1282 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1283 msg_buf);
1284
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301285 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286 if (NULL == sme_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001287 pe_err("AllocateMemory failed for sme_join_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001288 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301289 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001290 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301291 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001292 n_size);
1293
1294 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1295 /* Received invalid eWNI_SME_JOIN_REQ */
1296 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001297 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001298 sme_join_req->sessionId);
1299 ret_code = eSIR_SME_INVALID_PARAMETERS;
1300 goto end;
1301 }
1302
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001303 /*
1304 * Update the capability here itself as this is used in
1305 * lim_extract_ap_capability() below. If not updated issues
1306 * like not honoring power constraint on 1st association after
1307 * driver loading might occur.
1308 */
1309 lim_update_rrm_capability(mac_ctx, sme_join_req);
1310
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001311 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001313 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001314 &session_id);
1315
1316 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001317 pe_err("Session(%d) Already exists for BSSID: "
1318 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001319 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001320 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001321 session->limSmeState);
1322
1323 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1324 session->smeSessionId == sme_join_req->sessionId) {
1325 /*
1326 * Received eWNI_SME_JOIN_REQ for same
1327 * BSS as currently associated.
1328 * Log the event and send success
1329 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001330 pe_warn("SessionId: %d", session_id);
1331 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001332 /* Send Join success response to host */
1333 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1334 session = NULL;
1335 goto end;
1336 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001337 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001338 ret_code = eSIR_SME_REFUSED;
1339 session = NULL;
1340 goto end;
1341 }
1342 } else {
1343 /*
1344 * Session Entry does not exist for given BSSId
1345 * Try to Create a new session
1346 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001347 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001348 &session_id, mac_ctx->lim.maxStation,
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +05301349 eSIR_INFRASTRUCTURE_MODE,
1350 sme_join_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001351 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001352 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001353 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1354 goto end;
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301355 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001356 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001357 session_id);
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301358 }
1359
1360 /* Update the beacon/probe filter in mac_ctx */
1361 lim_set_bcn_probe_filter(mac_ctx, session,
1362 &sme_join_req->ssId,
1363 bss_desc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001364 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001365 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Arif Hussain6686c0b2018-08-21 18:21:05 -07001366 session->enable_session_twt_support =
1367 sme_join_req->enable_session_twt_support;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001368 /*
1369 * Store Session related parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001370 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001371
1372 /* store the smejoin req handle in session table */
1373 session->pLimJoinReq = sme_join_req;
1374
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001375 /* Store SME transaction Id in session Table */
1376 session->transactionId = sme_join_req->transactionId;
1377
1378 /* Store beaconInterval */
1379 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001380 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301382 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001383 sizeof(session->htConfig));
1384
Sandeep Puligilla98917432016-06-10 13:50:28 -07001385 qdf_mem_copy(&(session->vht_config),
1386 &(sme_join_req->vht_config),
1387 sizeof(session->vht_config));
1388
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001389 /* Copying of bssId is already done, while creating session */
1390 sir_copy_mac_addr(session->selfMacAddr,
1391 sme_join_req->selfMacAddr);
1392 session->bssType = sme_join_req->bsstype;
1393
1394 session->statypeForBss = STA_ENTRY_PEER;
1395 session->limWmeEnabled = sme_join_req->isWMEenabled;
1396 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301397 session->wps_registration = sme_join_req->wps_registration;
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001398 session->he_with_wep_tkip = sme_join_req->he_with_wep_tkip;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001399
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301400 session->enable_bcast_probe_rsp =
1401 sme_join_req->enable_bcast_probe_rsp;
1402
Jeff Johnson179fd8a2018-05-11 14:20:05 -07001403 /* Store vendor specific IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001404 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001405 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1406
Naveen Rawat08db88f2017-09-08 15:07:48 -07001407 vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001408 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001409 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001410
1411 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001412 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001413 session->isCiscoVendorAP = true;
1414 } else {
1415 session->isCiscoVendorAP = false;
1416 }
1417
1418 /* Copy the dot 11 mode in to the session table */
1419
1420 session->dot11mode = sme_join_req->dot11mode;
1421#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1422 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1423#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001424 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001425 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1426 session->enableHtSmps = sme_join_req->enableHtSmps;
1427 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001428 session->send_smps_action =
1429 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001430 /*
1431 * By default supported NSS 1x1 is set to true
1432 * and later on updated while determining session
1433 * supported rates which is the intersection of
1434 * self and peer rates
1435 */
1436 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301437 /*Store Persona */
1438 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001439 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 -08001440 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001441 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001442 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301443 session->supported_nss_1x1,
1444 session->pePersona,
1445 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001446
1447 /*Store Persona */
1448 session->pePersona = sme_join_req->staPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +05301449 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301450 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d force_24ghz_in_ht20 %d"),
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001451 session->pePersona, sme_join_req->cbMode,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301452 session->nwType, session->dot11mode,
1453 sme_join_req->force_24ghz_in_ht20);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001454
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001455 /* Copy The channel Id to the session Table */
1456 session->currentOperChannel = bss_desc->channelId;
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301457
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001458 session->vhtCapability =
1459 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001460 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301461 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001462 session->vht_config.su_beam_formee =
1463 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001464 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001465 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001466 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001467 session->enableVhtpAid =
1468 sme_join_req->enableVhtpAid;
1469 session->enableVhtGid =
1470 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001471 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001472 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001473 }
Krunal Soni53993f72016-07-08 18:20:03 -07001474
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001475 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301476 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001477 session->vht_config.su_beam_formee,
1478 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001479 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001480 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001481 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001482 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301483 session->force_24ghz_in_ht20 =
1484 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001485 /* cbMode is already merged value of peer and self -
1486 * done by csr in csr_get_cb_mode_from_ies */
1487 session->htSupportedChannelWidthSet =
1488 (sme_join_req->cbMode) ? 1 : 0;
1489 session->htRecommendedTxWidthSet =
1490 session->htSupportedChannelWidthSet;
1491 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1492
1493 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1494 session->ch_center_freq_seg0 =
1495 session->currentOperChannel - 2;
1496 session->ch_width = CH_WIDTH_40MHZ;
1497 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1498 sme_join_req->cbMode) {
1499 session->ch_center_freq_seg0 =
1500 session->currentOperChannel + 2;
1501 session->ch_width = CH_WIDTH_40MHZ;
1502 } else {
1503 session->ch_center_freq_seg0 = 0;
1504 session->ch_width = CH_WIDTH_20MHZ;
1505 }
1506
Naveen Rawataeca1b92017-10-16 16:55:31 -07001507 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1508 lim_update_session_he_capable(mac_ctx, session);
1509 lim_copy_join_req_he_cap(session, sme_join_req);
1510 }
1511
1512
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001513 /* Record if management frames need to be protected */
1514#ifdef WLAN_FEATURE_11W
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +05301515 if ((eSIR_ED_AES_128_CMAC ==
1516 sme_join_req->MgmtEncryptionType) ||
1517 (eSIR_ED_AES_GMAC_128 == sme_join_req->MgmtEncryptionType) ||
1518 (eSIR_ED_AES_GMAC_256 == sme_join_req->MgmtEncryptionType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001519 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001520 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001522#endif
1523
1524#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001525 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526#endif
1527
1528 /* Copy the SSID from smejoinreq to session entry */
1529 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301530 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531 session->ssId.length);
1532
1533 /*
1534 * Determin 11r or ESE connection based on input from SME
1535 * which inturn is dependent on the profile the user wants
1536 * to connect to, So input is coming from supplicant
1537 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001538 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001539#ifdef FEATURE_WLAN_ESE
1540 session->isESEconnection = sme_join_req->isESEconnection;
1541#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001542 session->isFastTransitionEnabled =
1543 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001544
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001545 session->isFastRoamIniFeatureEnabled =
1546 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001547 session->txLdpcIniFeatureEnabled =
1548 sme_join_req->txLdpcIniFeatureEnabled;
1549
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301550 lim_update_fils_config(session, sme_join_req);
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301551 lim_update_sae_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001552 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1553 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001554 } else {
1555 /*
1556 * Throw an error and return and make
1557 * sure to delete the session.
1558 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001559 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001560 session->bssType);
1561 ret_code = eSIR_SME_INVALID_PARAMETERS;
1562 goto end;
1563 }
1564
1565 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301566 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001567 &sme_join_req->addIEScan, sizeof(tSirAddie));
1568
1569 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301570 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001571 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1572
1573 val = sizeof(tLimMlmJoinReq) +
1574 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301575 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001576 if (NULL == mlm_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001577 pe_err("AllocateMemory failed for mlmJoinReq");
Nitesh Shah0102cac2016-07-13 14:38:30 +05301578 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1579 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001580 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581
1582 /* PE SessionId is stored as a part of JoinReq */
1583 mlm_join_req->sessionId = session->peSessionId;
1584
1585 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1586 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001587 QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001588 pe_err("couldn't retrieve JoinFailureTimer value"
1589 " setting to default value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590 mlm_join_req->joinFailureTimeout =
1591 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1592 }
1593
1594 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301595 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001596 (void *)&sme_join_req->operationalRateSet,
1597 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301598 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001599 (void *)&sme_join_req->extendedRateSet,
1600 sizeof(tSirMacRateSet));
1601 /*
1602 * this may not be needed anymore now, as rateSet is now
1603 * included in the session entry and MLM has session context.
1604 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301605 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001606 (void *)&session->rateSet,
1607 sizeof(tSirMacRateSet));
1608
1609 session->encryptType = sme_join_req->UCEncryptionType;
1610
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301611 session->supported_nss_1x1 = sme_join_req->supported_nss_1x1;
1612 session->vdev_nss = sme_join_req->vdev_nss;
1613 session->nss = sme_join_req->nss;
1614 session->nss_forced_1x1 = sme_join_req->nss_forced_1x1;
1615
1616 pe_debug("nss %d, vdev_nss %d, supported_nss_1x1 %d",
1617 session->nss,
1618 session->vdev_nss,
1619 session->supported_nss_1x1);
1620
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001621 mlm_join_req->bssDescription.length =
1622 session->pLimJoinReq->bssDescription.length;
1623
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301624 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001625 (uint8_t *)
1626 &session->pLimJoinReq->bssDescription.bssId,
1627 session->pLimJoinReq->bssDescription.length + 2);
1628
1629 session->limCurrentBssCaps =
1630 session->pLimJoinReq->bssDescription.capabilityInfo;
1631
1632 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1633 session->currentOperChannel);
1634 local_power_constraint = reg_max;
1635
1636 lim_extract_ap_capability(mac_ctx,
1637 (uint8_t *)
1638 session->pLimJoinReq->bssDescription.ieFields,
1639 lim_get_ielen_from_bss_description(
1640 &session->pLimJoinReq->bssDescription),
1641 &session->limCurrentBssQosCaps,
1642 &session->limCurrentBssPropCap,
1643 &session->gLimCurrentBssUapsd,
1644 &local_power_constraint, session);
1645
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001646 session->maxTxPower = lim_get_max_tx_power(reg_max,
1647 local_power_constraint,
1648 mac_ctx->roam.configParam.nTxPowerCap);
Abhinav Kumard528d192018-03-09 17:31:12 +05301649 session->def_max_tx_pwr = session->maxTxPower;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301650
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001651 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301652 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001653
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301654 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1655 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1656 pe_debug("Update MaxTxPower in join Req to %d",
1657 sme_join_req->powerCap.maxTxPower);
1658 }
1659
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001660 if (session->gLimCurrentBssUapsd) {
1661 session->gUapsdPerAcBitmask =
1662 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001663 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001664 session->gUapsdPerAcBitmask);
1665
1666 /* resetting the dynamic uapsd mask */
1667 session->gUapsdPerAcDeliveryEnableMask = 0;
1668 session->gUapsdPerAcTriggerEnableMask = 0;
1669 }
1670
1671 session->limRFBand =
1672 lim_get_rf_band(session->currentOperChannel);
1673
1674 /* Initialize 11h Enable Flag */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001675 if (BAND_5G == session->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001676 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001677 &val) != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001678 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001679 session->lim11hEnable =
1680 WNI_CFG_11H_ENABLED_STADEF;
1681 } else {
1682 session->lim11hEnable = val;
1683 }
1684 } else {
1685 session->lim11hEnable = 0;
1686 }
1687
1688 /*
1689 * To care of the scenario when STA transitions from
1690 * IBSS to Infrastructure mode.
1691 */
1692 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1693
1694 session->limPrevSmeState = session->limSmeState;
1695 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1696 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1697 session->peSessionId,
1698 session->limSmeState));
1699
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001700 /* Indicate whether spectrum management is enabled */
1701 session->spectrumMgtEnabled =
1702 sme_join_req->spectrumMgtIndicator;
1703
1704 /* Enable the spectrum management if this is a DFS channel */
1705 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001706 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001707 session->currentOperChannel))
1708 session->spectrumMgtEnabled = true;
1709
1710 session->isOSENConnection = sme_join_req->isOSENConnection;
1711
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001712 /* Issue LIM_MLM_JOIN_REQ to MLM */
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001713 lim_send_join_req(session, mlm_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001714 return;
1715
1716 } else {
1717 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001718 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001719 mac_ctx->lim.gLimSmeState);
1720 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1721 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1722 session = NULL;
1723 goto end;
1724 }
1725
1726end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301727 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1728 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001729
1730 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301731 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001732 sme_join_req = NULL;
1733 if (NULL != session)
1734 session->pLimJoinReq = NULL;
1735 }
1736 if (ret_code != eSIR_SME_SUCCESS) {
1737 if (NULL != session) {
1738 pe_delete_session(mac_ctx, session);
1739 session = NULL;
1740 }
1741 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001742 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001743 sme_session_id, ret_code);
1744 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1745 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1746 sme_transaction_id);
1747}
1748
Amar Singhala297bfa2015-10-15 15:07:29 -07001749uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001750 uint8_t iniTxPower)
1751{
1752 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301753 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001754
Anurag Chouhan6d760662016-02-20 16:05:43 +05301755 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1757 maxTxPower = txPower;
1758 else if (txPower < MIN_TX_PWR_CAP)
1759 maxTxPower = MIN_TX_PWR_CAP;
1760 else
1761 maxTxPower = MAX_TX_PWR_CAP;
1762
1763 return maxTxPower;
1764}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001765
1766/**
1767 * __lim_process_sme_reassoc_req() - process reassoc req
1768 *
1769 * @mac_ctx: Pointer to Global MAC structure
1770 * @msg_buf: pointer to the SME message buffer
1771 *
1772 * This function is called to process SME_REASSOC_REQ message
1773 * from HDD or upper layer application.
1774 *
1775 * Return: None
1776 */
1777
1778static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
1779 uint32_t *msg_buf)
1780{
1781 uint16_t caps;
1782 uint32_t val;
1783 tpSirSmeJoinReq reassoc_req = NULL;
1784 tLimMlmReassocReq *mlm_reassoc_req;
1785 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1786 tpPESession session_entry = NULL;
1787 uint8_t session_id;
1788 uint8_t sme_session_id;
1789 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001790 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001791 uint32_t tele_bcn_en = 0;
1792 uint16_t size;
1793
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001794 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301795 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001797 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001798
1799 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1800 goto end;
1801 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301802 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001803
1804 if (!lim_is_sme_join_req_valid(mac_ctx,
1805 (tpSirSmeJoinReq)reassoc_req)) {
1806 /*
1807 * Received invalid eWNI_SME_REASSOC_REQ
1808 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001809 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001810
1811 ret_code = eSIR_SME_INVALID_PARAMETERS;
1812 goto end;
1813 }
1814
1815 session_entry = pe_find_session_by_bssid(mac_ctx,
1816 reassoc_req->bssDescription.bssId,
1817 &session_id);
1818 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001819 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001820 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
1821 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001822 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001823 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
1824 &sme_session_id, &transaction_id);
1825 session_entry =
1826 pe_find_session_by_sme_session_id(mac_ctx,
1827 sme_session_id);
1828 if (session_entry != NULL)
1829 lim_handle_sme_join_result(mac_ctx,
1830 eSIR_SME_INVALID_PARAMETERS,
1831 eSIR_MAC_UNSPEC_FAILURE_STATUS,
1832 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833 goto end;
1834 }
1835#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
1836 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001837 session_entry, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001838#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1839 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
1840
1841 /* Store the reassoc handle in the session Table */
1842 session_entry->pLimReAssocReq = reassoc_req;
1843
1844 session_entry->dot11mode = reassoc_req->dot11mode;
1845 session_entry->vhtCapability =
1846 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001847
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301848 if (session_entry->vhtCapability) {
1849 if (session_entry->pePersona == QDF_STA_MODE) {
1850 session_entry->vht_config.su_beam_formee =
1851 reassoc_req->vht_config.su_beam_formee;
1852 } else {
1853 reassoc_req->vht_config.su_beam_formee = 0;
1854 }
1855 session_entry->enableVhtpAid =
1856 reassoc_req->enableVhtpAid;
1857 session_entry->enableVhtGid =
1858 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001859 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301860 }
1861
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301862 session_entry->supported_nss_1x1 = reassoc_req->supported_nss_1x1;
1863 session_entry->vdev_nss = reassoc_req->vdev_nss;
1864 session_entry->nss = reassoc_req->nss;
1865 session_entry->nss_forced_1x1 = reassoc_req->nss_forced_1x1;
1866
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001867 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301868 session_entry->vhtCapability,
1869 session_entry->vht_config.su_beam_formee,
1870 session_entry->vht_config.su_beam_former);
1871
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001872 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
1873 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001874 session_entry->send_smps_action =
1875 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001876 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001877 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001878 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001879 session_entry->send_smps_action,
1880 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001881 /*
1882 * Reassociate request is expected
1883 * in link established state only.
1884 */
1885
1886 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001887 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
1888 /*
1889 * May be from 11r FT pre-auth. So lets check it
1890 * before we bail out
1891 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001892 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001893 session_entry->peSessionId);
1894
1895 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301896 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001897 session_entry->limReAssocbssId,
1898 6)) {
1899 lim_print_mac_addr(mac_ctx,
1900 reassoc_req->bssDescription.
1901 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001902 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001903 ret_code = eSIR_SME_INVALID_PARAMETERS;
1904 goto end;
1905 }
1906
1907 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
1908 session_entry);
1909 return;
1910 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001911 /*
1912 * Should not have received eWNI_SME_REASSOC_REQ
1913 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001914 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001915 session_entry->limSmeState);
1916 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
1917
1918 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1919 goto end;
1920 }
1921
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301922 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001923 session_entry->pLimReAssocReq->bssDescription.bssId,
1924 sizeof(tSirMacAddr));
1925
1926 session_entry->limReassocChannelId =
1927 session_entry->pLimReAssocReq->bssDescription.channelId;
1928
1929 session_entry->reAssocHtSupportedChannelWidthSet =
1930 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
1931 session_entry->reAssocHtRecommendedTxWidthSet =
1932 session_entry->reAssocHtSupportedChannelWidthSet;
1933 session_entry->reAssocHtSecondaryChannelOffset =
1934 session_entry->pLimReAssocReq->cbMode;
1935
1936 session_entry->limReassocBssCaps =
1937 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
1938 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1939 session_entry->currentOperChannel);
1940 local_pwr_constraint = reg_max;
1941
1942 lim_extract_ap_capability(mac_ctx,
1943 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
1944 lim_get_ielen_from_bss_description(
1945 &session_entry->pLimReAssocReq->bssDescription),
1946 &session_entry->limReassocBssQosCaps,
1947 &session_entry->limReassocBssPropCap,
1948 &session_entry->gLimCurrentBssUapsd,
1949 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05301950 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001951 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301952 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001953 /* Copy the SSID from session entry to local variable */
1954 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301955 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001956 reassoc_req->ssId.ssId,
1957 session_entry->limReassocSSID.length);
1958 if (session_entry->gLimCurrentBssUapsd) {
1959 session_entry->gUapsdPerAcBitmask =
1960 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001961 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001962 session_entry->gUapsdPerAcBitmask);
1963 }
1964
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301965 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001966 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001967 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001968
1969 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1970 goto end;
1971 }
1972
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301973 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001974 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
1975
1976 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
1977 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001978 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001979 pe_err("could not retrieve ReassocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001980
1981 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001982 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001983 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301984
1985 lim_update_caps_info_for_bss(mac_ctx, &caps,
1986 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001987 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301988
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001989 mlm_reassoc_req->capabilityInfo = caps;
1990
1991 /* Update PE session_id */
1992 mlm_reassoc_req->sessionId = session_id;
1993
1994 /*
1995 * If telescopic beaconing is enabled, set listen interval to
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05301996 * CFG_TELE_BCN_MAX_LI
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001997 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05301999 tele_bcn_en = mac_ctx->mlme_cfg->sap_cfg.tele_bcn_wakeup_en;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05302001 if (tele_bcn_en)
2002 val = mac_ctx->mlme_cfg->sap_cfg.tele_bcn_max_li;
2003 else
2004 val = mac_ctx->mlme_cfg->sap_cfg.listen_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002005
2006 mlm_reassoc_req->listenInterval = (uint16_t) val;
2007
2008 /* Indicate whether spectrum management is enabled */
2009 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2010
2011 /* Enable the spectrum management if this is a DFS channel */
2012 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002013 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002014 session_entry->currentOperChannel))
2015 session_entry->spectrumMgtEnabled = true;
2016
2017 session_entry->limPrevSmeState = session_entry->limSmeState;
2018 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2019
2020 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2021 session_entry->peSessionId,
2022 session_entry->limSmeState));
2023
2024 lim_post_mlm_message(mac_ctx,
2025 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2026 return;
2027end:
2028 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302029 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002030 if (session_entry)
2031 session_entry->pLimReAssocReq = NULL;
2032 }
2033
2034 if (session_entry) {
2035 /*
2036 * error occurred after we determined the session so extract
2037 * session and transaction info from there
2038 */
2039 sme_session_id = session_entry->smeSessionId;
2040 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002041 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002042 /*
2043 * error occurred before or during the time we determined
2044 * the session so extract the session and transaction info
2045 * from the message
2046 */
2047 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2048 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002049 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002050 /*
2051 * Send Reassoc failure response to host
2052 * (note session_entry may be NULL, but that's OK)
2053 */
2054 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2055 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2056 session_entry, sme_session_id,
2057 transaction_id);
2058}
2059
2060bool send_disassoc_frame = 1;
2061/**
2062 * __lim_process_sme_disassoc_req()
2063 *
2064 ***FUNCTION:
2065 * This function is called to process SME_DISASSOC_REQ message
2066 * from HDD or upper layer application.
2067 *
2068 ***LOGIC:
2069 *
2070 ***ASSUMPTIONS:
2071 *
2072 ***NOTE:
2073 *
2074 * @param pMac Pointer to Global MAC structure
2075 * @param *pMsgBuf A pointer to the SME message buffer
2076 * @return None
2077 */
2078
2079static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2080{
2081 uint16_t disassocTrigger, reasonCode;
2082 tLimMlmDisassocReq *pMlmDisassocReq;
2083 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2084 tSirSmeDisassocReq smeDisassocReq;
2085 tpPESession psessionEntry = NULL;
2086 uint8_t sessionId;
2087 uint8_t smesessionId;
2088 uint16_t smetransactionId;
2089
2090 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002091 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002092 return;
2093 }
2094
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302095 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002096 smesessionId = smeDisassocReq.sessionId;
2097 smetransactionId = smeDisassocReq.transactionId;
2098 if (!lim_is_sme_disassoc_req_valid(pMac,
2099 &smeDisassocReq,
2100 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002101 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002102 if (pMac->lim.gLimRspReqd) {
2103 pMac->lim.gLimRspReqd = false;
2104
2105 retCode = eSIR_SME_INVALID_PARAMETERS;
2106 disassocTrigger = eLIM_HOST_DISASSOC;
2107 goto sendDisassoc;
2108 }
2109
2110 return;
2111 }
2112
2113 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002114 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002115 &sessionId);
2116 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002117 pe_err("session does not exist for given bssId "
2118 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002119 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002120 retCode = eSIR_SME_INVALID_PARAMETERS;
2121 disassocTrigger = eLIM_HOST_DISASSOC;
2122 goto sendDisassoc;
2123 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002124 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2125 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002126 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2127 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002128 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002129
2130#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2131 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2132 0, smeDisassocReq.reasonCode);
2133#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2134
2135 /* Update SME session Id and SME transaction ID */
2136
2137 psessionEntry->smeSessionId = smesessionId;
2138 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002139 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002140 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002141
2142 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2143 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002144 switch (psessionEntry->limSmeState) {
2145 case eLIM_SME_ASSOCIATED_STATE:
2146 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002147 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002148 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149 psessionEntry->limPrevSmeState =
2150 psessionEntry->limSmeState;
2151 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002152 /* Delete all TDLS peers connected before leaving BSS */
2153 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002154 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2155 psessionEntry->peSessionId,
2156 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002157 break;
2158
2159 case eLIM_SME_WT_DEAUTH_STATE:
2160 /* PE shall still process the DISASSOC_REQ and proceed with
2161 * link tear down even if it had already sent a DEAUTH_IND to
2162 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2163 * its been set when PE entered WT_DEAUTH_STATE.
2164 */
2165 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2166 MTRACE(mac_trace
2167 (pMac, TRACE_CODE_SME_STATE,
2168 psessionEntry->peSessionId,
2169 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002170 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002171 break;
2172
2173 case eLIM_SME_WT_DISASSOC_STATE:
Jeff Johnson47d75242018-05-12 15:58:53 -07002174 /* PE Received a Disassoc frame. Normally it gets DISASSOC_CNF but it
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002175 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2176 * PE can continue processing DISASSOC_REQ and send the response instead
2177 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2178 * for disassoc frame.
2179 *
2180 * It will send a disassoc, which is ok. However, we can use the global flag
2181 * sendDisassoc to not send disassoc frame.
2182 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002183 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002184 break;
2185
2186 case eLIM_SME_JOIN_FAILURE_STATE: {
2187 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002188 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002189 if (pMac->lim.gLimRspReqd) {
2190 retCode = eSIR_SME_SUCCESS;
2191 disassocTrigger = eLIM_HOST_DISASSOC;
2192 goto sendDisassoc;
2193 }
2194 }
2195 break;
2196 default:
2197 /**
2198 * STA is not currently associated.
2199 * Log error and send response to host
2200 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002201 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002202 psessionEntry->limSmeState);
2203 lim_print_sme_state(pMac, LOGE,
2204 psessionEntry->limSmeState);
2205
2206 if (pMac->lim.gLimRspReqd) {
2207 if (psessionEntry->limSmeState !=
2208 eLIM_SME_WT_ASSOC_STATE)
2209 pMac->lim.gLimRspReqd = false;
2210
2211 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2212 disassocTrigger = eLIM_HOST_DISASSOC;
2213 goto sendDisassoc;
2214 }
2215
2216 return;
2217 }
2218
2219 break;
2220
2221 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002222 /* Fall through */
2223 break;
2224
2225 case eLIM_STA_IN_IBSS_ROLE:
2226 default:
2227 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002228 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002229 GET_LIM_SYSTEM_ROLE(psessionEntry));
2230
2231 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2232 disassocTrigger = eLIM_HOST_DISASSOC;
2233 goto sendDisassoc;
2234 } /* end switch (pMac->lim.gLimSystemRole) */
2235
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302236 disassocTrigger = eLIM_HOST_DISASSOC;
2237 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002238
2239 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002240 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002241 send_disassoc_frame = 0;
2242 }
2243 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002244 pe_debug("Sending Disasscoc with disassoc Trigger"
2245 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002246 disassocTrigger, reasonCode);
2247
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302248 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002249 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002250 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002251 return;
2252 }
2253
Anurag Chouhanc5548422016-02-24 18:33:27 +05302254 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002255 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002256
2257 pMlmDisassocReq->reasonCode = reasonCode;
2258 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2259
2260 /* Update PE session ID */
2261 pMlmDisassocReq->sessionId = sessionId;
2262
2263 lim_post_mlm_message(pMac,
2264 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2265 return;
2266
2267sendDisassoc:
2268 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002269 lim_send_sme_disassoc_ntf(pMac,
2270 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002271 retCode,
2272 disassocTrigger,
2273 1, smesessionId, smetransactionId,
2274 psessionEntry);
2275 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002276 lim_send_sme_disassoc_ntf(pMac,
2277 smeDisassocReq.peer_macaddr.bytes,
2278 retCode, disassocTrigger, 1,
2279 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002280
2281} /*** end __lim_process_sme_disassoc_req() ***/
2282
2283/** -----------------------------------------------------------------
2284 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2285
2286 This function is called to process SME_DISASSOC_CNF message
2287 from HDD or upper layer application.
2288
2289 \param pMac - global mac structure
2290 \param pStaDs - station dph hash node
2291 \return none
2292 \sa
2293 ----------------------------------------------------------------- */
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002294void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002295{
2296 tSirSmeDisassocCnf smeDisassocCnf;
2297 uint16_t aid;
2298 tpDphHashNode pStaDs;
2299 tpPESession psessionEntry;
2300 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302301 uint32_t *msg = NULL;
2302 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002303
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302304 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002305 sizeof(struct sSirSmeDisassocCnf));
2306
2307 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002308 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002309 &sessionId);
2310 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002311 pe_err("session does not exist for given bssId");
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302312 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302313 smeDisassocCnf.sme_session_id,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302314 eSIR_SME_INVALID_SESSION,
2315 NULL);
2316 if (QDF_IS_STATUS_SUCCESS(status))
2317 lim_send_sme_disassoc_deauth_ntf(pMac,
2318 QDF_STATUS_SUCCESS,
2319 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002320 return;
2321 }
2322
2323 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002324 pe_err("received invalid SME_DISASSOC_CNF message");
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302325 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2326 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302327 eSIR_SME_INVALID_PARAMETERS,
2328 &smeDisassocCnf.bssid.bytes[0]);
2329 if (QDF_IS_STATUS_SUCCESS(status))
2330 lim_send_sme_disassoc_deauth_ntf(pMac,
2331 QDF_STATUS_SUCCESS,
2332 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002333 return;
2334 }
2335#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2336 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2337 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2338 psessionEntry,
2339 (uint16_t) smeDisassocCnf.statusCode, 0);
2340 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2341 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2342 psessionEntry,
2343 (uint16_t) smeDisassocCnf.statusCode, 0);
2344#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2345
2346 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2347 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002348 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2349 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2350 && (psessionEntry->limSmeState !=
2351 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002352 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002353 psessionEntry->limSmeState);
2354 lim_print_sme_state(pMac, LOGE,
2355 psessionEntry->limSmeState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302356 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302357 psessionEntry->smeSessionId,
2358 eSIR_SME_INVALID_STATE,
2359 &smeDisassocCnf.bssid.bytes[0]);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302360 if (QDF_IS_STATUS_SUCCESS(status))
2361 lim_send_sme_disassoc_deauth_ntf(pMac,
2362 QDF_STATUS_SUCCESS,
2363 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002364 return;
2365 }
2366 break;
2367
2368 case eLIM_AP_ROLE:
2369 /* Fall through */
2370 break;
2371
2372 case eLIM_STA_IN_IBSS_ROLE:
2373 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002374 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002375 GET_LIM_SYSTEM_ROLE(psessionEntry));
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302376 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2377 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302378 eSIR_SME_INVALID_STATE,
2379 &smeDisassocCnf.bssid.bytes[0]);
2380 if (QDF_IS_STATUS_SUCCESS(status))
2381 lim_send_sme_disassoc_deauth_ntf(pMac,
2382 QDF_STATUS_SUCCESS,
2383 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002384 return;
2385 }
2386
2387 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2388 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2389 LIM_IS_AP_ROLE(psessionEntry)) {
2390 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002391 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002392 &psessionEntry->dph.dphHashTable);
2393 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002394 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2395 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002396 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302397 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302398 psessionEntry->smeSessionId,
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05302399 eSIR_SME_INVALID_PARAMETERS,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302400 &smeDisassocCnf.bssid.bytes[0]);
2401 if (QDF_IS_STATUS_SUCCESS(status))
2402 lim_send_sme_disassoc_deauth_ntf(pMac,
2403 QDF_STATUS_SUCCESS,
2404 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002405 return;
2406 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302407
2408 if ((pStaDs->mlmStaContext.mlmState ==
2409 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2410 (pStaDs->mlmStaContext.mlmState ==
Arif Hussain5fa13782018-05-10 11:29:52 -07002411 eLIM_MLM_WT_DEL_BSS_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002412 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002413 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302414 pStaDs->mlmStaContext.mlmState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302415 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302416 psessionEntry->smeSessionId,
2417 eSIR_SME_SUCCESS,
2418 NULL);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302419 if (QDF_IS_STATUS_SUCCESS(status))
2420 lim_send_sme_disassoc_deauth_ntf(pMac,
2421 QDF_STATUS_SUCCESS,
2422 (uint32_t *)msg);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302423 return;
2424 }
2425
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002426 /* Delete FT session if there exists one */
2427 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002428 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2429
2430 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002431 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002432 }
2433
2434 return;
2435}
2436
2437/**
2438 * __lim_process_sme_deauth_req() - process sme deauth req
2439 * @mac_ctx: Pointer to Global MAC structure
2440 * @msg_buf: pointer to the SME message buffer
2441 *
2442 * This function is called to process SME_DEAUTH_REQ message
2443 * from HDD or upper layer application.
2444 *
2445 * Return: None
2446 */
2447
2448static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2449 uint32_t *msg_buf)
2450{
2451 uint16_t deauth_trigger, reason_code;
2452 tLimMlmDeauthReq *mlm_deauth_req;
2453 tSirSmeDeauthReq sme_deauth_req;
2454 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2455 tpPESession session_entry;
2456 uint8_t session_id; /* PE sessionId */
2457 uint8_t sme_session_id;
2458 uint16_t sme_transaction_id;
2459
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302460 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002461 sme_session_id = sme_deauth_req.sessionId;
2462 sme_transaction_id = sme_deauth_req.transactionId;
2463
2464 /*
2465 * We need to get a session first but we don't even know
2466 * if the message is correct.
2467 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002468 session_entry = pe_find_session_by_bssid(mac_ctx,
2469 sme_deauth_req.bssid.bytes,
2470 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002471 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002472 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002473 ret_code = eSIR_SME_INVALID_PARAMETERS;
2474 deauth_trigger = eLIM_HOST_DEAUTH;
2475 goto send_deauth;
2476 }
2477
2478 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2479 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002480 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002481 mac_ctx->lim.gLimRspReqd = false;
2482
2483 ret_code = eSIR_SME_INVALID_PARAMETERS;
2484 deauth_trigger = eLIM_HOST_DEAUTH;
2485 goto send_deauth;
2486 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002487 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2488 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002489 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2490 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002491 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002492#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2493 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2494 session_entry, 0, sme_deauth_req.reasonCode);
2495#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2496
2497 /* Update SME session ID and Transaction ID */
2498 session_entry->smeSessionId = sme_session_id;
2499 session_entry->transactionId = sme_transaction_id;
2500
2501 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2502 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002503 switch (session_entry->limSmeState) {
2504 case eLIM_SME_ASSOCIATED_STATE:
2505 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302506 /* Delete all TDLS peers connected before leaving BSS */
2507 lim_delete_tdls_peers(mac_ctx, session_entry);
Abhinav Kumarac12c762018-05-02 13:51:02 +05302508 /* fallthrough */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002509 case eLIM_SME_WT_ASSOC_STATE:
2510 case eLIM_SME_JOIN_FAILURE_STATE:
2511 case eLIM_SME_IDLE_STATE:
2512 session_entry->limPrevSmeState =
2513 session_entry->limSmeState;
2514 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2515 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2516 session_entry->peSessionId,
2517 session_entry->limSmeState));
2518 /* Send Deauthentication request to MLM below */
2519 break;
2520 case eLIM_SME_WT_DEAUTH_STATE:
2521 case eLIM_SME_WT_DISASSOC_STATE:
2522 /*
Jeff Johnson47d75242018-05-12 15:58:53 -07002523 * PE Received a Deauth/Disassoc frame. Normally it get
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002524 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2525 * Which means host is also trying to disconnect.
2526 * PE can continue processing DEAUTH_REQ and send
2527 * the response instead of failing the request.
2528 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2529 * was sent for deauth/disassoc frame.
2530 */
2531 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002532 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002533 break;
2534 default:
2535 /*
2536 * STA is not in a state to deauthenticate with
2537 * peer. Log error and send response to host.
2538 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002539 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002540 session_entry->limSmeState);
2541 lim_print_sme_state(mac_ctx, LOGE,
2542 session_entry->limSmeState);
2543
2544 if (mac_ctx->lim.gLimRspReqd) {
2545 mac_ctx->lim.gLimRspReqd = false;
2546
2547 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2548 deauth_trigger = eLIM_HOST_DEAUTH;
2549
wadesong42968e92017-06-08 14:11:21 +08002550 /*
2551 * here we received deauth request from AP so
2552 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2553 * have ISSUED delSta then mlm state should be
2554 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2555 * delBSS rsp then mlm state should be
2556 * eLIM_MLM_IDLE_STATE so the below condition
2557 * captures the state where delSta not done
2558 * and firmware still in connected state.
2559 */
2560 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002561 eLIM_SME_WT_DEAUTH_STATE &&
2562 session_entry->limMlmState !=
2563 eLIM_MLM_IDLE_STATE &&
2564 session_entry->limMlmState !=
2565 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002566 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002567 goto send_deauth;
2568 }
2569 return;
2570 }
2571 break;
2572
2573 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002574 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002575 if (mac_ctx->lim.gLimRspReqd) {
2576 mac_ctx->lim.gLimRspReqd = false;
2577 ret_code = eSIR_SME_INVALID_PARAMETERS;
2578 deauth_trigger = eLIM_HOST_DEAUTH;
2579 goto send_deauth;
2580 }
2581 return;
2582 case eLIM_AP_ROLE:
2583 break;
2584 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002585 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002586 GET_LIM_SYSTEM_ROLE(session_entry));
2587 if (mac_ctx->lim.gLimRspReqd) {
2588 mac_ctx->lim.gLimRspReqd = false;
2589 ret_code = eSIR_SME_INVALID_PARAMETERS;
2590 deauth_trigger = eLIM_HOST_DEAUTH;
2591 goto send_deauth;
2592 }
2593 return;
2594 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2595
2596 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2597 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002598 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002599 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2600 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2601 } else {
2602 deauth_trigger = eLIM_HOST_DEAUTH;
2603 reason_code = sme_deauth_req.reasonCode;
2604 }
2605
2606 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302607 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002608 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002609 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002610 if (mac_ctx->lim.gLimRspReqd) {
2611 mac_ctx->lim.gLimRspReqd = false;
2612 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2613 deauth_trigger = eLIM_HOST_DEAUTH;
2614 goto send_deauth;
2615 }
2616 return;
2617 }
2618
Anurag Chouhanc5548422016-02-24 18:33:27 +05302619 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002620 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002621
2622 mlm_deauth_req->reasonCode = reason_code;
2623 mlm_deauth_req->deauthTrigger = deauth_trigger;
2624
2625 /* Update PE session Id */
2626 mlm_deauth_req->sessionId = session_id;
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002627 lim_process_mlm_deauth_req(mac_ctx, (uint32_t *)mlm_deauth_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002628
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002629 return;
2630
2631send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002632 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2633 ret_code, deauth_trigger, 1,
2634 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002635}
2636
2637/**
2638 * __lim_process_sme_set_context_req()
2639 *
2640 * @mac_ctx: Pointer to Global MAC structure
2641 * @msg_buf: pointer to the SME message buffer
2642 *
2643 * This function is called to process SME_SETCONTEXT_REQ message
2644 * from HDD or upper layer application.
2645 *
2646 * Return: None
2647 */
2648
2649static void
2650__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2651{
2652 tpSirSmeSetContextReq set_context_req;
2653 tLimMlmSetKeysReq *mlm_set_key_req;
2654 tpPESession session_entry;
2655 uint8_t session_id; /* PE sessionID */
2656 uint8_t sme_session_id;
2657 uint16_t sme_transaction_id;
2658
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002659 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002660 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002661 return;
2662 }
2663
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302664 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002665 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002666 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002667 return;
2668 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302669 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002670 sizeof(struct sSirSmeSetContextReq));
2671 sme_session_id = set_context_req->sessionId;
2672 sme_transaction_id = set_context_req->transactionId;
2673
2674 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002675 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002676 goto end;
2677 }
2678
2679 if (set_context_req->keyMaterial.numKeys >
2680 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002681 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002682 set_context_req->keyMaterial.numKeys);
2683 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002684 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002685 eSIR_SME_INVALID_PARAMETERS, NULL,
2686 sme_session_id, sme_transaction_id);
2687 goto end;
2688 }
2689
2690 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002691 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002692 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002693 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002694 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002695 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002696 eSIR_SME_INVALID_PARAMETERS, NULL,
2697 sme_session_id, sme_transaction_id);
2698 goto end;
2699 }
2700#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2701 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2702 session_entry, 0, 0);
2703#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2704
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002705 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002706 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2707 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002708 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002709 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2710 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302711 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002712 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002713 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002714 goto end;
2715 }
2716 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2717 mlm_set_key_req->numKeys =
2718 set_context_req->keyMaterial.numKeys;
2719 if (mlm_set_key_req->numKeys >
2720 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002721 pe_err("no.of keys exceeded max num of default keys limit");
Jingxiang Ge4168a232018-01-03 18:47:15 +08002722 qdf_mem_free(mlm_set_key_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002723 goto end;
2724 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302725 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002726 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002727
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302728 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002729 (uint8_t *) &set_context_req->keyMaterial.key,
2730 sizeof(tSirKeys) *
2731 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2732 numKeys : 1));
2733
2734 mlm_set_key_req->sessionId = session_id;
2735 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002736 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002737 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002738
2739 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2740 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2741 LIM_IS_AP_ROLE(session_entry)) {
2742 if (set_context_req->keyMaterial.key[0].keyLength) {
2743 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002744
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002745 key_id =
2746 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302747 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002748 &session_entry->WEPKeyMaterial[key_id],
2749 (uint8_t *) &set_context_req->keyMaterial,
2750 sizeof(tSirKeyMaterial));
2751 } else {
2752 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002753
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002754 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2755 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302756 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002757 &mlm_set_key_req->key[i],
2758 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2759 sizeof(tSirKeys));
2760 }
2761 }
2762 }
2763 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2764 (uint32_t *) mlm_set_key_req);
2765 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002766 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002767 GET_LIM_SYSTEM_ROLE(session_entry),
2768 session_entry->limSmeState);
2769 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2770
2771 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002772 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002773 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2774 session_entry, sme_session_id,
2775 sme_transaction_id);
2776 }
2777end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302778 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002779 return;
2780}
2781
2782/**
2783 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2784 *
2785 * @mac_ctx: Pointer to Global MAC structure
2786 * @msg_buf: pointer to the SME message buffer
2787 *
2788 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2789 * from HDD or upper layer application.
2790 *
2791 * Return: None
2792 */
2793
Jeff Johnson801f1532016-10-07 07:54:50 -07002794static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2795 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002796{
2797 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2798 tpDphHashNode sta_ds = NULL;
2799 tpPESession session_entry = NULL;
2800 tSap_Event sap_event;
2801 tpWLAN_SAPEventCB sap_event_cb = NULL;
2802 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2803 uint8_t session_id = CSR_SESSION_ID_INVALID;
2804 uint8_t assoc_id = 0;
2805 uint8_t sta_cnt = 0;
2806
2807 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002808 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002809 return;
2810 }
2811
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302812 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002813 sizeof(struct sSirSmeGetAssocSTAsReq));
2814 /*
2815 * Get Associated stations from PE.
2816 * Find PE session Entry
2817 */
2818 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08002819 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002820 &session_id);
2821 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002822 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002823 goto lim_assoc_sta_end;
2824 }
2825
2826 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002827 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002828 session_entry->limSmeState,
2829 GET_LIM_SYSTEM_ROLE(session_entry));
2830 goto lim_assoc_sta_end;
2831 }
2832 /* Retrieve values obtained in the request message */
2833 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
2834 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2835
2836 if (NULL == assoc_sta_tmp)
2837 goto lim_assoc_sta_end;
2838 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
2839 assoc_id++) {
2840 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
2841 &session_entry->dph.dphHashTable);
2842 if (NULL == sta_ds)
2843 continue;
2844 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302845 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002846 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302847 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002848 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
2849 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
2850
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302851 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002852 (uint8_t *)&sta_ds->supportedRates,
2853 sizeof(tSirSupportedRates));
2854 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
2855 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
2856 assoc_sta_tmp->Support40Mhz =
2857 sta_ds->htDsssCckRate40MHzSupport;
2858
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002859 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002860 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002861 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002862 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002863 pe_debug("Association Id: %d Station Index: %d",
2864 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002865 assoc_sta_tmp++;
2866 sta_cnt++;
2867 }
2868 }
2869lim_assoc_sta_end:
2870 /*
2871 * Call hdd callback with sap event to send the list of
2872 * associated stations from PE
2873 */
2874 if (sap_event_cb != NULL) {
2875 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
2876 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302877 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002878 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
2879 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
2880 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2881 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
2882 }
2883}
2884
2885/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002886 * __lim_counter_measures()
2887 *
2888 * FUNCTION:
2889 * This function is called to "implement" MIC counter measure
2890 * and is *temporary* only
2891 *
2892 * LOGIC: on AP, disassoc all STA associated thru TKIP,
2893 * we don't do the proper STA disassoc sequence since the
Jeff Johnsond460e842018-05-11 13:25:53 -07002894 * BSS will be stopped anyway
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002895 *
2896 ***ASSUMPTIONS:
2897 *
2898 ***NOTE:
2899 *
2900 * @param pMac Pointer to Global MAC structure
2901 * @return None
2902 */
2903
2904static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
2905{
2906 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002907
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002908 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002909 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
2910 mac, psessionEntry, false);
2911};
2912
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302913/**
2914 * lim_send_stop_bss_failure_resp() -send failure delete bss resp to sme
2915 * @mac_ctx: mac ctx
2916 * @session: session pointer
2917 *
2918 * Return None
2919 */
2920static void lim_send_stop_bss_failure_resp(tpAniSirGlobal mac_ctx,
2921 tpPESession session)
2922{
2923 session->limSmeState = session->limPrevSmeState;
2924
2925 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE, session->peSessionId,
2926 session->limSmeState));
2927
2928 lim_send_sme_rsp(mac_ctx, eWNI_SME_STOP_BSS_RSP,
2929 eSIR_SME_STOP_BSS_FAILURE, session->smeSessionId,
2930 session->transactionId);
2931}
2932
2933void lim_delete_all_peers(tpPESession session)
2934{
2935 uint8_t i = 0;
2936 tpAniSirGlobal mac_ctx = session->mac_ctx;
2937 tpDphHashNode sta_ds = NULL;
2938 QDF_STATUS status;
2939
2940 for (i = 1; i < session->dph.dphHashTable.size; i++) {
2941 sta_ds = dph_get_hash_entry(mac_ctx, i,
2942 &session->dph.dphHashTable);
2943 if (!sta_ds)
2944 continue;
2945 status = lim_del_sta(mac_ctx, sta_ds, false, session);
2946 if (QDF_STATUS_SUCCESS == status) {
2947 lim_delete_dph_hash_entry(mac_ctx, sta_ds->staAddr,
2948 sta_ds->assocId, session);
2949 lim_release_peer_idx(mac_ctx, sta_ds->assocId, session);
2950 } else {
2951 pe_err("lim_del_sta failed with Status: %d", status);
2952 QDF_ASSERT(0);
2953 }
2954 }
Abhishek Singhcaa61852018-09-12 15:50:04 +05302955
2956#ifdef CONFIG_VDEV_SM
2957 status =
2958 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
2959 WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE,
2960 sizeof(*session), session);
2961 if (QDF_IS_STATUS_ERROR(status)) {
2962 pe_err("failed to post WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE for vdevid %d",
2963 session->smeSessionId);
2964 lim_send_stop_bss_failure_resp(mac_ctx, session);
2965 }
2966#endif
2967
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302968}
2969
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002970QDF_STATUS lim_sta_send_del_bss(tpPESession session)
2971{
2972 tpAniSirGlobal mac_ctx = session->mac_ctx;
2973 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2974 tpDphHashNode sta_ds = NULL;
2975
2976 sta_ds = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
2977 &session->dph.dphHashTable);
2978 if (!sta_ds) {
2979 pe_err("DPH Entry for STA is missing, failed to send delbss");
2980 goto end;
2981 }
2982
2983 status = lim_del_bss(mac_ctx, sta_ds, 0, session);
2984 if (QDF_IS_STATUS_ERROR(status))
2985 pe_err("delBss failed for bss %d", session->bssIdx);
2986
2987end:
2988 return status;
2989}
2990
Abhishek Singhcaa61852018-09-12 15:50:04 +05302991QDF_STATUS lim_send_vdev_stop(tpPESession session)
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302992{
2993 tpAniSirGlobal mac_ctx = session->mac_ctx;
2994 QDF_STATUS status;
2995
2996 status = lim_del_bss(mac_ctx, NULL, session->bssIdx, session);
2997
2998 if (QDF_IS_STATUS_ERROR(status)) {
2999 pe_err("delBss failed for bss %d", session->bssIdx);
3000 lim_send_stop_bss_failure_resp(mac_ctx, session);
3001 }
Abhishek Singhcaa61852018-09-12 15:50:04 +05303002
3003 return status;
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303004}
3005
3006/**
3007 * lim_delete_peers_and_send_vdev_stop() -delete peers and send vdev stop
3008 * @session: session pointer
3009 *
3010 * Return None
3011 */
Abhishek Singhcaa61852018-09-12 15:50:04 +05303012#ifdef CONFIG_VDEV_SM
3013static void lim_delete_peers_and_send_vdev_stop(tpPESession session)
3014{
3015 tpAniSirGlobal mac_ctx = session->mac_ctx;
3016 QDF_STATUS status;
3017
Abhishek Singhc5a54082018-09-12 16:08:03 +05303018 if (wlan_vdev_mlme_get_substate(session->vdev) ==
3019 WLAN_VDEV_SS_START_RESTART_PROGRESS)
3020 status =
3021 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3022 WLAN_VDEV_SM_EV_RESTART_REQ_FAIL,
Abhishek Singhcaa61852018-09-12 15:50:04 +05303023 sizeof(*session), session);
Abhishek Singhc5a54082018-09-12 16:08:03 +05303024 else
3025 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3026 WLAN_VDEV_SM_EV_DOWN,
3027 sizeof(*session),
3028 session);
Abhishek Singhcaa61852018-09-12 15:50:04 +05303029 if (QDF_IS_STATUS_ERROR(status)) {
3030 pe_err("failed to post WLAN_VDEV_SM_EV_DOWN for vdevid %d",
3031 session->smeSessionId);
3032 lim_send_stop_bss_failure_resp(mac_ctx, session);
3033 }
3034}
3035#else
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303036static void lim_delete_peers_and_send_vdev_stop(tpPESession session)
3037{
3038 lim_delete_all_peers(session);
3039 /* send a delBss to HAL and wait for a response */
3040 lim_send_vdev_stop(session);
3041}
Abhishek Singhcaa61852018-09-12 15:50:04 +05303042#endif
3043
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003044static void
3045__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3046{
3047 tSirSmeStopBssReq stopBssReq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003048 tLimSmeStates prevState;
3049 tpPESession psessionEntry;
3050 uint8_t smesessionId;
3051 uint8_t sessionId;
3052 uint16_t smetransactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003053
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303054 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055 smesessionId = stopBssReq.sessionId;
3056 smetransactionId = stopBssReq.transactionId;
3057
3058 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003059 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003060 /* Send Stop BSS response to host */
3061 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3062 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3063 smetransactionId);
3064 return;
3065 }
3066
3067 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003068 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003069 &sessionId);
3070 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003071 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003072 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3073 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3074 smetransactionId);
3075 return;
3076 }
3077#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3078 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3079 0, 0);
3080#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3081
3082 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3083 LIM_IS_STA_ROLE(psessionEntry)) {
3084 /**
3085 * Should not have received STOP_BSS_REQ in states
3086 * other than 'normal' state or on STA in Infrastructure
3087 * mode. Log error and return response to host.
3088 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003089 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003090 psessionEntry->limSmeState,
3091 GET_LIM_SYSTEM_ROLE(psessionEntry));
3092 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3093 /* / Send Stop BSS response to host */
3094 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3095 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3096 smetransactionId);
3097 return;
3098 }
3099
3100 if (LIM_IS_AP_ROLE(psessionEntry))
3101 lim_wpspbc_close(pMac, psessionEntry);
3102
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003103 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003104 stopBssReq.reasonCode);
3105
3106 prevState = psessionEntry->limSmeState;
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303107 psessionEntry->limPrevSmeState = prevState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003108
3109 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3110 MTRACE(mac_trace
3111 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3112 psessionEntry->limSmeState));
3113
3114 /* Update SME session Id and Transaction Id */
3115 psessionEntry->smeSessionId = smesessionId;
3116 psessionEntry->transactionId = smetransactionId;
3117
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003118 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3119 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3120 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003121 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003122
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003123 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3124 /* Send disassoc all stations associated thru TKIP */
3125 __lim_counter_measures(pMac, psessionEntry);
3126 else
3127 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003128 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3129 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130 }
3131
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003132 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3133 /* Free the buffer allocated in START_BSS_REQ */
3134 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3135 psessionEntry->addIeParams.probeRespDataLen = 0;
3136 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003137
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003138 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3139 psessionEntry->addIeParams.assocRespDataLen = 0;
3140 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003141
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003142 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3143 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3144 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003145
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003146 /*
3147 * lim_del_bss is also called as part of coalescing,
3148 * when we send DEL BSS followed by Add Bss msg.
3149 */
3150 pMac->lim.gLimIbssCoalescingHappened = false;
3151 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003152
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303153 lim_delete_peers_and_send_vdev_stop(psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003154
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003155}
3156
3157/**
3158 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3159 * @pMac: Global MAC context
3160 * @pMsg: Message from SME
3161 *
3162 * Wrapper for the function __lim_handle_sme_stop_bss_request
3163 * This message will be defered until softmac come out of
3164 * scan mode. Message should be handled even if we have
3165 * detected radar in the current operating channel.
3166 *
3167 * Return: true - If we consumed the buffer
3168 * false - If have defered the message.
3169 */
3170
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003171static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3172 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003173{
3174 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3175 /**
3176 * If message defered, buffer is not consumed yet.
3177 * So return false
3178 */
3179 return false;
3180 }
3181 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3182 return true;
3183} /*** end __lim_process_sme_stop_bss_req() ***/
3184
3185void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3186 uint32_t body, tpPESession psessionEntry)
3187{
3188
3189 (void)body;
3190 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3191 lim_ibss_delete(pMac, psessionEntry);
3192 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3193 lim_delete_pre_auth_list(pMac);
3194 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3195 psessionEntry->smeSessionId,
3196 psessionEntry->transactionId);
3197 return;
3198}
3199
3200/**
3201 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3202 *
3203 * @mac_ctx: pointer to mac context
3204 * @msg_type: message type
3205 * @msg_buf: pointer to the SME message buffer
3206 *
3207 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3208 * in BTAMP AP.
3209 *
3210 * Return: None
3211 */
3212
3213void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3214 uint32_t *msg_buf)
3215{
3216 tSirSmeAssocCnf assoc_cnf;
3217 tpDphHashNode sta_ds = NULL;
3218 tpPESession session_entry = NULL;
3219 uint8_t session_id;
3220 tpSirAssocReq assoc_req;
3221
3222 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003223 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003224 goto end;
3225 }
3226
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303227 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003228 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003229 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003230 goto end;
3231 }
3232
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003233 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003234 &session_id);
3235 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003236 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003237 goto end;
3238 }
3239
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003240 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003241 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3242 (session_entry->limSmeState !=
3243 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003244 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003245 msg_type, session_entry->limSmeState,
3246 GET_LIM_SYSTEM_ROLE(session_entry));
3247 goto end;
3248 }
3249 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3250 &session_entry->dph.dphHashTable);
3251 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003252 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303254 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003255
3256 /*
3257 * send a DISASSOC_IND message to WSM to make sure
3258 * the state in WSM and LIM is the same
3259 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003260 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003261 eSIR_SME_STA_NOT_ASSOCIATED,
3262 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3263 session_entry->smeSessionId,
3264 session_entry->transactionId,
3265 session_entry);
3266 goto end;
3267 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303268 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003269 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303270 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003271 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003272 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303273 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003274 goto end;
3275 }
3276
3277 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3278 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3279 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3280 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3281 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003282 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3283 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003284 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303285 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003286 goto end;
3287 }
3288 /*
3289 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3290 * has been received
3291 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003292 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003293 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3294 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3295
3296 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3297 /*
3298 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3299 * when it had received Assoc Request frame. Now, PE just needs
3300 * to send association rsp frame to the requesting BTAMP-STA.
3301 */
3302 sta_ds->mlmStaContext.mlmState =
3303 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003304 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003305 sta_ds->assocId);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003306 lim_send_assoc_rsp_mgmt_frame(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003307 sta_ds->assocId, sta_ds->staAddr,
3308 sta_ds->mlmStaContext.subType, sta_ds,
3309 session_entry);
3310 goto end;
3311 } else {
3312 /*
3313 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3314 * to be associated since the HAL sta entry is created for
3315 * denied STA we need to remove this HAL entry.
3316 * So to do that set updateContext to 1
3317 */
3318 if (!sta_ds->mlmStaContext.updateContext)
3319 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003320 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321 assoc_cnf.statusCode, sta_ds->assocId);
3322 lim_reject_association(mac_ctx, sta_ds->staAddr,
3323 sta_ds->mlmStaContext.subType,
3324 true, sta_ds->mlmStaContext.authType,
3325 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003326 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003327 session_entry);
3328 }
3329end:
3330 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3331 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3332 assoc_req = (tpSirAssocReq)
3333 session_entry->parsedAssocReq[sta_ds->assocId];
3334 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303335 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003336 assoc_req->assocReqFrame = NULL;
3337 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303338 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003339 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3340 }
3341}
3342
3343static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3344{
3345 tpDphHashNode pStaDs;
3346 tSirMacAddr peerMac;
3347 tpSirAddtsReq pSirAddts;
3348 uint32_t timeout;
3349 tpPESession psessionEntry;
3350 uint8_t sessionId; /* PE sessionId */
3351 uint8_t smesessionId;
3352 uint16_t smetransactionId;
3353
3354 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003355 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003356 return;
3357 }
3358
3359 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3360 &smetransactionId);
3361
3362 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3363
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003364 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3365 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003366 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003367 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003368 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303369 NULL, pSirAddts->req.tspec,
3370 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003371 return;
3372 }
3373#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3374 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3375 0);
3376#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3377
3378 /* if sta
3379 * - verify assoc state
3380 * - send addts request to ap
3381 * - wait for addts response from ap
3382 * if ap, just ignore with error log
3383 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003384 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3385 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3386 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003387
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003388 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003389 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303390 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003391 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003392
3393 pStaDs =
3394 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3395 &psessionEntry->dph.dphHashTable);
3396
3397 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003398 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303399 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003400 }
3401
3402 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3403 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003404 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303405 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003406 }
3407
3408 pSirAddts->req.wsmTspecPresent = 0;
3409 pSirAddts->req.wmeTspecPresent = 0;
3410 pSirAddts->req.lleTspecPresent = 0;
3411
3412 if ((pStaDs->wsmEnabled) &&
3413 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3414 SIR_MAC_ACCESSPOLICY_EDCA))
3415 pSirAddts->req.wsmTspecPresent = 1;
3416 else if (pStaDs->wmeEnabled)
3417 pSirAddts->req.wmeTspecPresent = 1;
3418 else if (pStaDs->lleEnabled)
3419 pSirAddts->req.lleTspecPresent = 1;
3420 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003421 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303422 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003423 }
3424
3425 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3426 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003427 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003428 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303429 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003430 }
3431
3432 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003433 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434 pMac->lim.gLimAddtsReq.req.dialogToken,
3435 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3436 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3437 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303438 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003439 }
3440
3441 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3442
3443 /* save the addts request */
3444 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303445 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003446 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3447
3448 /* ship out the message now */
3449 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3450 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303451 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003452 /* start a timer to wait for the response */
3453 if (pSirAddts->timeout)
3454 timeout = pSirAddts->timeout;
3455 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003456 QDF_STATUS_SUCCESS) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303457 pe_debug("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003458 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303459 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003460 }
3461
3462 timeout = SYS_MS_TO_TICKS(timeout);
3463 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3464 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003465 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303466 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003467 }
3468 pMac->lim.gLimAddtsRspTimerCount++;
3469 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3470 pMac->lim.gLimAddtsRspTimerCount) !=
3471 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003472 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303473 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003474 }
3475 MTRACE(mac_trace
3476 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3477 eLIM_ADDTS_RSP_TIMER));
3478
3479 /* add the sessionId to the timer object */
3480 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3481 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3482 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003483 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303484 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003485 }
3486 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303487
3488send_failure_addts_rsp:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003489 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303490 psessionEntry, pSirAddts->req.tspec,
3491 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003492}
3493
3494static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3495{
3496 tSirMacAddr peerMacAddr;
3497 uint8_t ac;
3498 tSirMacTSInfo *pTsinfo;
3499 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3500 tpDphHashNode pStaDs = NULL;
3501 tpPESession psessionEntry;
3502 uint8_t sessionId;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003503 uint32_t status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003504 uint8_t smesessionId;
3505 uint16_t smetransactionId;
3506
3507 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3508 &smetransactionId);
3509
3510 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003511 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003512 &sessionId);
3513 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003514 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003515 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003516 goto end;
3517 }
3518#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3519 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3520 0);
3521#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3522
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003523 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003524 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003525 pe_err("lim_validate_delts_req failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003526 status = QDF_STATUS_E_FAILURE;
3527 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_E_FAILURE, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003528 smesessionId, smetransactionId);
3529 return;
3530 }
3531
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003532 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3533 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003534 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3535
3536 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3537 pDeltsReq->req.wmeTspecPresent,
3538 &pDeltsReq->req.tsinfo,
3539 &pDeltsReq->req.tspec, psessionEntry);
3540
3541 pTsinfo =
3542 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3543 tsinfo : &pDeltsReq->req.tsinfo;
3544
3545 /* We've successfully send DELTS frame to AP. Update the
3546 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3547 * is no longer trigger enabled or delivery enabled
3548 */
3549 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3550 pTsinfo, CLEAR_UAPSD_MASK);
3551
3552 /* We're deleting the TSPEC, so this particular AC is no longer
3553 * admitted. PE needs to downgrade the EDCA
3554 * parameters(for the AC for which TS is being deleted) to the
3555 * next best AC for which ACM is not enabled, and send the
3556 * updated values to HAL.
3557 */
3558 ac = upToAc(pTsinfo->traffic.userPrio);
3559
3560 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3561 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3562 ~(1 << ac);
3563 } else if (pTsinfo->traffic.direction ==
3564 SIR_MAC_DIRECTION_DNLINK) {
3565 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3566 ~(1 << ac);
3567 } else if (pTsinfo->traffic.direction ==
3568 SIR_MAC_DIRECTION_BIDIR) {
3569 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3570 ~(1 << ac);
3571 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3572 ~(1 << ac);
3573 }
3574
3575 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3576 psessionEntry);
3577
3578 pStaDs =
3579 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3580 &psessionEntry->dph.dphHashTable);
3581 if (pStaDs != NULL) {
3582 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003583 pStaDs->bssId, false);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003584 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003585 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003586 pe_err("Self entry missing in Hash Table");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003587 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003588 }
3589#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003590 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003591#endif
3592
3593 /* send an sme response back */
3594end:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003595 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_SUCCESS, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003596 smesessionId, smetransactionId);
3597}
3598
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303599void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003600{
3601 /* fetch the sessionEntry based on the sessionId */
3602 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003603
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003604 psessionEntry = pe_find_session_by_session_id(pMac,
3605 pMac->lim.limTimers.gLimAddtsRspTimer.
3606 sessionId);
3607 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003608 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003609 return;
3610 }
3611
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003612 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003613 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003614 GET_LIM_SYSTEM_ROLE(psessionEntry));
3615 pMac->lim.gLimAddtsSent = false;
3616 return;
3617 }
3618
3619 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003620 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003621 return;
3622 }
3623
3624 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003625 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003626 pMac->lim.gLimAddtsRspTimerCount);
3627 return;
3628 }
3629 /* this a real response timeout */
3630 pMac->lim.gLimAddtsSent = false;
3631 pMac->lim.gLimAddtsRspTimerCount++;
3632
3633 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3634 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3635 psessionEntry->smeSessionId,
3636 psessionEntry->transactionId);
3637}
3638
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003639#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003640/**
3641 * __lim_process_sme_get_statistics_request()
3642 *
3643 ***FUNCTION:
3644 *
3645 *
3646 ***NOTE:
3647 *
3648 * @param pMac Pointer to Global MAC structure
3649 * @param *pMsgBuf A pointer to the SME message buffer
3650 * @return None
3651 */
3652static void
3653__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3654{
3655 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003656 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003657
3658 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3659
3660 msgQ.type = WMA_GET_STATISTICS_REQ;
3661
3662 msgQ.reserved = 0;
3663 msgQ.bodyptr = pMsgBuf;
3664 msgQ.bodyval = 0;
3665 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3666
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003667 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303668 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003669 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003670 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003671 return;
3672 }
3673
3674 return;
3675}
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003676#else
3677static void __lim_process_sme_get_statistics_request(
3678 struct sAniSirGlobal *mac_ctx, uint32_t *pMsgBuf) {}
3679#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003680
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003681#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003682/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003683 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003684 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003685 * @pMac: Pointer to Global MAC structure
3686 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003687 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003688 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003689 */
3690static void
3691__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3692{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003693 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003694
3695 msgQ.type = WMA_TSM_STATS_REQ;
3696 msgQ.reserved = 0;
3697 msgQ.bodyptr = pMsgBuf;
3698 msgQ.bodyval = 0;
3699 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3700
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003701 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303702 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003703 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003704 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003705 return;
3706 }
3707}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003708#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003709
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08003710static void lim_process_sme_set_addba_accept(tpAniSirGlobal mac_ctx,
3711 struct sme_addba_accept *msg)
3712{
3713 if (!msg) {
3714 pe_err("Msg Buffer is NULL");
3715 return;
3716 }
3717 if (!msg->addba_accept)
3718 mac_ctx->reject_addba_req = 1;
3719 else
3720 mac_ctx->reject_addba_req = 0;
3721}
3722
Arif Hussaineb8ba362018-03-07 19:15:13 -08003723static void lim_process_sme_update_edca_params(tpAniSirGlobal mac_ctx,
3724 uint32_t sme_session_id)
3725{
3726 tpPESession pe_session;
3727 tpDphHashNode sta_ds_ptr;
3728
3729 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3730 if (!pe_session) {
3731 pe_err("Session does not exist: sme_id %d", sme_session_id);
3732 return;
3733 }
3734 pe_session->gLimEdcaParamsActive[EDCA_AC_BE].no_ack =
3735 mac_ctx->no_ack_policy_cfg[EDCA_AC_BE];
3736 pe_session->gLimEdcaParamsActive[EDCA_AC_BK].no_ack =
3737 mac_ctx->no_ack_policy_cfg[EDCA_AC_BK];
3738 pe_session->gLimEdcaParamsActive[EDCA_AC_VI].no_ack =
3739 mac_ctx->no_ack_policy_cfg[EDCA_AC_VI];
3740 pe_session->gLimEdcaParamsActive[EDCA_AC_VO].no_ack =
3741 mac_ctx->no_ack_policy_cfg[EDCA_AC_VO];
3742 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3743 &pe_session->dph.dphHashTable);
3744 if (sta_ds_ptr)
3745 lim_send_edca_params(mac_ctx,
3746 pe_session->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003747 sta_ds_ptr->bssId, false);
Arif Hussaineb8ba362018-03-07 19:15:13 -08003748 else
3749 pe_err("Self entry missing in Hash Table");
3750}
3751
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07003752static void lim_process_sme_update_mu_edca_params(tpAniSirGlobal mac_ctx,
3753 uint32_t sme_session_id)
3754{
3755 tpPESession pe_session;
3756 tpDphHashNode sta_ds_ptr;
3757
3758 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3759 if (!pe_session) {
3760 pe_err("Session does not exist: sme_id %d", sme_session_id);
3761 return;
3762 }
3763 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3764 &pe_session->dph.dphHashTable);
3765 if (sta_ds_ptr)
3766 lim_send_edca_params(mac_ctx, mac_ctx->usr_mu_edca_params,
3767 sta_ds_ptr->bssId, true);
3768 else
3769 pe_err("Self entry missing in Hash Table");
3770}
3771
Naveen Rawat8029a402017-06-01 10:54:19 -07003772static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3773 struct update_config *msg)
3774{
3775 tpPESession pe_session;
3776
3777 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3778 if (msg == NULL) {
3779 pe_err("Buffer is Pointing to NULL");
3780 return;
3781 }
3782
3783 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3784 msg->sme_session_id);
3785 if (pe_session == NULL) {
3786 pe_warn("Session does not exist for given BSSID");
3787 return;
3788 }
3789
3790 switch (msg->capab) {
3791 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3792 pe_session->htConfig.ht_rx_ldpc = msg->value;
3793 break;
3794 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3795 pe_session->htConfig.ht_tx_stbc = msg->value;
3796 break;
3797 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3798 pe_session->htConfig.ht_rx_stbc = msg->value;
3799 break;
3800 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3801 pe_session->htConfig.ht_sgi20 = msg->value;
3802 break;
3803 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3804 pe_session->htConfig.ht_sgi40 = msg->value;
3805 break;
3806 }
3807
3808 if (LIM_IS_AP_ROLE(pe_session)) {
3809 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3810 lim_send_beacon_ind(mac_ctx, pe_session);
3811 }
3812}
3813
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003814void
3815lim_send_vdev_restart(tpAniSirGlobal pMac,
3816 tpPESession psessionEntry, uint8_t sessionId)
3817{
3818 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003819 struct scheduler_msg msgQ = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003820 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003821
3822 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003823 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003824 return;
3825 }
3826
3827 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303828 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003829 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003830 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003831 return;
3832 }
3833
3834 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3835 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003836 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003837
3838 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3839 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3840 msgQ.bodyval = 0;
3841
3842 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003843 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003844 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303845 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003846 }
3847}
3848
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303849/**
3850 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3851 * @mac_ctx: Pointer to Global MAC structure
3852 * @msg_buf: Pointer to SME message buffer
3853 *
3854 * Return: None
3855 */
3856static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3857 uint32_t *msg_buf)
3858{
3859 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003860 struct scheduler_msg wma_msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003861 QDF_STATUS status;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303862 tSirRoamOffloadScanReq *req_buffer;
3863 uint16_t local_ie_len;
3864 uint8_t *local_ie_buf;
3865
3866 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3867 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3868 req_buffer->sessionId);
3869
3870 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3871 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003872 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303873 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303874 return;
3875 }
3876
3877 local_ie_len = req_buffer->assoc_ie.length;
3878 /* Update ext cap IE if present */
3879 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003880 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3881 local_ie_buf, &local_ie_len)) {
3882 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003883 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3884 req_buffer->assoc_ie.length = local_ie_len;
3885 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3886 local_ie_buf, local_ie_len);
3887 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303888 }
3889 qdf_mem_free(local_ie_buf);
3890
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303891 if (pe_session)
3892 lim_update_fils_rik(pe_session, req_buffer);
3893
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303894 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3895 wma_msg.bodyptr = req_buffer;
3896
3897 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003898 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003899 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303900 qdf_mem_free(req_buffer);
3901 }
3902}
3903
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303904/*
3905 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3906 * @mac_ctx: Pointer to global mac context
3907 * @session: Pointer to PE session
3908 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3909 * 1 - Disable broadcast SSID
3910 *
3911 * Return: None
3912 */
3913static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3914 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003915{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003916 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003917 session->ssidHidden, ssid_hidden);
3918
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003919 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303920 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003921 } else {
3922 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05303923 return;
3924 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003925
Abhishek Singh6c681f42018-09-12 15:52:36 +05303926#ifdef CONFIG_VDEV_SM
3927 ap_mlme_set_hidden_ssid_restart_in_progress(session->vdev, true);
3928 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3929 WLAN_VDEV_SM_EV_FW_VDEV_RESTART,
3930 sizeof(*session), session);
3931#else
3932
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003933 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303934 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Abhishek Singh6c681f42018-09-12 15:52:36 +05303935#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003936
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003937 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303938}
3939
3940/**
3941 * __lim_process_sme_session_update - process SME session update msg
3942 *
3943 * @mac_ctx: Pointer to global mac context
3944 * @msg_buf: Pointer to the received message buffer
3945 *
3946 * Return: None
3947 */
3948static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
3949 uint32_t *msg_buf)
3950{
3951 struct sir_update_session_param *msg;
3952 tpPESession session;
3953
3954 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003955 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303956 return;
3957 }
3958
3959 msg = (struct sir_update_session_param *) msg_buf;
3960
3961 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
3962 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003963 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303964 msg->session_id);
3965 return;
3966 }
3967
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003968 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303969 msg->param_type, msg->param_val);
3970 switch (msg->param_type) {
3971 case SIR_PARAM_SSID_HIDDEN:
3972 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
3973 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303974 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
3975 session->ignore_assoc_disallowed = msg->param_val;
3976 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303977 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003978 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303979 break;
3980 }
3981}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003982
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003983/*
3984 Update the beacon Interval dynamically if beaconInterval is different in MCC
3985 */
3986static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3987{
3988 tpSirChangeBIParams pChangeBIParams;
3989 tpPESession psessionEntry;
3990 uint8_t sessionId = 0;
3991 tUpdateBeaconParams beaconParams;
3992
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003993 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003994
3995 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003996 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003997 return;
3998 }
3999
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304000 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004001 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4002
4003 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004004 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004005 &sessionId);
4006 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004007 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004008 return;
4009 }
4010
4011 /*Update sessionEntry Beacon Interval */
4012 if (psessionEntry->beaconParams.beaconInterval !=
4013 pChangeBIParams->beaconInterval) {
4014 psessionEntry->beaconParams.beaconInterval =
4015 pChangeBIParams->beaconInterval;
4016 }
4017
4018 /*Update sch beaconInterval */
4019 if (pMac->sch.schObject.gSchBeaconInterval !=
4020 pChangeBIParams->beaconInterval) {
4021 pMac->sch.schObject.gSchBeaconInterval =
4022 pChangeBIParams->beaconInterval;
4023
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004024 pe_debug("LIM send update BeaconInterval Indication: %d",
4025 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004026
4027 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4028 /* Update beacon */
4029 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4030
4031 beaconParams.bssIdx = psessionEntry->bssIdx;
4032 /* Set change in beacon Interval */
4033 beaconParams.beaconInterval =
4034 pChangeBIParams->beaconInterval;
4035 beaconParams.paramChangeBitmap =
4036 PARAM_BCN_INTERVAL_CHANGED;
4037 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4038 }
4039 }
4040
4041 return;
4042} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4043
4044#ifdef QCA_HT_2040_COEX
4045static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4046 uint32_t *pMsgBuf)
4047{
4048 tpSirSetHT2040Mode pSetHT2040Mode;
4049 tpPESession psessionEntry;
4050 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004051 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004052 tUpdateVHTOpMode *pHtOpMode = NULL;
4053 uint16_t staId = 0;
4054 tpDphHashNode pStaDs = NULL;
4055
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004056 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004057 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004058 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004059 return;
4060 }
4061
4062 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4063
4064 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004065 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004066 &sessionId);
4067 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004068 pe_debug("Session does not exist for given BSSID");
4069 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004070 return;
4071 }
4072
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004073 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004074 pSetHT2040Mode->cbMode);
4075 /*Update sessionEntry HT related fields */
4076 switch (pSetHT2040Mode->cbMode) {
4077 case PHY_SINGLE_CHANNEL_CENTERED:
4078 psessionEntry->htSecondaryChannelOffset =
4079 PHY_SINGLE_CHANNEL_CENTERED;
4080 psessionEntry->htRecommendedTxWidthSet = 0;
4081 if (pSetHT2040Mode->obssEnabled)
4082 psessionEntry->htSupportedChannelWidthSet
4083 = eHT_CHANNEL_WIDTH_40MHZ;
4084 else
4085 psessionEntry->htSupportedChannelWidthSet
4086 = eHT_CHANNEL_WIDTH_20MHZ;
4087 break;
4088 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4089 psessionEntry->htSecondaryChannelOffset =
4090 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4091 psessionEntry->htRecommendedTxWidthSet = 1;
4092 break;
4093 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4094 psessionEntry->htSecondaryChannelOffset =
4095 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4096 psessionEntry->htRecommendedTxWidthSet = 1;
4097 break;
4098 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004099 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004100 return;
4101 }
4102
4103 /* Update beacon */
4104 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4105 lim_send_beacon_ind(pMac, psessionEntry);
4106
4107 /* update OP Mode for each associated peer */
4108 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4109 pStaDs = dph_get_hash_entry(pMac, staId,
4110 &psessionEntry->dph.dphHashTable);
4111 if (NULL == pStaDs)
4112 continue;
4113
4114 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304115 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004116 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004117 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004118 return;
4119 }
4120 pHtOpMode->opMode =
4121 (psessionEntry->htSecondaryChannelOffset ==
4122 PHY_SINGLE_CHANNEL_CENTERED) ?
4123 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4124 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304125 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004126 sizeof(tSirMacAddr));
4127 pHtOpMode->smesessionId = sessionId;
4128
4129 msg.type = WMA_UPDATE_OP_MODE;
4130 msg.reserved = 0;
4131 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004132 if (!QDF_IS_STATUS_SUCCESS
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05304133 (scheduler_post_message(QDF_MODULE_ID_PE,
4134 QDF_MODULE_ID_WMA,
4135 QDF_MODULE_ID_WMA,
4136 &msg))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004137 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304138 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004139 return;
4140 }
Jeff Johnson47d75242018-05-12 15:58:53 -07004141 pe_debug("Notified FW about OP mode: %d for staId=%d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004142 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004143
4144 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004145 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004146 }
4147
4148 return;
4149}
4150#endif
4151
4152/* -------------------------------------------------------------------- */
4153/**
4154 * __lim_process_report_message
4155 *
4156 * FUNCTION: Processes the next received Radio Resource Management message
4157 *
4158 * LOGIC:
4159 *
4160 * ASSUMPTIONS:
4161 *
4162 * NOTE:
4163 *
4164 * @param None
4165 * @return None
4166 */
4167
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004168static void __lim_process_report_message(tpAniSirGlobal pMac,
4169 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004170{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004171 switch (pMsg->type) {
4172 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4173 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4174 break;
4175 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004176 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004177 break;
4178 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004179 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004180 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004181}
4182
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004183/* -------------------------------------------------------------------- */
4184/**
4185 * lim_send_set_max_tx_power_req
4186 *
4187 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4188 *
4189 * LOGIC:
4190 *
4191 * ASSUMPTIONS:
4192 *
4193 * NOTE:
4194 *
4195 * @param txPower txPower to be set.
4196 * @param pSessionEntry session entry.
4197 * @return None
4198 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004199QDF_STATUS
Amar Singhala297bfa2015-10-15 15:07:29 -07004200lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201 tpPESession pSessionEntry)
4202{
4203 tpMaxTxPowerParams pMaxTxParams = NULL;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004204 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004205 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004206
4207 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004208 pe_err("Invalid parameters");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004209 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004210 }
4211
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304212 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004213 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004214 pe_err("Unable to allocate memory for pMaxTxParams");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004215 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004216
4217 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004218 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304219 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304220 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304221 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004222 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304223 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004224
4225 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4226 msgQ.bodyptr = pMaxTxParams;
4227 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004228 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004229 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4230 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004231 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004232 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304233 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004234 }
4235 return retCode;
4236}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004237
4238/**
4239 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4240 *
4241 * @mac_ctx: Pointer to Global MAC structure
4242 * @msg_buf: pointer to the SME message buffer
4243 *
4244 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4245 * from SME. It Register this information within PE.
4246 *
4247 * Return: None
4248 */
4249static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4250 uint32_t *msg_buf)
4251{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304252 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004253 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4254 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4255 struct mgmt_frm_reg_info *next = NULL;
4256 bool match = false;
4257
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004258 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004259 sme_req->registerFrame, sme_req->frameType,
4260 sme_req->matchLen);
4261 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304262 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304263 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4264 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304265 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004266
4267 while (lim_mgmt_regn != NULL) {
4268 if (lim_mgmt_regn->frameType != sme_req->frameType)
4269 goto skip_match;
4270 if (sme_req->matchLen) {
4271 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304272 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004273 sme_req->matchData,
4274 lim_mgmt_regn->matchLen))) {
4275 /* found match! */
4276 match = true;
4277 break;
4278 }
4279 } else {
4280 /* found match! */
4281 match = true;
4282 break;
4283 }
4284skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304285 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304286 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004287 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304288 (qdf_list_node_t *)lim_mgmt_regn,
4289 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304290 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004291 lim_mgmt_regn = next;
4292 next = NULL;
4293 }
4294 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304295 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004296 if (QDF_STATUS_SUCCESS ==
4297 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004298 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004299 (qdf_list_node_t *)lim_mgmt_regn))
4300 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304301 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004302 }
4303
4304 if (sme_req->registerFrame) {
4305 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304306 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004307 sme_req->matchLen);
4308 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004309 lim_mgmt_regn->frameType = sme_req->frameType;
4310 lim_mgmt_regn->matchLen = sme_req->matchLen;
4311 lim_mgmt_regn->sessionId = sme_req->sessionId;
4312 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304313 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004314 sme_req->matchData,
4315 sme_req->matchLen);
4316 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304317 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004318 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304319 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004320 gLimMgmtFrameRegistratinQueue,
4321 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304322 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004323 &mac_ctx->lim.lim_frame_register_lock);
4324 }
4325 }
4326 return;
4327}
4328
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004329static void
4330__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4331{
4332 tpSirResetAPCapsChange pResetCapsChange;
4333 tpPESession psessionEntry;
4334 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004335
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004336 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004337 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004338 return;
4339 }
4340
4341 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4342 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004343 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4344 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004345 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004346 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004347 return;
4348 }
4349
4350 psessionEntry->limSentCapsChangeNtf = false;
4351 return;
4352}
4353
4354/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304355 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4356 * indication callback in PE.
4357 * @mac_ptr: Mac pointer
4358 * @msg_buf: Msg pointer containing the callback
4359 *
4360 * This function is used save the Management frame
4361 * indication callback in PE.
4362 *
4363 * Return: None
4364 */
4365static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4366 uint32_t *msg_buf)
4367{
4368 struct sir_sme_mgmt_frame_cb_req *sme_req =
4369 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4370
4371 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004372 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304373 return;
4374 }
4375 if (sme_req->callback)
4376 mac_ctx->mgmt_frame_ind_cb =
4377 (sir_mgmt_frame_ind_callback)sme_req->callback;
4378 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004379 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304380}
4381
4382/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304383 *__lim_process_send_disassoc_frame: function processes disassoc frame
4384 * @mac_ctx: pointer to mac context
4385 * @msg_buf: message buffer
4386 *
4387 * function processes disassoc request received from SME
4388 *
4389 * return: none
4390 */
4391static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4392 uint32_t *msg_buf)
4393{
4394 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004395 QDF_STATUS status;
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304396 tpPESession session_entry = NULL;
4397 uint8_t sme_session_id;
4398 uint16_t sme_trans_id;
4399
4400 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004401 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304402 return;
4403 }
4404
4405 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4406 &sme_trans_id);
4407
4408 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4409 &sme_send_disassoc_frame_req,
4410 (uint8_t *)msg_buf);
4411
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004412 if ((QDF_STATUS_E_FAILURE == status) ||
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304413 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4414 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004415 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304416 return;
4417 }
4418
4419 session_entry = pe_find_session_by_sme_session_id(
4420 mac_ctx, sme_session_id);
4421 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004422 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304423 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4424 return;
4425 }
4426
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004427 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 +05304428 sme_send_disassoc_frame_req.msg_type,
4429 sme_send_disassoc_frame_req.length,
4430 sme_send_disassoc_frame_req.session_id,
4431 sme_send_disassoc_frame_req.trans_id,
4432 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4433 sme_send_disassoc_frame_req.reason,
4434 sme_send_disassoc_frame_req.wait_for_ack);
4435
4436 lim_send_disassoc_mgmt_frame(mac_ctx,
4437 sme_send_disassoc_frame_req.reason,
4438 sme_send_disassoc_frame_req.peer_mac,
4439 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4440}
4441
4442/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004443 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4444 * @mac_ctx: Pointer to Global MAC structure
4445 * @pdev_id: pdev id to set the IE.
4446 * @nss: Nss values to prepare the HT IE.
4447 *
4448 * Prepares the HT IE with self capabilities for different
4449 * Nss values and sends the set HT IE req to FW.
4450 *
4451 * Return: None
4452 */
4453static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4454 uint8_t nss)
4455{
4456 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004457 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004458 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004459 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004460 tHtCaps *p_ht_cap;
4461 int i;
4462
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004463 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004464 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4465 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004466 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004467 return;
4468 }
4469 ie_params->nss = i;
4470 ie_params->pdev_id = pdev_id;
4471 ie_params->ie_type = DOT11_HT_IE;
4472 /* 2 for IE len and EID */
4473 ie_params->ie_len = 2 + sizeof(tHtCaps);
4474 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4475 if (NULL == ie_params->ie_ptr) {
4476 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004477 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004478 return;
4479 }
4480 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4481 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4482 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4483 ie_params->ie_len);
4484
4485 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004486 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4487 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004488 if (NULL == p_ie) {
4489 qdf_mem_free(ie_params->ie_ptr);
4490 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004491 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004492 return;
4493 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004494 p_ht_cap = (tHtCaps *)&p_ie[2];
4495 p_ht_cap->supportedMCSSet[1] = 0;
4496 p_ht_cap->txSTBC = 0;
4497 }
4498
4499 msg.type = WMA_SET_PDEV_IE_REQ;
4500 msg.bodyptr = ie_params;
4501 msg.bodyval = 0;
4502
4503 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004504 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004505 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004506 qdf_mem_free(ie_params->ie_ptr);
4507 qdf_mem_free(ie_params);
4508 return;
4509 }
4510 }
4511}
4512
4513/**
4514 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4515 * @mac_ctx: Pointer to Global MAC structure
4516 * @pdev_id: pdev id to set the IE.
4517 * @nss: Nss values to prepare the VHT IE.
4518 *
4519 * Prepares the VHT IE with self capabilities for different
4520 * Nss values and sends the set VHT IE req to FW.
4521 *
4522 * Return: None
4523 */
4524static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4525 uint8_t nss)
4526{
4527 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004528 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004529 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004530 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004531 tSirMacVHTCapabilityInfo *vht_cap;
4532 int i;
4533 tSirVhtMcsInfo *vht_mcs;
4534
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004535 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004536 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4537 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004538 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004539 return;
4540 }
4541 ie_params->nss = i;
4542 ie_params->pdev_id = pdev_id;
4543 ie_params->ie_type = DOT11_VHT_IE;
4544 /* 2 for IE len and EID */
4545 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4546 sizeof(tSirVhtMcsInfo);
4547 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4548 if (NULL == ie_params->ie_ptr) {
4549 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004550 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004551 return;
4552 }
4553 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4554 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4555 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4556 ie_params->ie_len);
4557
4558 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004559 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4560 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004561 if (NULL == p_ie) {
4562 qdf_mem_free(ie_params->ie_ptr);
4563 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004564 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004565 return;
4566 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004567 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4568 vht_cap->txSTBC = 0;
4569 vht_mcs =
4570 (tSirVhtMcsInfo *)&p_ie[2 +
4571 sizeof(tSirMacVHTCapabilityInfo)];
4572 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4573 vht_mcs->rxHighest =
4574 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4575 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4576 vht_mcs->txHighest =
4577 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4578 }
4579 msg.type = WMA_SET_PDEV_IE_REQ;
4580 msg.bodyptr = ie_params;
4581 msg.bodyval = 0;
4582
4583 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004584 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004585 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004586 qdf_mem_free(ie_params->ie_ptr);
4587 qdf_mem_free(ie_params);
4588 return;
4589 }
4590 }
4591}
4592
4593/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004594 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4595 * @mac_ctx: Pointer to Global MAC structure
4596 * @msg_buf: Pointer to the SME message buffer
4597 *
4598 * This function is called by limProcessMessageQueue(). This function sets the
4599 * VDEV IEs to the FW.
4600 *
4601 * Return: None
4602 */
4603static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4604 uint32_t *msg_buf)
4605{
4606 struct sir_set_vdev_ies_per_band *p_msg =
4607 (struct sir_set_vdev_ies_per_band *)msg_buf;
4608
4609 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004610 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004611 return;
4612 }
4613
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004614 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004615 p_msg->vdev_id);
4616 /* intentionally using NULL here so that self capabilty are sent */
4617 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4618 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004619 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004620}
4621
4622/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004623 * lim_process_set_pdev_IEs() - process the set pdev IE req
4624 * @mac_ctx: Pointer to Global MAC structure
4625 * @msg_buf: Pointer to the SME message buffer
4626 *
4627 * This function is called by limProcessMessageQueue(). This
4628 * function sets the PDEV IEs to the FW.
4629 *
4630 * Return: None
4631 */
4632static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4633{
4634 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4635
4636 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4637
4638 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004639 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004640 return;
4641 }
4642
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004643 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004644 ht_vht_cfg->nss);
4645 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4646
4647 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4648 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4649 ht_vht_cfg->nss);
4650}
4651
4652/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304653 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4654 *
4655 * access policy
4656 * @mac_ctx: pointer to mac context
4657 * @msg: message buffer
4658 *
4659 * function processes vendor IE and access policy from SME and updates PE
4660 *
4661 * session entry
4662 *
4663 * return: none
4664*/
4665static void lim_process_sme_update_access_policy_vendor_ie(
4666 tpAniSirGlobal mac_ctx,
4667 uint32_t *msg)
4668{
4669 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4670 struct sPESession *pe_session_entry;
Pragaspathi Thilagaraj9b7a1162018-05-07 16:28:13 +05304671 uint16_t num_bytes;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304672
4673 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004674 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304675 return;
4676 }
4677 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4678 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4679 update_vendor_ie->sme_session_id);
4680
4681 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004682 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304683 update_vendor_ie->sme_session_id);
4684 return;
4685 }
4686 if (pe_session_entry->access_policy_vendor_ie)
4687 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4688
4689 num_bytes = update_vendor_ie->ie[1] + 2;
4690 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4691
4692 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004693 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304694 return;
4695 }
4696 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4697 &update_vendor_ie->ie[0], num_bytes);
4698
4699 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4700}
4701
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004702#ifdef CONFIG_VDEV_SM
4703QDF_STATUS lim_sta_mlme_vdev_disconnect_bss(struct vdev_mlme_obj *vdev_mlme,
4704 uint16_t data_len, void *data)
4705{
4706 tpAniSirGlobal mac_ctx;
4707 struct scheduler_msg *msg = (struct scheduler_msg *)data;
4708
4709 mac_ctx = cds_get_context(QDF_MODULE_ID_PE);
4710 if (!mac_ctx) {
4711 pe_err("mac_ctx is NULL");
4712 if (data)
4713 qdf_mem_free(data);
4714 return QDF_STATUS_E_INVAL;
4715 }
4716 pe_debug("VDEV Manager disconnect bss callback type:(%d)", msg->type);
4717
4718 switch (msg->type) {
4719 case eWNI_SME_DEAUTH_REQ:
4720 __lim_process_sme_deauth_req(mac_ctx,
4721 (uint32_t *)msg->bodyptr);
4722 break;
4723 case eWNI_SME_DISASSOC_CNF:
4724 case eWNI_SME_DEAUTH_CNF:
4725 __lim_process_sme_disassoc_cnf(mac_ctx,
4726 (uint32_t *)msg->bodyptr);
4727 break;
4728 case eWNI_SME_DISASSOC_REQ:
4729 __lim_process_sme_disassoc_req(mac_ctx,
4730 (uint32_t *)msg->bodyptr);
4731 break;
4732 default:
4733 pe_debug("Wrong message type received %d", msg->type);
4734 }
4735 return QDF_STATUS_SUCCESS;
4736}
4737#endif
4738
4739static void lim_process_sme_disassoc_cnf(tpAniSirGlobal mac_ctx,
4740 struct scheduler_msg *msg)
4741{
4742#ifdef CONFIG_VDEV_SM
4743 tSirSmeDisassocCnf sme_disassoc_cnf;
4744 tpPESession session;
4745 uint8_t session_id;
4746 QDF_STATUS status;
4747
4748 qdf_mem_copy(&sme_disassoc_cnf, msg->bodyptr,
4749 sizeof(struct sSirSmeDisassocCnf));
4750
4751 session = pe_find_session_by_bssid(mac_ctx,
4752 sme_disassoc_cnf.bssid.bytes,
4753 &session_id);
4754
4755 if (LIM_IS_STA_ROLE(session)) {
4756 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4757 WLAN_VDEV_SM_EV_DOWN,
4758 sizeof(*msg),
4759 msg);
4760 } else {
4761 __lim_process_sme_disassoc_cnf(mac_ctx,
4762 (uint32_t *)msg->bodyptr);
4763 }
4764#else
4765 __lim_process_sme_disassoc_cnf(mac_ctx, (uint32_t *)msg->bodyptr);
4766#endif
4767}
4768
4769static void lim_process_sme_disassoc_req(tpAniSirGlobal mac_ctx,
4770 struct scheduler_msg *msg)
4771{
4772#ifdef CONFIG_VDEV_SM
4773 tSirSmeDisassocReq disassoc_req;
4774 tpPESession session;
4775 uint8_t session_id;
4776 QDF_STATUS status;
4777
4778 qdf_mem_copy(&disassoc_req, msg->bodyptr, sizeof(tSirSmeDisassocReq));
4779
4780 session = pe_find_session_by_bssid(mac_ctx,
4781 disassoc_req.bssid.bytes,
4782 &session_id);
4783 if (LIM_IS_STA_ROLE(session)) {
4784 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4785 WLAN_VDEV_SM_EV_DOWN,
4786 sizeof(*msg),
4787 msg);
4788 } else {
4789 __lim_process_sme_disassoc_req(mac_ctx,
4790 (uint32_t *)msg->bodyptr);
4791 }
4792#else
4793 __lim_process_sme_disassoc_req(mac_ctx, (uint32_t *)msg->bodyptr);
4794#endif
4795}
4796
4797static void lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
4798 struct scheduler_msg *msg)
4799{
4800#ifdef CONFIG_VDEV_SM
4801 tSirSmeDeauthReq sme_deauth_req;
4802 tpPESession session;
4803 uint8_t session_id;
4804 QDF_STATUS status;
4805
4806 qdf_mem_copy(&sme_deauth_req, msg->bodyptr, sizeof(tSirSmeDeauthReq));
4807
4808 session = pe_find_session_by_bssid(mac_ctx,
4809 sme_deauth_req.bssid.bytes,
4810 &session_id);
4811 if (LIM_IS_STA_ROLE(session)) {
4812 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4813 WLAN_VDEV_SM_EV_DOWN,
4814 sizeof(*msg),
4815 msg);
4816 } else {
4817 __lim_process_sme_deauth_req(mac_ctx,
4818 (uint32_t *)msg->bodyptr);
4819 }
4820#else
4821 __lim_process_sme_deauth_req(mac_ctx, (uint32_t *)msg->bodyptr);
4822#endif
4823}
4824
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304825/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004826 * lim_process_sme_req_messages()
4827 *
4828 ***FUNCTION:
4829 * This function is called by limProcessMessageQueue(). This
4830 * function processes SME request messages from HDD or upper layer
4831 * application.
4832 *
4833 ***LOGIC:
4834 *
4835 ***ASSUMPTIONS:
4836 *
4837 ***NOTE:
4838 *
4839 * @param pMac Pointer to Global MAC structure
4840 * @param msgType Indicates the SME message type
4841 * @param *pMsgBuf A pointer to the SME message buffer
4842 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4843 * false - if pMsgBuf is not to be freed.
4844 */
4845
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004846bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4847 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004848{
Jeff Johnson33142e62018-05-06 17:58:36 -07004849 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 -08004850 uint32_t *pMsgBuf = pMsg->bodyptr;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004851
4852 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004853 lim_msg_str(pMsg->type), pMsg->type,
4854 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4855 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004856
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004857 /* If no insert NOA required then execute the code below */
4858
4859 switch (pMsg->type) {
4860 case eWNI_SME_SYS_READY_IND:
4861 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4862 break;
4863
4864 case eWNI_SME_START_BSS_REQ:
4865 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4866 break;
4867
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004868 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4869 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4870 break;
4871 case eWNI_SME_JOIN_REQ:
4872 __lim_process_sme_join_req(pMac, pMsgBuf);
4873 break;
4874
4875 case eWNI_SME_REASSOC_REQ:
4876 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4877 break;
4878
4879 case eWNI_SME_DISASSOC_REQ:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004880 lim_process_sme_disassoc_req(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004881 break;
4882
4883 case eWNI_SME_DISASSOC_CNF:
4884 case eWNI_SME_DEAUTH_CNF:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004885 lim_process_sme_disassoc_cnf(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004886 break;
4887
4888 case eWNI_SME_DEAUTH_REQ:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004889 lim_process_sme_deauth_req(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004890 break;
4891
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304892 case eWNI_SME_SEND_DISASSOC_FRAME:
4893 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4894 break;
4895
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004896 case eWNI_SME_SETCONTEXT_REQ:
4897 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4898 break;
4899
4900 case eWNI_SME_STOP_BSS_REQ:
4901 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4902 break;
4903
4904 case eWNI_SME_ASSOC_CNF:
4905 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004906 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004907 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4908 pMsgBuf);
4909 break;
4910
4911 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004912 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004913 __lim_process_sme_addts_req(pMac, pMsgBuf);
4914 break;
4915
4916 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004917 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004918 __lim_process_sme_delts_req(pMac, pMsgBuf);
4919 break;
4920
4921 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004922 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004923 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4924 break;
4925
4926 case eWNI_SME_GET_STATISTICS_REQ:
4927 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4928 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4929 bufConsumed = false;
4930 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004931#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004932 case eWNI_SME_GET_TSM_STATS_REQ:
4933 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4934 bufConsumed = false;
4935 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004936#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004937 case eWNI_SME_GET_ASSOC_STAS_REQ:
4938 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4939 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304940 case eWNI_SME_SESSION_UPDATE_PARAM:
4941 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004942 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304943 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4944 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4945 bufConsumed = false;
4946 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004947 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4948 /* Update the beaconInterval */
4949 __lim_process_sme_change_bi(pMac, pMsgBuf);
4950 break;
4951
4952#ifdef QCA_HT_2040_COEX
4953 case eWNI_SME_SET_HT_2040_MODE:
4954 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4955 break;
4956#endif
4957
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004958 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4959 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4960 __lim_process_report_message(pMac, pMsg);
4961 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004962
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004963 case eWNI_SME_FT_PRE_AUTH_REQ:
4964 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4965 break;
4966 case eWNI_SME_FT_UPDATE_KEY:
4967 lim_process_ft_update_key(pMac, pMsgBuf);
4968 break;
4969
4970 case eWNI_SME_FT_AGGR_QOS_REQ:
4971 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4972 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004973
4974 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4975 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4976 break;
4977#ifdef FEATURE_WLAN_TDLS
4978 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4979 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4980 break;
4981 case eWNI_SME_TDLS_ADD_STA_REQ:
4982 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4983 break;
4984 case eWNI_SME_TDLS_DEL_STA_REQ:
4985 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4986 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004987#endif
4988 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4989 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4990 break;
4991
4992 case eWNI_SME_CHANNEL_CHANGE_REQ:
4993 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4994 break;
4995
4996 case eWNI_SME_START_BEACON_REQ:
4997 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4998 break;
4999
5000 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5001 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5002 break;
5003
5004 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5005 lim_process_update_add_ies(pMac, pMsgBuf);
5006 break;
5007
5008 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5009 lim_process_modify_add_ies(pMac, pMsgBuf);
5010 break;
5011 case eWNI_SME_SET_HW_MODE_REQ:
5012 lim_process_set_hw_mode(pMac, pMsgBuf);
5013 break;
5014 case eWNI_SME_NSS_UPDATE_REQ:
5015 lim_process_nss_update_request(pMac, pMsgBuf);
5016 break;
5017 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5018 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5019 break;
5020 case eWNI_SME_SET_IE_REQ:
5021 lim_process_set_ie_req(pMac, pMsgBuf);
5022 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305023 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5024 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5025 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305026 case eWNI_SME_EXT_CHANGE_CHANNEL:
5027 lim_process_ext_change_channel(pMac, pMsgBuf);
5028 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005029 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5030 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5031 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005032 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5033 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005034 break;
5035 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5036 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5037 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305038 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5039 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5040 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07005041 case eWNI_SME_UPDATE_CONFIG:
5042 lim_process_sme_update_config(pMac,
5043 (struct update_config *)pMsgBuf);
5044 break;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08005045 case eWNI_SME_SET_ADDBA_ACCEPT:
5046 lim_process_sme_set_addba_accept(pMac,
5047 (struct sme_addba_accept *)pMsgBuf);
5048 break;
Arif Hussaineb8ba362018-03-07 19:15:13 -08005049 case eWNI_SME_UPDATE_EDCA_PROFILE:
5050 lim_process_sme_update_edca_params(pMac, pMsg->bodyval);
5051 break;
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07005052 case WNI_SME_UPDATE_MU_EDCA_PARAMS:
5053 lim_process_sme_update_mu_edca_params(pMac, pMsg->bodyval);
5054 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005055 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305056 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005057 pMsg->bodyptr = NULL;
5058 break;
5059 } /* switch (msgType) */
5060
5061 return bufConsumed;
5062} /*** end lim_process_sme_req_messages() ***/
5063
5064/**
5065 * lim_process_sme_start_beacon_req()
5066 *
5067 ***FUNCTION:
5068 * This function is called by limProcessMessageQueue(). This
5069 * function processes SME request messages from HDD or upper layer
5070 * application.
5071 *
5072 ***LOGIC:
5073 *
5074 ***ASSUMPTIONS:
5075 *
5076 ***NOTE:
5077 *
5078 * @param pMac Pointer to Global MAC structure
5079 * @param msgType Indicates the SME message type
5080 * @param *pMsgBuf A pointer to the SME message buffer
5081 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5082 * false - if pMsgBuf is not to be freed.
5083 */
5084static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5085{
5086 tpSirStartBeaconIndication pBeaconStartInd;
5087 tpPESession psessionEntry;
5088 uint8_t sessionId; /* PE sessionID */
5089
5090 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005091 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005092 return;
5093 }
5094
5095 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5096 psessionEntry = pe_find_session_by_bssid(pMac,
5097 pBeaconStartInd->bssid,
5098 &sessionId);
5099 if (psessionEntry == NULL) {
5100 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005101 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005102 return;
5103 }
5104
5105 if (pBeaconStartInd->beaconStartStatus == true) {
5106 /*
5107 * Currently this Indication comes from SAP
5108 * to start Beacon Tx on a DFS channel
5109 * since beaconing has to be done on DFS
5110 * channel only after CAC WAIT is completed.
5111 * On a DFS Channel LIM does not start beacon
5112 * Tx right after the WMA_ADD_BSS_RSP.
5113 */
5114 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05305115 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005116 FL("Start Beacon with ssid %s Ch %d"),
5117 psessionEntry->ssId.ssId,
5118 psessionEntry->currentOperChannel);
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05305119 lim_send_beacon(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08005120 lim_enable_obss_detection_config(pMac, psessionEntry);
Arif Hussain05fb4872018-01-03 16:02:55 -08005121 lim_send_obss_color_collision_cfg(pMac, psessionEntry,
5122 OBSS_COLOR_COLLISION_DETECTION);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005123 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005124 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005125 return;
5126 }
5127}
5128
5129/**
5130 * lim_process_sme_channel_change_request() - process sme ch change req
5131 *
5132 * @mac_ctx: Pointer to Global MAC structure
5133 * @msg_buf: pointer to the SME message buffer
5134 *
5135 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5136 *
5137 * Return: None
5138 */
5139static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5140 uint32_t *msg_buf)
5141{
5142 tpSirChanChangeRequest ch_change_req;
5143 tpPESession session_entry;
5144 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005145 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005146 uint32_t val = 0;
5147
5148 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005149 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005150 return;
5151 }
5152 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5153
5154 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5155 ch_change_req->targetChannel);
5156
5157 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5158 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005159 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005160 return;
5161 }
5162
5163 session_entry = pe_find_session_by_bssid(mac_ctx,
5164 ch_change_req->bssid, &session_id);
5165 if (session_entry == NULL) {
5166 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005167 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005168 return;
5169 }
5170
Manjunathappa Prakash34fda792018-02-07 18:23:42 -08005171 if ((session_entry->currentOperChannel ==
5172 ch_change_req->targetChannel) &&
5173 (session_entry->ch_width == ch_change_req->ch_width)) {
5174 pe_err("Target channel and mode is same as current channel and mode channel %d and mode %d",
5175 session_entry->currentOperChannel, session_entry->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005176 return;
5177 }
5178
5179 if (LIM_IS_AP_ROLE(session_entry))
5180 session_entry->channelChangeReasonCode =
5181 LIM_SWITCH_CHANNEL_SAP_DFS;
5182 else
5183 session_entry->channelChangeReasonCode =
5184 LIM_SWITCH_CHANNEL_OPERATION;
5185
Bala Venkateshb39ed152017-12-26 19:35:27 +05305186 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d, nw_type %d, dot11mode %d",
5187 session_entry->currentOperChannel,
5188 ch_change_req->targetChannel,
5189 ch_change_req->ch_width,
5190 ch_change_req->nw_type,
5191 ch_change_req->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005192
5193 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005194 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005195 session_entry->ch_center_freq_seg0 =
5196 ch_change_req->center_freq_seg_0;
5197 session_entry->ch_center_freq_seg1 =
5198 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005199 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005200 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005201 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005202 session_entry->htRecommendedTxWidthSet =
5203 session_entry->htSupportedChannelWidthSet;
5204 session_entry->currentOperChannel =
5205 ch_change_req->targetChannel;
5206 session_entry->limRFBand =
5207 lim_get_rf_band(session_entry->currentOperChannel);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305208 session_entry->cac_duration_ms = ch_change_req->cac_duration_ms;
5209 session_entry->dfs_regdomain = ch_change_req->dfs_regdomain;
5210 session_entry->maxTxPower = max_tx_pwr;
Vignesh Viswanathan153ae932018-04-11 14:24:13 +05305211
5212 /* Update the global beacon filter */
5213 lim_update_bcn_probe_filter(mac_ctx, session_entry);
5214
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005215 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08005216 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005217 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005218 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005219 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005220 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005221 }
5222
5223 session_entry->lim11hEnable = val;
5224 session_entry->dot11mode = ch_change_req->dot11mode;
Bala Venkateshb39ed152017-12-26 19:35:27 +05305225 session_entry->nwType = ch_change_req->nw_type;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305226 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005227 &ch_change_req->operational_rateset,
5228 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305229 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005230 &ch_change_req->extended_rateset,
5231 sizeof(session_entry->extRateSet));
Abhishek Singh20a8e442018-09-12 15:50:44 +05305232
5233#ifdef CONFIG_VDEV_SM
Abhishek Singha063f1c2018-09-19 11:37:51 +05305234 mlme_set_chan_switch_in_progress(session_entry->vdev, true);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305235 if (wlan_vdev_mlme_get_state(session_entry->vdev) ==
5236 WLAN_VDEV_S_DFS_CAC_WAIT)
5237 wlan_vdev_mlme_sm_deliver_evt(session_entry->vdev,
5238 WLAN_VDEV_SM_EV_RADAR_DETECTED,
5239 sizeof(*session_entry),
5240 session_entry);
5241 else
5242 wlan_vdev_mlme_sm_deliver_evt(session_entry->vdev,
5243 WLAN_VDEV_SM_EV_CSA_COMPLETE,
5244 sizeof(*session_entry),
5245 session_entry);
5246
5247
5248#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005249 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5250 session_entry->ch_center_freq_seg0,
5251 session_entry->ch_center_freq_seg1,
5252 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07005253 max_tx_pwr, session_entry->peSessionId,
5254 ch_change_req->cac_duration_ms,
5255 ch_change_req->dfs_regdomain);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305256#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005257}
5258
5259/******************************************************************************
5260* lim_start_bss_update_add_ie_buffer()
5261*
5262***FUNCTION:
5263* This function checks the src buffer and its length and then malloc for
5264* dst buffer update the same
5265*
5266***LOGIC:
5267*
5268***ASSUMPTIONS:
5269*
5270***NOTE:
5271*
5272* @param pMac Pointer to Global MAC structure
5273* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5274* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5275* @param *pSrcData_buff A pointer of uint8_t src buffer
5276* @param srcDataLen src buffer length
5277******************************************************************************/
5278
5279static void
5280lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5281 uint8_t **pDstData_buff,
5282 uint16_t *pDstDataLen,
5283 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5284{
5285
5286 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5287 *pDstDataLen = srcDataLen;
5288
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305289 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005290
5291 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005292 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005293 return;
5294 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305295 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005296 } else {
5297 *pDstData_buff = NULL;
5298 *pDstDataLen = 0;
5299 }
5300}
5301
5302/******************************************************************************
5303* lim_update_add_ie_buffer()
5304*
5305***FUNCTION:
5306* This function checks the src buffer and length if src buffer length more
5307* than dst buffer length then free the dst buffer and malloc for the new src
5308* length, and update the dst buffer and length. But if dst buffer is bigger
5309* than src buffer length then it just update the dst buffer and length
5310*
5311***LOGIC:
5312*
5313***ASSUMPTIONS:
5314*
5315***NOTE:
5316*
5317* @param pMac Pointer to Global MAC structure
5318* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5319* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5320* @param *pSrcData_buff A pointer of uint8_t src buffer
5321* @param srcDataLen src buffer length
5322******************************************************************************/
5323
5324static void
5325lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5326 uint8_t **pDstData_buff,
5327 uint16_t *pDstDataLen,
5328 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5329{
5330
5331 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005332 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005333 return;
5334 }
5335
5336 if (srcDataLen > *pDstDataLen) {
5337 *pDstDataLen = srcDataLen;
5338 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305339 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005340 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305341 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005342
5343 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005344 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005345 *pDstDataLen = 0;
5346 return;
5347 }
5348 }
5349
5350 /* copy the content of buffer into dst buffer
5351 */
5352 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305353 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005354
5355}
5356
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005357/**
5358 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5359 * @pMac : Pointer to Global MAC structure
5360 * @pDstData_buff : A pointer to pointer of dst buffer
5361 * @pDstDataLen : A pointer to pointer of dst buffer length
5362 * @pModifyIE : A pointer to tSirModifyIE
5363 *
5364 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5365 *
5366 * Return:
5367 * True or false depending upon whether IE is updated or not
5368 */
5369static bool
5370lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5371 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5372{
Hong Shi1553d692016-09-28 12:16:19 +08005373 int32_t oui_length;
5374 uint8_t *ibss_ie = NULL;
5375 uint8_t *vendor_ie;
5376#define MAC_VENDOR_OUI "\x00\x16\x32"
5377#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005378
5379 ibss_ie = pModifyIE->pIEBuffer;
5380 oui_length = pModifyIE->oui_length;
5381
5382 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005383 pe_err("Invalid set IBSS vendor IE command length %d",
5384 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005385 return false;
5386 }
5387
Hong Shi1553d692016-09-28 12:16:19 +08005388 /*
5389 * Why replace only beacon OUI data here:
5390 * 1. other ie (such as wpa) shall not be overwritten here.
5391 * 2. per spec, beacon oui ie might be set twice and original one
5392 * shall be updated.
5393 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005394 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005395 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5396 if (vendor_ie) {
5397 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5398 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5399 pModifyIE->ieBufferlength);
5400 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005401 uint16_t new_length;
5402 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005403
Naveen Rawat668dee32017-09-29 14:39:40 -07005404 /*
5405 * check for uint16 overflow before using sum of two numbers as
5406 * length of size to malloc
5407 */
5408 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5409 pe_err("U16 overflow due to %d + %d",
5410 pModifyIE->ieBufferlength, *pDstDataLen);
5411 return false;
5412 }
5413
5414 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5415 new_ptr = qdf_mem_malloc(new_length);
Hong Shi1553d692016-09-28 12:16:19 +08005416 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005417 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005418 return false;
5419 }
5420 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5421 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5422 pModifyIE->ieBufferlength);
5423 qdf_mem_free(*pDstData_buff);
5424 *pDstDataLen = new_length;
5425 *pDstData_buff = new_ptr;
5426 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005427 return true;
5428}
5429
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005430/*
5431* lim_process_modify_add_ies() - process modify additional IE req.
5432*
5433* @mac_ctx: Pointer to Global MAC structure
5434* @msg_buf: pointer to the SME message buffer
5435*
5436* This function update the PE buffers for additional IEs.
5437*
5438* Return: None
5439*/
5440static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5441 uint32_t *msg_buf)
5442{
5443 tpSirModifyIEsInd modify_add_ies;
5444 tpPESession session_entry;
5445 uint8_t session_id;
5446 bool ret = false;
5447 tSirAddIeParams *add_ie_params;
5448
5449 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005450 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005451 return;
5452 }
5453
5454 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5455 /* Incoming message has smeSession, use BSSID to find PE session */
5456 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005457 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005458
5459 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005460 pe_err("Session not found for given bssid"
5461 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005462 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005463 goto end;
5464 }
5465 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5466 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5467 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005468 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005469 modify_add_ies->modifyIE.pIEBuffer,
5470 modify_add_ies->modifyIE.ieBufferlength,
5471 modify_add_ies->modifyIE.ieID,
5472 modify_add_ies->modifyIE.ieIDLen,
5473 modify_add_ies->updateType);
5474 goto end;
5475 }
5476 add_ie_params = &session_entry->addIeParams;
5477 switch (modify_add_ies->updateType) {
5478 case eUPDATE_IE_PROBE_RESP:
5479 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005480 if (LIM_IS_IBSS_ROLE(session_entry)) {
5481 lim_update_ibss_prop_add_ies(mac_ctx,
5482 &add_ie_params->probeRespData_buff,
5483 &add_ie_params->probeRespDataLen,
5484 &modify_add_ies->modifyIE);
5485 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005486 break;
5487 case eUPDATE_IE_ASSOC_RESP:
5488 /* assoc resp IE */
5489 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305490 QDF_TRACE(QDF_MODULE_ID_PE,
5491 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005492 "assoc resp add ie not present %d"),
5493 add_ie_params->assocRespDataLen);
5494 }
5495 /* search through the buffer and modify the IE */
5496 break;
5497 case eUPDATE_IE_PROBE_BCN:
5498 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005499 if (LIM_IS_IBSS_ROLE(session_entry)) {
5500 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5501 &add_ie_params->probeRespBCNData_buff,
5502 &add_ie_params->probeRespBCNDataLen,
5503 &modify_add_ies->modifyIE);
5504 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005505 if (ret == true && modify_add_ies->modifyIE.notify) {
5506 lim_handle_param_update(mac_ctx,
5507 modify_add_ies->updateType);
5508 }
5509 break;
5510 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005511 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005512 modify_add_ies->updateType);
5513 break;
5514 }
5515end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305516 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005517 modify_add_ies->modifyIE.pIEBuffer = NULL;
5518}
5519
5520/*
5521* lim_process_update_add_ies() - process additional IE update req
5522*
5523* @mac_ctx: Pointer to Global MAC structure
5524* @msg_buf: pointer to the SME message buffer
5525*
5526* This function update the PE buffers for additional IEs.
5527*
5528* Return: None
5529*/
5530static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5531 uint32_t *msg_buf)
5532{
5533 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5534 uint8_t session_id;
5535 tpPESession session_entry;
5536 tSirAddIeParams *addn_ie;
5537 uint16_t new_length = 0;
5538 uint8_t *new_ptr = NULL;
5539 tSirUpdateIE *update_ie;
5540
5541 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005542 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005543 return;
5544 }
5545 update_ie = &update_add_ies->updateIE;
5546 /* incoming message has smeSession, use BSSID to find PE session */
5547 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005548 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005549
5550 if (NULL == session_entry) {
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05305551 pe_debug("Session not found for given bssid"
5552 MAC_ADDRESS_STR,
5553 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005554 goto end;
5555 }
5556 addn_ie = &session_entry->addIeParams;
5557 /* if len is 0, upper layer requested freeing of buffer */
5558 if (0 == update_ie->ieBufferlength) {
5559 switch (update_add_ies->updateType) {
5560 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305561 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005562 addn_ie->probeRespData_buff = NULL;
5563 addn_ie->probeRespDataLen = 0;
5564 break;
5565 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305566 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005567 addn_ie->assocRespData_buff = NULL;
5568 addn_ie->assocRespDataLen = 0;
5569 break;
5570 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305571 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005572 addn_ie->probeRespBCNData_buff = NULL;
5573 addn_ie->probeRespBCNDataLen = 0;
5574
5575 if (update_ie->notify)
5576 lim_handle_param_update(mac_ctx,
5577 update_add_ies->updateType);
5578 break;
5579 default:
5580 break;
5581 }
5582 return;
5583 }
5584 switch (update_add_ies->updateType) {
5585 case eUPDATE_IE_PROBE_RESP:
5586 if (update_ie->append) {
5587 /*
5588 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005589 * with combined length.
5590 * Multiple back to back append commands
5591 * can lead to a huge length.So, check
5592 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005593 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005594 if (addn_ie->probeRespDataLen >
5595 (USHRT_MAX - update_ie->ieBufferlength)) {
5596 pe_err("IE Length overflow, curr:%d, new:%d",
5597 addn_ie->probeRespDataLen,
5598 update_ie->ieBufferlength);
5599 goto end;
5600 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005601 new_length = update_ie->ieBufferlength +
5602 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305603 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005604 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005605 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005606 goto end;
5607 }
5608 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305609 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005610 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305611 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005612 update_ie->pAdditionIEBuffer,
5613 update_ie->ieBufferlength);
5614 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305615 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005616 /* adjust length accordingly */
5617 addn_ie->probeRespDataLen = new_length;
5618 /* save refernece of local buffer in PE session */
5619 addn_ie->probeRespData_buff = new_ptr;
5620 goto end;
5621 }
5622 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5623 &addn_ie->probeRespDataLen,
5624 update_ie->pAdditionIEBuffer,
5625 update_ie->ieBufferlength);
5626 break;
5627 case eUPDATE_IE_ASSOC_RESP:
5628 /* assoc resp IE */
5629 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5630 &addn_ie->assocRespDataLen,
5631 update_ie->pAdditionIEBuffer,
5632 update_ie->ieBufferlength);
5633 break;
5634 case eUPDATE_IE_PROBE_BCN:
5635 /* probe resp Bcn IE */
5636 lim_update_add_ie_buffer(mac_ctx,
5637 &addn_ie->probeRespBCNData_buff,
5638 &addn_ie->probeRespBCNDataLen,
5639 update_ie->pAdditionIEBuffer,
5640 update_ie->ieBufferlength);
5641 if (update_ie->notify)
5642 lim_handle_param_update(mac_ctx,
5643 update_add_ies->updateType);
5644 break;
5645 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005646 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005647 break;
5648 }
5649end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305650 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005651 update_ie->pAdditionIEBuffer = NULL;
5652}
5653
5654/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305655 * send_extended_chan_switch_action_frame()- function to send ECSA
5656 * action frame for each sta connected to SAP/GO and AP in case of
5657 * STA .
5658 * @mac_ctx: pointer to global mac structure
5659 * @new_channel: new channel to switch to.
5660 * @ch_bandwidth: BW of channel to calculate op_class
5661 * @session_entry: pe session
5662 *
5663 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5664 *
5665 * Return: void
5666 */
5667
5668static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5669 uint16_t new_channel, uint8_t ch_bandwidth,
5670 tpPESession session_entry)
5671{
5672 uint16_t op_class;
5673 uint8_t switch_mode = 0, i;
5674 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005675 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305676
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005677 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305678 mac_ctx->scan.countryCodeCurrent,
5679 new_channel,
5680 ch_bandwidth);
5681
5682 if (LIM_IS_AP_ROLE(session_entry) &&
5683 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005684 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305685
gaoleze2920bd2017-03-21 17:38:42 +08005686 switch_count = session_entry->gLimChannelSwitch.switchCount;
5687
Abhishek Singh518323d2015-10-19 17:42:01 +05305688 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005689 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305690 psta =
5691 session_entry->dph.dphHashTable.pDphNodeArray + i;
5692 if (psta && psta->added)
5693 lim_send_extended_chan_switch_action_frame(
5694 mac_ctx,
5695 psta->staAddr,
5696 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005697 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305698 }
5699 } else if (LIM_IS_STA_ROLE(session_entry)) {
5700 lim_send_extended_chan_switch_action_frame(mac_ctx,
5701 session_entry->bssId,
5702 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005703 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305704 }
5705
5706}
5707
gaolez76d2a162017-03-21 19:23:58 +08005708void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5709 uint16_t new_channel,
5710 uint8_t ch_bandwidth,
5711 tpPESession session_entry)
5712{
5713 uint16_t op_class;
5714 uint8_t switch_mode = 0, i;
5715 uint8_t switch_count;
5716 tpDphHashNode psta;
5717 tpDphHashNode dph_node_array_ptr;
5718
5719 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5720
5721 op_class = wlan_reg_dmn_get_opclass_from_channel(
5722 mac_ctx->scan.countryCodeCurrent,
5723 new_channel, ch_bandwidth);
5724
5725 if (LIM_IS_AP_ROLE(session_entry) &&
5726 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5727 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5728
5729 switch_count = session_entry->gLimChannelSwitch.switchCount;
5730
5731 if (LIM_IS_AP_ROLE(session_entry)) {
5732 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5733 psta = dph_node_array_ptr + i;
5734 if (!(psta && psta->added))
5735 continue;
5736 if (session_entry->lim_non_ecsa_cap_num == 0)
5737 lim_send_extended_chan_switch_action_frame
5738 (mac_ctx, psta->staAddr, switch_mode,
5739 op_class, new_channel, switch_count,
5740 session_entry);
5741 else
5742 lim_send_channel_switch_mgmt_frame
5743 (mac_ctx, psta->staAddr, switch_mode,
5744 new_channel, switch_count,
5745 session_entry);
5746 }
5747 } else if (LIM_IS_STA_ROLE(session_entry)) {
5748 lim_send_extended_chan_switch_action_frame
5749 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5750 new_channel, switch_count, session_entry);
5751 }
5752}
5753
5754/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005755 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5756 *
5757 * @mac_ctx: Pointer to Global MAC structure
5758 * @msg_buf: pointer to the SME message buffer
5759 *
5760 * This function processes SME request messages from HDD or upper layer
5761 * application.
5762 *
5763 * Return: None
5764 */
5765static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5766 uint32_t *msg_buf)
5767{
5768 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5769 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005770 uint8_t session_id;
5771 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005772 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005773
5774 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005775 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005776 return;
5777 }
5778
5779 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5780 session_entry = pe_find_session_by_bssid(mac_ctx,
5781 dfs_csa_ie_req->bssid, &session_id);
5782 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005783 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005784 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5785 return;
5786 }
5787
5788 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005789 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005790 GET_LIM_SYSTEM_ROLE(session_entry));
5791 return;
5792 }
5793
5794 /* target channel */
5795 session_entry->gLimChannelSwitch.primaryChannel =
5796 dfs_csa_ie_req->targetChannel;
5797
5798 /* Channel switch announcement needs to be included in beacon */
5799 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005800 session_entry->gLimChannelSwitch.switchCount =
5801 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005802 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005803 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305804 session_entry->gLimChannelSwitch.sec_ch_offset =
5805 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005806 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005807 session_entry->gLimChannelSwitch.switchMode =
5808 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005809
5810 /*
5811 * Validate if SAP is operating HT or VHT mode and set the Channel
5812 * Switch Wrapper element with the Wide Band Switch subelement.
5813 */
5814 if (true != session_entry->vhtCapability)
5815 goto skip_vht;
5816
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005817 /* Now encode the Wider Ch BW element depending on the ch width */
5818 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005819 switch (dfs_csa_ie_req->ch_params.ch_width) {
5820 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005821 /*
5822 * Wide channel BW sublement in channel wrapper element is not
5823 * required in case of 20 Mhz operation. Currently It is set
5824 * only set in case of 40/80 Mhz Operation.
5825 */
5826 session_entry->dfsIncludeChanWrapperIe = false;
5827 wider_bw_ch_switch->newChanWidth =
5828 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5829 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005830 case CH_WIDTH_40MHZ:
5831 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005832 wider_bw_ch_switch->newChanWidth =
5833 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5834 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005835 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005836 session_entry->dfsIncludeChanWrapperIe = true;
5837 wider_bw_ch_switch->newChanWidth =
5838 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5839 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005840 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005841 session_entry->dfsIncludeChanWrapperIe = true;
5842 wider_bw_ch_switch->newChanWidth =
5843 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5844 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005845 case CH_WIDTH_80P80MHZ:
5846 session_entry->dfsIncludeChanWrapperIe = true;
5847 wider_bw_ch_switch->newChanWidth =
5848 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005849 /*
5850 * This is not applicable for 20/40/80 Mhz.
5851 * Only used when we support 80+80 Mhz operation.
5852 * In case of 80+80 Mhz, this parameter indicates
5853 * center channel frequency index of 80 Mhz channel of
5854 * frequency segment 1.
5855 */
5856 wider_bw_ch_switch->newCenterChanFreq1 =
5857 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005858 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005859 default:
5860 session_entry->dfsIncludeChanWrapperIe = false;
5861 /*
5862 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5863 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5864 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005865 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005866 break;
5867 }
5868 /* Fetch the center channel based on the channel width */
5869 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005870 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005871skip_vht:
5872 /* Send CSA IE request from here */
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05305873 lim_send_dfs_chan_sw_ie_update(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305874
5875 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5876 ch_offset = BW80;
5877 else
5878 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5879
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005880 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305881 session_entry->gLimChannelSwitch.switchCount,
5882 session_entry->gLimChannelSwitch.primaryChannel,
5883 session_entry->gLimChannelSwitch.ch_width,
5884 session_entry->dfsIncludeChanWrapperIe,
5885 ch_offset);
5886
gaolez76d2a162017-03-21 19:23:58 +08005887 /* Send ECSA/CSA Action frame after updating the beacon */
5888 if (CHAN_HOP_ALL_BANDS_ENABLE)
5889 lim_send_chan_switch_action_frame(mac_ctx,
5890 session_entry->gLimChannelSwitch.primaryChannel,
5891 ch_offset, session_entry);
5892 else
5893 send_extended_chan_switch_action_frame(mac_ctx,
5894 session_entry->gLimChannelSwitch.primaryChannel,
5895 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005896}
5897
5898/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305899 * lim_process_ext_change_channel()- function to send ECSA
5900 * action frame for STA/CLI .
5901 * @mac_ctx: pointer to global mac structure
5902 * @msg: params from sme for new channel.
5903 *
5904 * This function is called to send ECSA frame for STA/CLI.
5905 *
5906 * Return: void
5907 */
5908
5909static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5910 uint32_t *msg)
5911{
5912 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5913 (struct sir_sme_ext_cng_chan_req *) msg;
5914 tpPESession session_entry = NULL;
5915
5916 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005917 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305918 return;
5919 }
5920 session_entry =
5921 pe_find_session_by_sme_session_id(mac_ctx,
5922 ext_chng_channel->session_id);
5923 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005924 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305925 ext_chng_channel->session_id);
5926 return;
5927 }
5928 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005929 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305930 return;
5931 }
5932 send_extended_chan_switch_action_frame(mac_ctx,
5933 ext_chng_channel->new_channel,
5934 0, session_entry);
5935}
5936
5937/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005938 * lim_process_nss_update_request() - process sme nss update req
5939 *
5940 * @mac_ctx: Pointer to Global MAC structure
5941 * @msg_buf: pointer to the SME message buffer
5942 *
5943 * This function processes SME request messages from HDD or upper layer
5944 * application.
5945 *
5946 * Return: None
5947 */
5948static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5949 uint32_t *msg_buf)
5950{
5951 struct sir_nss_update_request *nss_update_req_ptr;
5952 tpPESession session_entry = NULL;
5953
5954 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005955 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005956 return;
5957 }
5958
5959 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305960 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005961 nss_update_req_ptr->vdev_id);
5962 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005963 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005964 nss_update_req_ptr->vdev_id);
5965 return;
5966 }
5967
5968 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005969 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005970 GET_LIM_SYSTEM_ROLE(session_entry));
5971 return;
5972 }
5973
5974 /* populate nss field in the beacon */
5975 session_entry->gLimOperatingMode.present = 1;
5976 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05305977 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
5978
5979 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
5980 (session_entry->ch_width > CH_WIDTH_80MHZ))
5981 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
5982
5983 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
5984
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005985 /* Send nss update request from here */
5986 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005987 QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005988 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005989 return;
5990 }
5991
5992 lim_send_beacon_ind(mac_ctx, session_entry);
5993}
5994
5995/**
5996 * lim_process_set_ie_req() - process sme set IE request
5997 *
5998 * @mac_ctx: Pointer to Global MAC structure
5999 * @msg_buf: pointer to the SME message buffer
6000 *
6001 * This function processes SME request messages from HDD or upper layer
6002 * application.
6003 *
6004 * Return: None
6005 */
6006static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6007{
6008 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306009 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006010
6011 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006012 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006013 return;
6014 }
6015
6016 msg = (struct send_extcap_ie *)msg_buf;
6017 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306018 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006019 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006020
6021}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006022
6023#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Arif Hussain05fb4872018-01-03 16:02:55 -08006024
6025/**
6026 * obss_color_collision_process_color_disable() - Disable bss color
6027 * @mac_ctx: Pointer to Global MAC structure
6028 * @session: pointer to session
6029 *
6030 * This function will disbale bss color.
6031 *
6032 * Return: None
6033 */
6034static void obss_color_collision_process_color_disable(tpAniSirGlobal mac_ctx,
6035 tpPESession session)
6036{
6037 tUpdateBeaconParams beacon_params;
6038
6039 if (!session) {
6040 pe_err("Invalid session");
6041 return;
6042 }
6043
6044 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6045 pe_err("Invalid SystemRole %d",
6046 GET_LIM_SYSTEM_ROLE(session));
6047 return;
6048 }
6049
6050 if (session->bss_color_changing == 1) {
6051 pe_warn("%d: color change in progress", session->smeSessionId);
6052 /* Continue color collision detection */
6053 lim_send_obss_color_collision_cfg(mac_ctx, session,
6054 OBSS_COLOR_COLLISION_DETECTION);
6055 return;
6056 }
6057
6058 if (session->he_op.bss_col_disabled == 1) {
6059 pe_warn("%d: bss color already disabled",
6060 session->smeSessionId);
6061 /* Continue free color detection */
6062 lim_send_obss_color_collision_cfg(mac_ctx, session,
6063 OBSS_COLOR_FREE_SLOT_AVAILABLE);
6064 return;
6065 }
6066
6067 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
6068 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
6069 session->he_op.bss_col_disabled = 1;
Arif Hussain05fb4872018-01-03 16:02:55 -08006070 beacon_params.bss_color_disabled = 1;
Arif Hussain2f2d3512018-03-06 12:37:03 -08006071 beacon_params.bss_color = session->he_op.bss_color;
Arif Hussain05fb4872018-01-03 16:02:55 -08006072
6073 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006074 QDF_STATUS_SUCCESS) {
Arif Hussain05fb4872018-01-03 16:02:55 -08006075 pe_err("Unable to set op mode IE in beacon");
6076 return;
6077 }
6078
6079 lim_send_beacon_params(mac_ctx, &beacon_params, session);
6080 lim_send_obss_color_collision_cfg(mac_ctx, session,
6081 OBSS_COLOR_FREE_SLOT_AVAILABLE);
6082}
6083
6084/**
6085 * obss_color_collision_process_color_change() - Process bss color change
6086 * @mac_ctx: Pointer to Global MAC structure
6087 * @session: pointer to session
6088 * @obss_color_info: obss color collision/free slot indication info
6089 *
6090 * This function selects new color ib case of bss color collision.
6091 *
6092 * Return: None
6093 */
6094static void obss_color_collision_process_color_change(tpAniSirGlobal mac_ctx,
6095 tpPESession session,
6096 struct wmi_obss_color_collision_info *obss_color_info)
6097{
6098 int i, num_bss_color = 0;
6099 uint32_t bss_color_bitmap;
6100 uint8_t bss_color_index_array[MAX_BSS_COLOR_VALUE];
6101 uint32_t rand_byte = 0;
6102 struct sir_set_he_bss_color he_bss_color;
6103 bool is_color_collision = false;
6104
6105
6106 if (session->bss_color_changing == 1) {
6107 pe_err("%d: color change in progress", session->smeSessionId);
6108 return;
6109 }
6110
6111 if (!session->he_op.bss_col_disabled) {
6112 if (session->he_op.bss_color < 32)
6113 is_color_collision = (obss_color_info->
6114 obss_color_bitmap_bit0to31 >>
6115 session->he_op.bss_color) & 0x01;
6116 else
6117 is_color_collision = (obss_color_info->
6118 obss_color_bitmap_bit32to63 >>
6119 (session->he_op.bss_color -
Arif Hussain9e8c5612018-04-12 16:35:48 -07006120 32)) & 0x01;
Arif Hussain05fb4872018-01-03 16:02:55 -08006121 if (!is_color_collision) {
6122 pe_err("%d: color collision not found, curr_color: %d",
6123 session->smeSessionId,
6124 session->he_op.bss_color);
6125 return;
6126 }
6127 }
6128
6129 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit0to31;
6130
6131 /* Skip color zero */
6132 bss_color_bitmap = bss_color_bitmap >> 1;
6133 for (i = 0; (i < 31) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
6134 if (!(bss_color_bitmap & 0x01)) {
6135 bss_color_index_array[num_bss_color] = i + 1;
6136 num_bss_color++;
6137 }
6138 bss_color_bitmap = bss_color_bitmap >> 1;
6139 }
6140
6141 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit32to63;
6142 for (i = 0; (i < 32) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
6143 if (!(bss_color_bitmap & 0x01)) {
6144 bss_color_index_array[num_bss_color] = i + 32;
6145 num_bss_color++;
6146 }
6147 bss_color_bitmap = bss_color_bitmap >> 1;
6148 }
6149
6150 if (num_bss_color) {
6151 qdf_get_random_bytes((void *) &rand_byte, 1);
6152 i = (rand_byte + qdf_mc_timer_get_system_ticks()) %
6153 num_bss_color;
6154 pe_debug("New bss color = %d", bss_color_index_array[i]);
6155 he_bss_color.session_id = obss_color_info->vdev_id;
6156 he_bss_color.bss_color = bss_color_index_array[i];
6157 lim_process_set_he_bss_color(mac_ctx,
6158 (uint32_t *)&he_bss_color);
6159 } else {
6160 pe_err("Unable to find bss color from bitmasp");
6161 if (obss_color_info->evt_type ==
6162 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY &&
6163 session->obss_color_collision_dec_evt ==
6164 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6165 /* In dot11BSSColorCollisionAPPeriod and
6166 * timer expired, time to disable bss color.
6167 */
6168 obss_color_collision_process_color_disable(mac_ctx,
6169 session);
6170 else
6171 /*
6172 * Enter dot11BSSColorCollisionAPPeriod period.
6173 */
6174 lim_send_obss_color_collision_cfg(mac_ctx, session,
6175 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY);
6176 }
6177}
6178
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006179void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6180{
6181 struct sir_set_he_bss_color *bss_color;
6182 tpPESession session_entry = NULL;
6183 tUpdateBeaconParams beacon_params;
6184
6185 if (!msg_buf) {
6186 pe_err("Buffer is Pointing to NULL");
6187 return;
6188 }
6189
6190 bss_color = (struct sir_set_he_bss_color *)msg_buf;
6191 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
6192 bss_color->session_id);
6193 if (!session_entry) {
6194 pe_err("Session not found for given session_id %d",
6195 bss_color->session_id);
6196 return;
6197 }
6198
6199 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6200 pe_err("Invalid SystemRole %d",
6201 GET_LIM_SYSTEM_ROLE(session_entry));
6202 return;
6203 }
6204
6205 if (bss_color->bss_color == session_entry->he_op.bss_color) {
6206 pe_err("No change in BSS color, current BSS color %d",
6207 bss_color->bss_color);
6208 return;
6209 }
6210 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
6211 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
6212 session_entry->he_op.bss_col_disabled = 1;
6213 session_entry->he_bss_color_change.countdown =
6214 BSS_COLOR_SWITCH_COUNTDOWN;
6215 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08006216 beacon_params.bss_color_disabled = 1;
6217 beacon_params.bss_color = session_entry->he_op.bss_color;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006218 session_entry->bss_color_changing = 1;
6219
6220 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006221 QDF_STATUS_SUCCESS) {
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006222 pe_err("Unable to set op mode IE in beacon");
6223 return;
6224 }
6225
6226 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
Arif Hussain05fb4872018-01-03 16:02:55 -08006227 lim_send_obss_color_collision_cfg(mac_ctx, session_entry,
6228 OBSS_COLOR_COLLISION_DETECTION_DISABLE);
6229}
6230
6231void lim_send_obss_color_collision_cfg(tpAniSirGlobal mac_ctx,
6232 tpPESession session,
6233 enum wmi_obss_color_collision_evt_type
6234 event_type)
6235{
6236 struct wmi_obss_color_collision_cfg_param *cfg_param;
6237 struct scheduler_msg msg = {0};
6238
6239 if (!session) {
6240 pe_err("Invalid session");
6241 return;
6242 }
6243
6244 if (!session->he_capable ||
6245 !session->is_session_obss_color_collision_det_enabled) {
6246 pe_debug("%d: obss color det not enabled, he_cap:%d, sup:%d:%d",
6247 session->smeSessionId, session->he_capable,
6248 session->is_session_obss_color_collision_det_enabled,
6249 mac_ctx->lim.global_obss_color_collision_det_offload);
6250 return;
6251 }
6252
6253 cfg_param = qdf_mem_malloc(sizeof(*cfg_param));
6254 if (!cfg_param) {
6255 pe_err("Failed to allocate memory");
6256 return;
6257 }
6258
6259 pe_debug("%d: sending event:%d", session->smeSessionId, event_type);
6260 qdf_mem_zero(cfg_param, sizeof(*cfg_param));
6261 cfg_param->vdev_id = session->smeSessionId;
6262 cfg_param->evt_type = event_type;
6263 if (LIM_IS_AP_ROLE(session))
6264 cfg_param->detection_period_ms =
6265 OBSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS;
6266 else
6267 cfg_param->detection_period_ms =
6268 OBSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS;
6269
6270 cfg_param->scan_period_ms = OBSS_COLOR_COLLISION_SCAN_PERIOD_MS;
6271 if (event_type == OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6272 cfg_param->free_slot_expiry_time_ms =
6273 OBSS_COLOR_COLLISION_FREE_SLOT_EXPIRY_MS;
6274
6275 msg.type = WMA_OBSS_COLOR_COLLISION_REQ;
6276 msg.bodyptr = cfg_param;
6277 msg.reserved = 0;
6278
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05306279 if (QDF_IS_STATUS_ERROR(scheduler_post_message(QDF_MODULE_ID_PE,
6280 QDF_MODULE_ID_WMA,
6281 QDF_MODULE_ID_WMA,
6282 &msg))) {
Arif Hussain05fb4872018-01-03 16:02:55 -08006283 pe_err("Failed to post WMA_OBSS_COLOR_COLLISION_REQ to WMA");
6284 qdf_mem_free(cfg_param);
6285 } else {
6286 session->obss_color_collision_dec_evt = event_type;
6287 }
6288}
6289
6290void lim_process_obss_color_collision_info(tpAniSirGlobal mac_ctx,
6291 uint32_t *msg_buf)
6292{
6293 struct wmi_obss_color_collision_info *obss_color_info;
6294 tpPESession session;
6295
6296 if (!msg_buf) {
6297 pe_err("Buffer is Pointing to NULL");
6298 return;
6299 }
6300
6301 obss_color_info = (struct wmi_obss_color_collision_info *)msg_buf;
6302 session = pe_find_session_by_sme_session_id(mac_ctx,
6303 obss_color_info->vdev_id);
6304 if (!session) {
6305 pe_err("Session not found for given session_id %d",
6306 obss_color_info->vdev_id);
6307 return;
6308 }
6309
6310 pe_debug("vdev_id:%d, evt:%d:%d, 0to31:0x%x, 32to63:0x%x, cap:%d:%d:%d",
6311 obss_color_info->vdev_id,
6312 obss_color_info->evt_type,
6313 session->obss_color_collision_dec_evt,
6314 obss_color_info->obss_color_bitmap_bit0to31,
6315 obss_color_info->obss_color_bitmap_bit32to63,
6316 session->he_capable,
6317 session->is_session_obss_color_collision_det_enabled,
6318 mac_ctx->lim.global_obss_color_collision_det_offload);
6319
6320 if (!session->he_capable ||
6321 !session->is_session_obss_color_collision_det_enabled) {
6322 return;
6323 }
6324
6325 switch (obss_color_info->evt_type) {
6326 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
6327 pe_err("%d: FW disabled obss color det. he_cap:%d, sup:%d:%d",
6328 session->smeSessionId, session->he_capable,
6329 session->is_session_obss_color_collision_det_enabled,
6330 mac_ctx->lim.global_obss_color_collision_det_offload);
6331 session->is_session_obss_color_collision_det_enabled = false;
6332 return;
6333 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
6334 case OBSS_COLOR_COLLISION_DETECTION:
6335 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
6336 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6337 pe_debug("Invalid System Role %d",
6338 GET_LIM_SYSTEM_ROLE(session));
6339 return;
6340 }
6341
6342 if (session->obss_color_collision_dec_evt !=
6343 obss_color_info->evt_type) {
6344 pe_debug("%d: Wrong event: %d, skiping",
6345 obss_color_info->vdev_id,
6346 obss_color_info->evt_type);
6347 return;
6348 }
6349 obss_color_collision_process_color_change(mac_ctx, session,
6350 obss_color_info);
6351 break;
6352 default:
6353 pe_err("%d: Invalid event type %d",
6354 obss_color_info->vdev_id, obss_color_info->evt_type);
6355 return;
6356 }
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006357}
6358#endif
Abhishek Singh20a8e442018-09-12 15:50:44 +05306359
6360#ifdef CONFIG_VDEV_SM
6361void lim_send_csa_restart_req(tpAniSirGlobal mac_ctx, uint8_t vdev_id)
6362{
6363 tpPESession session;
6364
6365 session = pe_find_session_by_sme_session_id(mac_ctx, vdev_id);
6366
6367 if (!session) {
6368 pe_err("session not found for vdev id %d", vdev_id);
6369 return;
6370 }
6371
6372 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
6373 WLAN_VDEV_SM_EV_CSA_RESTART,
6374 sizeof(*session), session);
6375}
6376#endif