blob: 90301ce767ef460c1a9cf473563a34c670f0d1a9 [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
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001585 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301586 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001587 (void *)&sme_join_req->operationalRateSet,
1588 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301589 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590 (void *)&sme_join_req->extendedRateSet,
1591 sizeof(tSirMacRateSet));
1592 /*
1593 * this may not be needed anymore now, as rateSet is now
1594 * included in the session entry and MLM has session context.
1595 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301596 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001597 (void *)&session->rateSet,
1598 sizeof(tSirMacRateSet));
1599
1600 session->encryptType = sme_join_req->UCEncryptionType;
1601
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301602 session->supported_nss_1x1 = sme_join_req->supported_nss_1x1;
1603 session->vdev_nss = sme_join_req->vdev_nss;
1604 session->nss = sme_join_req->nss;
1605 session->nss_forced_1x1 = sme_join_req->nss_forced_1x1;
1606
1607 pe_debug("nss %d, vdev_nss %d, supported_nss_1x1 %d",
1608 session->nss,
1609 session->vdev_nss,
1610 session->supported_nss_1x1);
1611
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001612 mlm_join_req->bssDescription.length =
1613 session->pLimJoinReq->bssDescription.length;
1614
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301615 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001616 (uint8_t *)
1617 &session->pLimJoinReq->bssDescription.bssId,
1618 session->pLimJoinReq->bssDescription.length + 2);
1619
1620 session->limCurrentBssCaps =
1621 session->pLimJoinReq->bssDescription.capabilityInfo;
1622
1623 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1624 session->currentOperChannel);
1625 local_power_constraint = reg_max;
1626
1627 lim_extract_ap_capability(mac_ctx,
1628 (uint8_t *)
1629 session->pLimJoinReq->bssDescription.ieFields,
1630 lim_get_ielen_from_bss_description(
1631 &session->pLimJoinReq->bssDescription),
1632 &session->limCurrentBssQosCaps,
1633 &session->limCurrentBssPropCap,
1634 &session->gLimCurrentBssUapsd,
1635 &local_power_constraint, session);
1636
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637 session->maxTxPower = lim_get_max_tx_power(reg_max,
1638 local_power_constraint,
1639 mac_ctx->roam.configParam.nTxPowerCap);
Abhinav Kumard528d192018-03-09 17:31:12 +05301640 session->def_max_tx_pwr = session->maxTxPower;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301641
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001642 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301643 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001644
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301645 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1646 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1647 pe_debug("Update MaxTxPower in join Req to %d",
1648 sme_join_req->powerCap.maxTxPower);
1649 }
1650
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001651 if (session->gLimCurrentBssUapsd) {
1652 session->gUapsdPerAcBitmask =
1653 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001654 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001655 session->gUapsdPerAcBitmask);
1656
1657 /* resetting the dynamic uapsd mask */
1658 session->gUapsdPerAcDeliveryEnableMask = 0;
1659 session->gUapsdPerAcTriggerEnableMask = 0;
1660 }
1661
1662 session->limRFBand =
1663 lim_get_rf_band(session->currentOperChannel);
1664
1665 /* Initialize 11h Enable Flag */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001666 if (BAND_5G == session->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001667 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001668 &val) != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001669 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001670 session->lim11hEnable =
1671 WNI_CFG_11H_ENABLED_STADEF;
1672 } else {
1673 session->lim11hEnable = val;
1674 }
1675 } else {
1676 session->lim11hEnable = 0;
1677 }
1678
1679 /*
1680 * To care of the scenario when STA transitions from
1681 * IBSS to Infrastructure mode.
1682 */
1683 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1684
1685 session->limPrevSmeState = session->limSmeState;
1686 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1687 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1688 session->peSessionId,
1689 session->limSmeState));
1690
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001691 /* Indicate whether spectrum management is enabled */
1692 session->spectrumMgtEnabled =
1693 sme_join_req->spectrumMgtIndicator;
1694
1695 /* Enable the spectrum management if this is a DFS channel */
1696 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001697 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001698 session->currentOperChannel))
1699 session->spectrumMgtEnabled = true;
1700
1701 session->isOSENConnection = sme_join_req->isOSENConnection;
1702
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001703 /* Issue LIM_MLM_JOIN_REQ to MLM */
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001704 lim_send_join_req(session, mlm_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001705 return;
1706
1707 } else {
1708 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001709 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001710 mac_ctx->lim.gLimSmeState);
1711 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1712 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1713 session = NULL;
1714 goto end;
1715 }
1716
1717end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301718 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1719 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001720
1721 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301722 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001723 sme_join_req = NULL;
1724 if (NULL != session)
1725 session->pLimJoinReq = NULL;
1726 }
1727 if (ret_code != eSIR_SME_SUCCESS) {
1728 if (NULL != session) {
1729 pe_delete_session(mac_ctx, session);
1730 session = NULL;
1731 }
1732 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001733 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001734 sme_session_id, ret_code);
1735 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1736 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1737 sme_transaction_id);
1738}
1739
Amar Singhala297bfa2015-10-15 15:07:29 -07001740uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001741 uint8_t iniTxPower)
1742{
1743 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301744 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001745
Anurag Chouhan6d760662016-02-20 16:05:43 +05301746 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001747 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1748 maxTxPower = txPower;
1749 else if (txPower < MIN_TX_PWR_CAP)
1750 maxTxPower = MIN_TX_PWR_CAP;
1751 else
1752 maxTxPower = MAX_TX_PWR_CAP;
1753
1754 return maxTxPower;
1755}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756
1757/**
1758 * __lim_process_sme_reassoc_req() - process reassoc req
1759 *
1760 * @mac_ctx: Pointer to Global MAC structure
1761 * @msg_buf: pointer to the SME message buffer
1762 *
1763 * This function is called to process SME_REASSOC_REQ message
1764 * from HDD or upper layer application.
1765 *
1766 * Return: None
1767 */
1768
1769static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
1770 uint32_t *msg_buf)
1771{
1772 uint16_t caps;
1773 uint32_t val;
1774 tpSirSmeJoinReq reassoc_req = NULL;
1775 tLimMlmReassocReq *mlm_reassoc_req;
1776 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1777 tpPESession session_entry = NULL;
1778 uint8_t session_id;
1779 uint8_t sme_session_id;
1780 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001781 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001782 uint32_t tele_bcn_en = 0;
1783 uint16_t size;
1784
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001785 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301786 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001788 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001789
1790 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1791 goto end;
1792 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301793 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001794
1795 if (!lim_is_sme_join_req_valid(mac_ctx,
1796 (tpSirSmeJoinReq)reassoc_req)) {
1797 /*
1798 * Received invalid eWNI_SME_REASSOC_REQ
1799 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001800 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001801
1802 ret_code = eSIR_SME_INVALID_PARAMETERS;
1803 goto end;
1804 }
1805
1806 session_entry = pe_find_session_by_bssid(mac_ctx,
1807 reassoc_req->bssDescription.bssId,
1808 &session_id);
1809 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001810 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001811 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
1812 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001813 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001814 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
1815 &sme_session_id, &transaction_id);
1816 session_entry =
1817 pe_find_session_by_sme_session_id(mac_ctx,
1818 sme_session_id);
1819 if (session_entry != NULL)
1820 lim_handle_sme_join_result(mac_ctx,
1821 eSIR_SME_INVALID_PARAMETERS,
1822 eSIR_MAC_UNSPEC_FAILURE_STATUS,
1823 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001824 goto end;
1825 }
1826#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
1827 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001828 session_entry, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1830 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
1831
1832 /* Store the reassoc handle in the session Table */
1833 session_entry->pLimReAssocReq = reassoc_req;
1834
1835 session_entry->dot11mode = reassoc_req->dot11mode;
1836 session_entry->vhtCapability =
1837 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001838
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301839 if (session_entry->vhtCapability) {
1840 if (session_entry->pePersona == QDF_STA_MODE) {
1841 session_entry->vht_config.su_beam_formee =
1842 reassoc_req->vht_config.su_beam_formee;
1843 } else {
1844 reassoc_req->vht_config.su_beam_formee = 0;
1845 }
1846 session_entry->enableVhtpAid =
1847 reassoc_req->enableVhtpAid;
1848 session_entry->enableVhtGid =
1849 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001850 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301851 }
1852
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301853 session_entry->supported_nss_1x1 = reassoc_req->supported_nss_1x1;
1854 session_entry->vdev_nss = reassoc_req->vdev_nss;
1855 session_entry->nss = reassoc_req->nss;
1856 session_entry->nss_forced_1x1 = reassoc_req->nss_forced_1x1;
1857
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001858 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301859 session_entry->vhtCapability,
1860 session_entry->vht_config.su_beam_formee,
1861 session_entry->vht_config.su_beam_former);
1862
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001863 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
1864 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001865 session_entry->send_smps_action =
1866 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001867 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001868 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001869 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001870 session_entry->send_smps_action,
1871 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001872 /*
1873 * Reassociate request is expected
1874 * in link established state only.
1875 */
1876
1877 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001878 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
1879 /*
1880 * May be from 11r FT pre-auth. So lets check it
1881 * before we bail out
1882 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001883 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001884 session_entry->peSessionId);
1885
1886 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301887 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888 session_entry->limReAssocbssId,
1889 6)) {
1890 lim_print_mac_addr(mac_ctx,
1891 reassoc_req->bssDescription.
1892 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001893 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001894 ret_code = eSIR_SME_INVALID_PARAMETERS;
1895 goto end;
1896 }
1897
1898 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
1899 session_entry);
1900 return;
1901 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001902 /*
1903 * Should not have received eWNI_SME_REASSOC_REQ
1904 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001905 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001906 session_entry->limSmeState);
1907 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
1908
1909 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1910 goto end;
1911 }
1912
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301913 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001914 session_entry->pLimReAssocReq->bssDescription.bssId,
1915 sizeof(tSirMacAddr));
1916
1917 session_entry->limReassocChannelId =
1918 session_entry->pLimReAssocReq->bssDescription.channelId;
1919
1920 session_entry->reAssocHtSupportedChannelWidthSet =
1921 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
1922 session_entry->reAssocHtRecommendedTxWidthSet =
1923 session_entry->reAssocHtSupportedChannelWidthSet;
1924 session_entry->reAssocHtSecondaryChannelOffset =
1925 session_entry->pLimReAssocReq->cbMode;
1926
1927 session_entry->limReassocBssCaps =
1928 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
1929 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1930 session_entry->currentOperChannel);
1931 local_pwr_constraint = reg_max;
1932
1933 lim_extract_ap_capability(mac_ctx,
1934 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
1935 lim_get_ielen_from_bss_description(
1936 &session_entry->pLimReAssocReq->bssDescription),
1937 &session_entry->limReassocBssQosCaps,
1938 &session_entry->limReassocBssPropCap,
1939 &session_entry->gLimCurrentBssUapsd,
1940 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05301941 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001942 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301943 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944 /* Copy the SSID from session entry to local variable */
1945 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301946 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001947 reassoc_req->ssId.ssId,
1948 session_entry->limReassocSSID.length);
1949 if (session_entry->gLimCurrentBssUapsd) {
1950 session_entry->gUapsdPerAcBitmask =
1951 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001952 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001953 session_entry->gUapsdPerAcBitmask);
1954 }
1955
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301956 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001957 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001958 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001959
1960 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1961 goto end;
1962 }
1963
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301964 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001965 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
1966
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001967 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001968 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001969 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301970
1971 lim_update_caps_info_for_bss(mac_ctx, &caps,
1972 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001973 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301974
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001975 mlm_reassoc_req->capabilityInfo = caps;
1976
1977 /* Update PE session_id */
1978 mlm_reassoc_req->sessionId = session_id;
1979
1980 /*
1981 * If telescopic beaconing is enabled, set listen interval to
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05301982 * CFG_TELE_BCN_MAX_LI
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001984
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05301985 tele_bcn_en = mac_ctx->mlme_cfg->sap_cfg.tele_bcn_wakeup_en;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001986
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05301987 if (tele_bcn_en)
1988 val = mac_ctx->mlme_cfg->sap_cfg.tele_bcn_max_li;
1989 else
1990 val = mac_ctx->mlme_cfg->sap_cfg.listen_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991
1992 mlm_reassoc_req->listenInterval = (uint16_t) val;
1993
1994 /* Indicate whether spectrum management is enabled */
1995 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
1996
1997 /* Enable the spectrum management if this is a DFS channel */
1998 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001999 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000 session_entry->currentOperChannel))
2001 session_entry->spectrumMgtEnabled = true;
2002
2003 session_entry->limPrevSmeState = session_entry->limSmeState;
2004 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2005
2006 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2007 session_entry->peSessionId,
2008 session_entry->limSmeState));
2009
2010 lim_post_mlm_message(mac_ctx,
2011 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2012 return;
2013end:
2014 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302015 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002016 if (session_entry)
2017 session_entry->pLimReAssocReq = NULL;
2018 }
2019
2020 if (session_entry) {
2021 /*
2022 * error occurred after we determined the session so extract
2023 * session and transaction info from there
2024 */
2025 sme_session_id = session_entry->smeSessionId;
2026 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002027 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002028 /*
2029 * error occurred before or during the time we determined
2030 * the session so extract the session and transaction info
2031 * from the message
2032 */
2033 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2034 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002035 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002036 /*
2037 * Send Reassoc failure response to host
2038 * (note session_entry may be NULL, but that's OK)
2039 */
2040 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2041 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2042 session_entry, sme_session_id,
2043 transaction_id);
2044}
2045
2046bool send_disassoc_frame = 1;
2047/**
2048 * __lim_process_sme_disassoc_req()
2049 *
2050 ***FUNCTION:
2051 * This function is called to process SME_DISASSOC_REQ message
2052 * from HDD or upper layer application.
2053 *
2054 ***LOGIC:
2055 *
2056 ***ASSUMPTIONS:
2057 *
2058 ***NOTE:
2059 *
2060 * @param pMac Pointer to Global MAC structure
2061 * @param *pMsgBuf A pointer to the SME message buffer
2062 * @return None
2063 */
2064
2065static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2066{
2067 uint16_t disassocTrigger, reasonCode;
2068 tLimMlmDisassocReq *pMlmDisassocReq;
2069 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2070 tSirSmeDisassocReq smeDisassocReq;
2071 tpPESession psessionEntry = NULL;
2072 uint8_t sessionId;
2073 uint8_t smesessionId;
2074 uint16_t smetransactionId;
2075
2076 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002077 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002078 return;
2079 }
2080
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302081 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002082 smesessionId = smeDisassocReq.sessionId;
2083 smetransactionId = smeDisassocReq.transactionId;
2084 if (!lim_is_sme_disassoc_req_valid(pMac,
2085 &smeDisassocReq,
2086 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002087 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002088 if (pMac->lim.gLimRspReqd) {
2089 pMac->lim.gLimRspReqd = false;
2090
2091 retCode = eSIR_SME_INVALID_PARAMETERS;
2092 disassocTrigger = eLIM_HOST_DISASSOC;
2093 goto sendDisassoc;
2094 }
2095
2096 return;
2097 }
2098
2099 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002100 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002101 &sessionId);
2102 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002103 pe_err("session does not exist for given bssId "
2104 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002105 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002106 retCode = eSIR_SME_INVALID_PARAMETERS;
2107 disassocTrigger = eLIM_HOST_DISASSOC;
2108 goto sendDisassoc;
2109 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002110 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2111 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002112 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2113 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002114 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002115
2116#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2117 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2118 0, smeDisassocReq.reasonCode);
2119#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2120
2121 /* Update SME session Id and SME transaction ID */
2122
2123 psessionEntry->smeSessionId = smesessionId;
2124 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002125 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002126 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002127
2128 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2129 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002130 switch (psessionEntry->limSmeState) {
2131 case eLIM_SME_ASSOCIATED_STATE:
2132 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002133 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002134 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002135 psessionEntry->limPrevSmeState =
2136 psessionEntry->limSmeState;
2137 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002138 /* Delete all TDLS peers connected before leaving BSS */
2139 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002140 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2141 psessionEntry->peSessionId,
2142 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002143 break;
2144
2145 case eLIM_SME_WT_DEAUTH_STATE:
2146 /* PE shall still process the DISASSOC_REQ and proceed with
2147 * link tear down even if it had already sent a DEAUTH_IND to
2148 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2149 * its been set when PE entered WT_DEAUTH_STATE.
2150 */
2151 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2152 MTRACE(mac_trace
2153 (pMac, TRACE_CODE_SME_STATE,
2154 psessionEntry->peSessionId,
2155 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002156 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002157 break;
2158
2159 case eLIM_SME_WT_DISASSOC_STATE:
Jeff Johnson47d75242018-05-12 15:58:53 -07002160 /* PE Received a Disassoc frame. Normally it gets DISASSOC_CNF but it
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002161 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2162 * PE can continue processing DISASSOC_REQ and send the response instead
2163 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2164 * for disassoc frame.
2165 *
2166 * It will send a disassoc, which is ok. However, we can use the global flag
2167 * sendDisassoc to not send disassoc frame.
2168 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002169 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002170 break;
2171
2172 case eLIM_SME_JOIN_FAILURE_STATE: {
2173 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002174 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002175 if (pMac->lim.gLimRspReqd) {
2176 retCode = eSIR_SME_SUCCESS;
2177 disassocTrigger = eLIM_HOST_DISASSOC;
2178 goto sendDisassoc;
2179 }
2180 }
2181 break;
2182 default:
2183 /**
2184 * STA is not currently associated.
2185 * Log error and send response to host
2186 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002187 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002188 psessionEntry->limSmeState);
2189 lim_print_sme_state(pMac, LOGE,
2190 psessionEntry->limSmeState);
2191
2192 if (pMac->lim.gLimRspReqd) {
2193 if (psessionEntry->limSmeState !=
2194 eLIM_SME_WT_ASSOC_STATE)
2195 pMac->lim.gLimRspReqd = false;
2196
2197 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2198 disassocTrigger = eLIM_HOST_DISASSOC;
2199 goto sendDisassoc;
2200 }
2201
2202 return;
2203 }
2204
2205 break;
2206
2207 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002208 /* Fall through */
2209 break;
2210
2211 case eLIM_STA_IN_IBSS_ROLE:
2212 default:
2213 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002214 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002215 GET_LIM_SYSTEM_ROLE(psessionEntry));
2216
2217 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2218 disassocTrigger = eLIM_HOST_DISASSOC;
2219 goto sendDisassoc;
2220 } /* end switch (pMac->lim.gLimSystemRole) */
2221
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302222 disassocTrigger = eLIM_HOST_DISASSOC;
2223 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002224
2225 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002226 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002227 send_disassoc_frame = 0;
2228 }
2229 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002230 pe_debug("Sending Disasscoc with disassoc Trigger"
2231 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002232 disassocTrigger, reasonCode);
2233
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302234 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002235 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002236 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002237 return;
2238 }
2239
Anurag Chouhanc5548422016-02-24 18:33:27 +05302240 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002241 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002242
2243 pMlmDisassocReq->reasonCode = reasonCode;
2244 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2245
2246 /* Update PE session ID */
2247 pMlmDisassocReq->sessionId = sessionId;
2248
2249 lim_post_mlm_message(pMac,
2250 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2251 return;
2252
2253sendDisassoc:
2254 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002255 lim_send_sme_disassoc_ntf(pMac,
2256 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002257 retCode,
2258 disassocTrigger,
2259 1, smesessionId, smetransactionId,
2260 psessionEntry);
2261 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002262 lim_send_sme_disassoc_ntf(pMac,
2263 smeDisassocReq.peer_macaddr.bytes,
2264 retCode, disassocTrigger, 1,
2265 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002266
2267} /*** end __lim_process_sme_disassoc_req() ***/
2268
2269/** -----------------------------------------------------------------
2270 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2271
2272 This function is called to process SME_DISASSOC_CNF message
2273 from HDD or upper layer application.
2274
2275 \param pMac - global mac structure
2276 \param pStaDs - station dph hash node
2277 \return none
2278 \sa
2279 ----------------------------------------------------------------- */
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002280void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002281{
2282 tSirSmeDisassocCnf smeDisassocCnf;
2283 uint16_t aid;
2284 tpDphHashNode pStaDs;
2285 tpPESession psessionEntry;
2286 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302287 uint32_t *msg = NULL;
2288 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002289
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302290 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002291 sizeof(struct sSirSmeDisassocCnf));
2292
2293 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002294 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002295 &sessionId);
2296 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002297 pe_err("session does not exist for given bssId");
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302298 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302299 smeDisassocCnf.sme_session_id,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302300 eSIR_SME_INVALID_SESSION,
2301 NULL);
2302 if (QDF_IS_STATUS_SUCCESS(status))
2303 lim_send_sme_disassoc_deauth_ntf(pMac,
2304 QDF_STATUS_SUCCESS,
2305 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002306 return;
2307 }
2308
2309 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002310 pe_err("received invalid SME_DISASSOC_CNF message");
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302311 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2312 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302313 eSIR_SME_INVALID_PARAMETERS,
2314 &smeDisassocCnf.bssid.bytes[0]);
2315 if (QDF_IS_STATUS_SUCCESS(status))
2316 lim_send_sme_disassoc_deauth_ntf(pMac,
2317 QDF_STATUS_SUCCESS,
2318 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002319 return;
2320 }
2321#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2322 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2323 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2324 psessionEntry,
2325 (uint16_t) smeDisassocCnf.statusCode, 0);
2326 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2327 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2328 psessionEntry,
2329 (uint16_t) smeDisassocCnf.statusCode, 0);
2330#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2331
2332 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2333 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002334 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2335 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2336 && (psessionEntry->limSmeState !=
2337 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002338 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002339 psessionEntry->limSmeState);
2340 lim_print_sme_state(pMac, LOGE,
2341 psessionEntry->limSmeState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302342 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302343 psessionEntry->smeSessionId,
2344 eSIR_SME_INVALID_STATE,
2345 &smeDisassocCnf.bssid.bytes[0]);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302346 if (QDF_IS_STATUS_SUCCESS(status))
2347 lim_send_sme_disassoc_deauth_ntf(pMac,
2348 QDF_STATUS_SUCCESS,
2349 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002350 return;
2351 }
2352 break;
2353
2354 case eLIM_AP_ROLE:
2355 /* Fall through */
2356 break;
2357
2358 case eLIM_STA_IN_IBSS_ROLE:
2359 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002360 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002361 GET_LIM_SYSTEM_ROLE(psessionEntry));
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302362 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2363 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302364 eSIR_SME_INVALID_STATE,
2365 &smeDisassocCnf.bssid.bytes[0]);
2366 if (QDF_IS_STATUS_SUCCESS(status))
2367 lim_send_sme_disassoc_deauth_ntf(pMac,
2368 QDF_STATUS_SUCCESS,
2369 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002370 return;
2371 }
2372
2373 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2374 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2375 LIM_IS_AP_ROLE(psessionEntry)) {
2376 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002377 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002378 &psessionEntry->dph.dphHashTable);
2379 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002380 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2381 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002382 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302383 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302384 psessionEntry->smeSessionId,
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05302385 eSIR_SME_INVALID_PARAMETERS,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302386 &smeDisassocCnf.bssid.bytes[0]);
2387 if (QDF_IS_STATUS_SUCCESS(status))
2388 lim_send_sme_disassoc_deauth_ntf(pMac,
2389 QDF_STATUS_SUCCESS,
2390 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002391 return;
2392 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302393
2394 if ((pStaDs->mlmStaContext.mlmState ==
2395 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2396 (pStaDs->mlmStaContext.mlmState ==
Arif Hussain5fa13782018-05-10 11:29:52 -07002397 eLIM_MLM_WT_DEL_BSS_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002398 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002399 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302400 pStaDs->mlmStaContext.mlmState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302401 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302402 psessionEntry->smeSessionId,
2403 eSIR_SME_SUCCESS,
2404 NULL);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302405 if (QDF_IS_STATUS_SUCCESS(status))
2406 lim_send_sme_disassoc_deauth_ntf(pMac,
2407 QDF_STATUS_SUCCESS,
2408 (uint32_t *)msg);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302409 return;
2410 }
2411
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002412 /* Delete FT session if there exists one */
2413 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002414 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2415
2416 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002417 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002418 }
2419
2420 return;
2421}
2422
2423/**
2424 * __lim_process_sme_deauth_req() - process sme deauth req
2425 * @mac_ctx: Pointer to Global MAC structure
2426 * @msg_buf: pointer to the SME message buffer
2427 *
2428 * This function is called to process SME_DEAUTH_REQ message
2429 * from HDD or upper layer application.
2430 *
2431 * Return: None
2432 */
2433
2434static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2435 uint32_t *msg_buf)
2436{
2437 uint16_t deauth_trigger, reason_code;
2438 tLimMlmDeauthReq *mlm_deauth_req;
2439 tSirSmeDeauthReq sme_deauth_req;
2440 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2441 tpPESession session_entry;
2442 uint8_t session_id; /* PE sessionId */
2443 uint8_t sme_session_id;
2444 uint16_t sme_transaction_id;
2445
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302446 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002447 sme_session_id = sme_deauth_req.sessionId;
2448 sme_transaction_id = sme_deauth_req.transactionId;
2449
2450 /*
2451 * We need to get a session first but we don't even know
2452 * if the message is correct.
2453 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002454 session_entry = pe_find_session_by_bssid(mac_ctx,
2455 sme_deauth_req.bssid.bytes,
2456 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002457 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002458 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002459 ret_code = eSIR_SME_INVALID_PARAMETERS;
2460 deauth_trigger = eLIM_HOST_DEAUTH;
2461 goto send_deauth;
2462 }
2463
2464 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2465 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002466 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002467 mac_ctx->lim.gLimRspReqd = false;
2468
2469 ret_code = eSIR_SME_INVALID_PARAMETERS;
2470 deauth_trigger = eLIM_HOST_DEAUTH;
2471 goto send_deauth;
2472 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002473 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2474 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002475 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2476 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002477 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002478#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2479 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2480 session_entry, 0, sme_deauth_req.reasonCode);
2481#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2482
2483 /* Update SME session ID and Transaction ID */
2484 session_entry->smeSessionId = sme_session_id;
2485 session_entry->transactionId = sme_transaction_id;
2486
2487 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2488 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002489 switch (session_entry->limSmeState) {
2490 case eLIM_SME_ASSOCIATED_STATE:
2491 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302492 /* Delete all TDLS peers connected before leaving BSS */
2493 lim_delete_tdls_peers(mac_ctx, session_entry);
Abhinav Kumarac12c762018-05-02 13:51:02 +05302494 /* fallthrough */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002495 case eLIM_SME_WT_ASSOC_STATE:
2496 case eLIM_SME_JOIN_FAILURE_STATE:
2497 case eLIM_SME_IDLE_STATE:
2498 session_entry->limPrevSmeState =
2499 session_entry->limSmeState;
2500 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2501 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2502 session_entry->peSessionId,
2503 session_entry->limSmeState));
2504 /* Send Deauthentication request to MLM below */
2505 break;
2506 case eLIM_SME_WT_DEAUTH_STATE:
2507 case eLIM_SME_WT_DISASSOC_STATE:
2508 /*
Jeff Johnson47d75242018-05-12 15:58:53 -07002509 * PE Received a Deauth/Disassoc frame. Normally it get
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002510 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2511 * Which means host is also trying to disconnect.
2512 * PE can continue processing DEAUTH_REQ and send
2513 * the response instead of failing the request.
2514 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2515 * was sent for deauth/disassoc frame.
2516 */
2517 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002518 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002519 break;
2520 default:
2521 /*
2522 * STA is not in a state to deauthenticate with
2523 * peer. Log error and send response to host.
2524 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002525 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002526 session_entry->limSmeState);
2527 lim_print_sme_state(mac_ctx, LOGE,
2528 session_entry->limSmeState);
2529
2530 if (mac_ctx->lim.gLimRspReqd) {
2531 mac_ctx->lim.gLimRspReqd = false;
2532
2533 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2534 deauth_trigger = eLIM_HOST_DEAUTH;
2535
wadesong42968e92017-06-08 14:11:21 +08002536 /*
2537 * here we received deauth request from AP so
2538 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2539 * have ISSUED delSta then mlm state should be
2540 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2541 * delBSS rsp then mlm state should be
2542 * eLIM_MLM_IDLE_STATE so the below condition
2543 * captures the state where delSta not done
2544 * and firmware still in connected state.
2545 */
2546 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002547 eLIM_SME_WT_DEAUTH_STATE &&
2548 session_entry->limMlmState !=
2549 eLIM_MLM_IDLE_STATE &&
2550 session_entry->limMlmState !=
2551 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002552 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002553 goto send_deauth;
2554 }
2555 return;
2556 }
2557 break;
2558
2559 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002560 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002561 if (mac_ctx->lim.gLimRspReqd) {
2562 mac_ctx->lim.gLimRspReqd = false;
2563 ret_code = eSIR_SME_INVALID_PARAMETERS;
2564 deauth_trigger = eLIM_HOST_DEAUTH;
2565 goto send_deauth;
2566 }
2567 return;
2568 case eLIM_AP_ROLE:
2569 break;
2570 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002571 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002572 GET_LIM_SYSTEM_ROLE(session_entry));
2573 if (mac_ctx->lim.gLimRspReqd) {
2574 mac_ctx->lim.gLimRspReqd = false;
2575 ret_code = eSIR_SME_INVALID_PARAMETERS;
2576 deauth_trigger = eLIM_HOST_DEAUTH;
2577 goto send_deauth;
2578 }
2579 return;
2580 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2581
2582 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2583 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002584 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002585 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2586 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2587 } else {
2588 deauth_trigger = eLIM_HOST_DEAUTH;
2589 reason_code = sme_deauth_req.reasonCode;
2590 }
2591
2592 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302593 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002594 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002595 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002596 if (mac_ctx->lim.gLimRspReqd) {
2597 mac_ctx->lim.gLimRspReqd = false;
2598 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2599 deauth_trigger = eLIM_HOST_DEAUTH;
2600 goto send_deauth;
2601 }
2602 return;
2603 }
2604
Anurag Chouhanc5548422016-02-24 18:33:27 +05302605 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002606 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002607
2608 mlm_deauth_req->reasonCode = reason_code;
2609 mlm_deauth_req->deauthTrigger = deauth_trigger;
2610
2611 /* Update PE session Id */
2612 mlm_deauth_req->sessionId = session_id;
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002613 lim_process_mlm_deauth_req(mac_ctx, (uint32_t *)mlm_deauth_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002614
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002615 return;
2616
2617send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002618 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2619 ret_code, deauth_trigger, 1,
2620 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002621}
2622
2623/**
2624 * __lim_process_sme_set_context_req()
2625 *
2626 * @mac_ctx: Pointer to Global MAC structure
2627 * @msg_buf: pointer to the SME message buffer
2628 *
2629 * This function is called to process SME_SETCONTEXT_REQ message
2630 * from HDD or upper layer application.
2631 *
2632 * Return: None
2633 */
2634
2635static void
2636__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2637{
2638 tpSirSmeSetContextReq set_context_req;
2639 tLimMlmSetKeysReq *mlm_set_key_req;
2640 tpPESession session_entry;
2641 uint8_t session_id; /* PE sessionID */
2642 uint8_t sme_session_id;
2643 uint16_t sme_transaction_id;
2644
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002645 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002646 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002647 return;
2648 }
2649
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302650 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002651 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002652 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002653 return;
2654 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302655 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002656 sizeof(struct sSirSmeSetContextReq));
2657 sme_session_id = set_context_req->sessionId;
2658 sme_transaction_id = set_context_req->transactionId;
2659
2660 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002661 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002662 goto end;
2663 }
2664
2665 if (set_context_req->keyMaterial.numKeys >
2666 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002667 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002668 set_context_req->keyMaterial.numKeys);
2669 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002670 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002671 eSIR_SME_INVALID_PARAMETERS, NULL,
2672 sme_session_id, sme_transaction_id);
2673 goto end;
2674 }
2675
2676 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002677 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002678 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002679 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002680 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002681 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002682 eSIR_SME_INVALID_PARAMETERS, NULL,
2683 sme_session_id, sme_transaction_id);
2684 goto end;
2685 }
2686#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2687 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2688 session_entry, 0, 0);
2689#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2690
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002691 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002692 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2693 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002694 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002695 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2696 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302697 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002698 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002699 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002700 goto end;
2701 }
2702 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2703 mlm_set_key_req->numKeys =
2704 set_context_req->keyMaterial.numKeys;
2705 if (mlm_set_key_req->numKeys >
2706 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002707 pe_err("no.of keys exceeded max num of default keys limit");
Jingxiang Ge4168a232018-01-03 18:47:15 +08002708 qdf_mem_free(mlm_set_key_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002709 goto end;
2710 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302711 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002712 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002713
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302714 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002715 (uint8_t *) &set_context_req->keyMaterial.key,
2716 sizeof(tSirKeys) *
2717 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2718 numKeys : 1));
2719
2720 mlm_set_key_req->sessionId = session_id;
2721 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002722 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002723 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002724
2725 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2726 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2727 LIM_IS_AP_ROLE(session_entry)) {
2728 if (set_context_req->keyMaterial.key[0].keyLength) {
2729 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002730
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002731 key_id =
2732 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302733 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002734 &session_entry->WEPKeyMaterial[key_id],
2735 (uint8_t *) &set_context_req->keyMaterial,
2736 sizeof(tSirKeyMaterial));
2737 } else {
2738 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002739
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002740 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2741 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302742 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002743 &mlm_set_key_req->key[i],
2744 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2745 sizeof(tSirKeys));
2746 }
2747 }
2748 }
2749 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2750 (uint32_t *) mlm_set_key_req);
2751 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002752 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002753 GET_LIM_SYSTEM_ROLE(session_entry),
2754 session_entry->limSmeState);
2755 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2756
2757 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002758 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002759 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2760 session_entry, sme_session_id,
2761 sme_transaction_id);
2762 }
2763end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302764 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002765 return;
2766}
2767
2768/**
2769 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2770 *
2771 * @mac_ctx: Pointer to Global MAC structure
2772 * @msg_buf: pointer to the SME message buffer
2773 *
2774 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2775 * from HDD or upper layer application.
2776 *
2777 * Return: None
2778 */
2779
Jeff Johnson801f1532016-10-07 07:54:50 -07002780static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2781 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002782{
2783 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2784 tpDphHashNode sta_ds = NULL;
2785 tpPESession session_entry = NULL;
2786 tSap_Event sap_event;
2787 tpWLAN_SAPEventCB sap_event_cb = NULL;
2788 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2789 uint8_t session_id = CSR_SESSION_ID_INVALID;
2790 uint8_t assoc_id = 0;
2791 uint8_t sta_cnt = 0;
2792
2793 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002794 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002795 return;
2796 }
2797
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302798 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002799 sizeof(struct sSirSmeGetAssocSTAsReq));
2800 /*
2801 * Get Associated stations from PE.
2802 * Find PE session Entry
2803 */
2804 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08002805 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002806 &session_id);
2807 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002808 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002809 goto lim_assoc_sta_end;
2810 }
2811
2812 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002813 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002814 session_entry->limSmeState,
2815 GET_LIM_SYSTEM_ROLE(session_entry));
2816 goto lim_assoc_sta_end;
2817 }
2818 /* Retrieve values obtained in the request message */
2819 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
2820 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2821
2822 if (NULL == assoc_sta_tmp)
2823 goto lim_assoc_sta_end;
2824 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
2825 assoc_id++) {
2826 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
2827 &session_entry->dph.dphHashTable);
2828 if (NULL == sta_ds)
2829 continue;
2830 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302831 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002832 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302833 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002834 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
2835 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
2836
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302837 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002838 (uint8_t *)&sta_ds->supportedRates,
2839 sizeof(tSirSupportedRates));
2840 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
2841 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
2842 assoc_sta_tmp->Support40Mhz =
2843 sta_ds->htDsssCckRate40MHzSupport;
2844
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002845 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002846 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002847 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002848 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002849 pe_debug("Association Id: %d Station Index: %d",
2850 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002851 assoc_sta_tmp++;
2852 sta_cnt++;
2853 }
2854 }
2855lim_assoc_sta_end:
2856 /*
2857 * Call hdd callback with sap event to send the list of
2858 * associated stations from PE
2859 */
2860 if (sap_event_cb != NULL) {
2861 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
2862 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302863 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002864 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
2865 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
2866 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2867 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
2868 }
2869}
2870
2871/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002872 * __lim_counter_measures()
2873 *
2874 * FUNCTION:
2875 * This function is called to "implement" MIC counter measure
2876 * and is *temporary* only
2877 *
2878 * LOGIC: on AP, disassoc all STA associated thru TKIP,
2879 * we don't do the proper STA disassoc sequence since the
Jeff Johnsond460e842018-05-11 13:25:53 -07002880 * BSS will be stopped anyway
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002881 *
2882 ***ASSUMPTIONS:
2883 *
2884 ***NOTE:
2885 *
2886 * @param pMac Pointer to Global MAC structure
2887 * @return None
2888 */
2889
2890static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
2891{
2892 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002893
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002894 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002895 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
2896 mac, psessionEntry, false);
2897};
2898
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302899/**
2900 * lim_send_stop_bss_failure_resp() -send failure delete bss resp to sme
2901 * @mac_ctx: mac ctx
2902 * @session: session pointer
2903 *
2904 * Return None
2905 */
2906static void lim_send_stop_bss_failure_resp(tpAniSirGlobal mac_ctx,
2907 tpPESession session)
2908{
2909 session->limSmeState = session->limPrevSmeState;
2910
2911 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE, session->peSessionId,
2912 session->limSmeState));
2913
2914 lim_send_sme_rsp(mac_ctx, eWNI_SME_STOP_BSS_RSP,
2915 eSIR_SME_STOP_BSS_FAILURE, session->smeSessionId,
2916 session->transactionId);
2917}
2918
2919void lim_delete_all_peers(tpPESession session)
2920{
2921 uint8_t i = 0;
2922 tpAniSirGlobal mac_ctx = session->mac_ctx;
2923 tpDphHashNode sta_ds = NULL;
2924 QDF_STATUS status;
2925
2926 for (i = 1; i < session->dph.dphHashTable.size; i++) {
2927 sta_ds = dph_get_hash_entry(mac_ctx, i,
2928 &session->dph.dphHashTable);
2929 if (!sta_ds)
2930 continue;
2931 status = lim_del_sta(mac_ctx, sta_ds, false, session);
2932 if (QDF_STATUS_SUCCESS == status) {
2933 lim_delete_dph_hash_entry(mac_ctx, sta_ds->staAddr,
2934 sta_ds->assocId, session);
2935 lim_release_peer_idx(mac_ctx, sta_ds->assocId, session);
2936 } else {
2937 pe_err("lim_del_sta failed with Status: %d", status);
2938 QDF_ASSERT(0);
2939 }
2940 }
Abhishek Singhcaa61852018-09-12 15:50:04 +05302941
2942#ifdef CONFIG_VDEV_SM
2943 status =
2944 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
2945 WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE,
2946 sizeof(*session), session);
2947 if (QDF_IS_STATUS_ERROR(status)) {
2948 pe_err("failed to post WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE for vdevid %d",
2949 session->smeSessionId);
2950 lim_send_stop_bss_failure_resp(mac_ctx, session);
2951 }
2952#endif
2953
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302954}
2955
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002956QDF_STATUS lim_sta_send_del_bss(tpPESession session)
2957{
2958 tpAniSirGlobal mac_ctx = session->mac_ctx;
2959 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2960 tpDphHashNode sta_ds = NULL;
2961
2962 sta_ds = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
2963 &session->dph.dphHashTable);
2964 if (!sta_ds) {
2965 pe_err("DPH Entry for STA is missing, failed to send delbss");
2966 goto end;
2967 }
2968
2969 status = lim_del_bss(mac_ctx, sta_ds, 0, session);
2970 if (QDF_IS_STATUS_ERROR(status))
2971 pe_err("delBss failed for bss %d", session->bssIdx);
2972
2973end:
2974 return status;
2975}
2976
Abhishek Singhcaa61852018-09-12 15:50:04 +05302977QDF_STATUS lim_send_vdev_stop(tpPESession session)
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302978{
2979 tpAniSirGlobal mac_ctx = session->mac_ctx;
2980 QDF_STATUS status;
2981
2982 status = lim_del_bss(mac_ctx, NULL, session->bssIdx, session);
2983
2984 if (QDF_IS_STATUS_ERROR(status)) {
2985 pe_err("delBss failed for bss %d", session->bssIdx);
2986 lim_send_stop_bss_failure_resp(mac_ctx, session);
2987 }
Abhishek Singhcaa61852018-09-12 15:50:04 +05302988
2989 return status;
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302990}
2991
2992/**
2993 * lim_delete_peers_and_send_vdev_stop() -delete peers and send vdev stop
2994 * @session: session pointer
2995 *
2996 * Return None
2997 */
Abhishek Singhcaa61852018-09-12 15:50:04 +05302998#ifdef CONFIG_VDEV_SM
2999static void lim_delete_peers_and_send_vdev_stop(tpPESession session)
3000{
3001 tpAniSirGlobal mac_ctx = session->mac_ctx;
3002 QDF_STATUS status;
3003
Abhishek Singhc5a54082018-09-12 16:08:03 +05303004 if (wlan_vdev_mlme_get_substate(session->vdev) ==
3005 WLAN_VDEV_SS_START_RESTART_PROGRESS)
3006 status =
3007 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3008 WLAN_VDEV_SM_EV_RESTART_REQ_FAIL,
Abhishek Singhcaa61852018-09-12 15:50:04 +05303009 sizeof(*session), session);
Abhishek Singhc5a54082018-09-12 16:08:03 +05303010 else
3011 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3012 WLAN_VDEV_SM_EV_DOWN,
3013 sizeof(*session),
3014 session);
Abhishek Singhcaa61852018-09-12 15:50:04 +05303015 if (QDF_IS_STATUS_ERROR(status)) {
3016 pe_err("failed to post WLAN_VDEV_SM_EV_DOWN for vdevid %d",
3017 session->smeSessionId);
3018 lim_send_stop_bss_failure_resp(mac_ctx, session);
3019 }
3020}
3021#else
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303022static void lim_delete_peers_and_send_vdev_stop(tpPESession session)
3023{
3024 lim_delete_all_peers(session);
3025 /* send a delBss to HAL and wait for a response */
3026 lim_send_vdev_stop(session);
3027}
Abhishek Singhcaa61852018-09-12 15:50:04 +05303028#endif
3029
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003030static void
3031__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3032{
3033 tSirSmeStopBssReq stopBssReq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003034 tLimSmeStates prevState;
3035 tpPESession psessionEntry;
3036 uint8_t smesessionId;
3037 uint8_t sessionId;
3038 uint16_t smetransactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003039
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303040 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003041 smesessionId = stopBssReq.sessionId;
3042 smetransactionId = stopBssReq.transactionId;
3043
3044 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003045 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003046 /* Send Stop BSS response to host */
3047 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3048 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3049 smetransactionId);
3050 return;
3051 }
3052
3053 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003054 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055 &sessionId);
3056 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003057 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3059 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3060 smetransactionId);
3061 return;
3062 }
3063#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3064 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3065 0, 0);
3066#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3067
3068 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3069 LIM_IS_STA_ROLE(psessionEntry)) {
3070 /**
3071 * Should not have received STOP_BSS_REQ in states
3072 * other than 'normal' state or on STA in Infrastructure
3073 * mode. Log error and return response to host.
3074 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003075 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003076 psessionEntry->limSmeState,
3077 GET_LIM_SYSTEM_ROLE(psessionEntry));
3078 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3079 /* / Send Stop BSS response to host */
3080 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3081 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3082 smetransactionId);
3083 return;
3084 }
3085
3086 if (LIM_IS_AP_ROLE(psessionEntry))
3087 lim_wpspbc_close(pMac, psessionEntry);
3088
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003089 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003090 stopBssReq.reasonCode);
3091
3092 prevState = psessionEntry->limSmeState;
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303093 psessionEntry->limPrevSmeState = prevState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003094
3095 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3096 MTRACE(mac_trace
3097 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3098 psessionEntry->limSmeState));
3099
3100 /* Update SME session Id and Transaction Id */
3101 psessionEntry->smeSessionId = smesessionId;
3102 psessionEntry->transactionId = smetransactionId;
3103
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003104 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3105 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3106 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003107 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003108
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003109 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3110 /* Send disassoc all stations associated thru TKIP */
3111 __lim_counter_measures(pMac, psessionEntry);
3112 else
3113 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003114 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3115 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003116 }
3117
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003118 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3119 /* Free the buffer allocated in START_BSS_REQ */
3120 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3121 psessionEntry->addIeParams.probeRespDataLen = 0;
3122 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003123
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003124 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3125 psessionEntry->addIeParams.assocRespDataLen = 0;
3126 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003127
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003128 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3129 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3130 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003131
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003132 /*
3133 * lim_del_bss is also called as part of coalescing,
3134 * when we send DEL BSS followed by Add Bss msg.
3135 */
3136 pMac->lim.gLimIbssCoalescingHappened = false;
3137 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003138
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303139 lim_delete_peers_and_send_vdev_stop(psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003140
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003141}
3142
3143/**
3144 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3145 * @pMac: Global MAC context
3146 * @pMsg: Message from SME
3147 *
3148 * Wrapper for the function __lim_handle_sme_stop_bss_request
3149 * This message will be defered until softmac come out of
3150 * scan mode. Message should be handled even if we have
3151 * detected radar in the current operating channel.
3152 *
3153 * Return: true - If we consumed the buffer
3154 * false - If have defered the message.
3155 */
3156
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003157static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3158 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003159{
3160 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3161 /**
3162 * If message defered, buffer is not consumed yet.
3163 * So return false
3164 */
3165 return false;
3166 }
3167 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3168 return true;
3169} /*** end __lim_process_sme_stop_bss_req() ***/
3170
3171void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3172 uint32_t body, tpPESession psessionEntry)
3173{
3174
3175 (void)body;
3176 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3177 lim_ibss_delete(pMac, psessionEntry);
3178 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3179 lim_delete_pre_auth_list(pMac);
3180 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3181 psessionEntry->smeSessionId,
3182 psessionEntry->transactionId);
3183 return;
3184}
3185
3186/**
3187 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3188 *
3189 * @mac_ctx: pointer to mac context
3190 * @msg_type: message type
3191 * @msg_buf: pointer to the SME message buffer
3192 *
3193 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3194 * in BTAMP AP.
3195 *
3196 * Return: None
3197 */
3198
3199void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3200 uint32_t *msg_buf)
3201{
3202 tSirSmeAssocCnf assoc_cnf;
3203 tpDphHashNode sta_ds = NULL;
3204 tpPESession session_entry = NULL;
3205 uint8_t session_id;
3206 tpSirAssocReq assoc_req;
3207
3208 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003209 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003210 goto end;
3211 }
3212
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303213 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003214 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003215 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003216 goto end;
3217 }
3218
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003219 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003220 &session_id);
3221 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003222 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003223 goto end;
3224 }
3225
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003226 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003227 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3228 (session_entry->limSmeState !=
3229 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003230 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003231 msg_type, session_entry->limSmeState,
3232 GET_LIM_SYSTEM_ROLE(session_entry));
3233 goto end;
3234 }
3235 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3236 &session_entry->dph.dphHashTable);
3237 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003238 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003239 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303240 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003241
3242 /*
3243 * send a DISASSOC_IND message to WSM to make sure
3244 * the state in WSM and LIM is the same
3245 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003246 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003247 eSIR_SME_STA_NOT_ASSOCIATED,
3248 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3249 session_entry->smeSessionId,
3250 session_entry->transactionId,
3251 session_entry);
3252 goto end;
3253 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303254 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003255 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303256 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003257 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003258 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303259 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003260 goto end;
3261 }
3262
3263 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3264 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3265 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3266 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3267 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003268 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3269 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003270 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303271 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003272 goto end;
3273 }
3274 /*
3275 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3276 * has been received
3277 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003278 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3280 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3281
3282 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3283 /*
3284 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3285 * when it had received Assoc Request frame. Now, PE just needs
3286 * to send association rsp frame to the requesting BTAMP-STA.
3287 */
3288 sta_ds->mlmStaContext.mlmState =
3289 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003290 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003291 sta_ds->assocId);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003292 lim_send_assoc_rsp_mgmt_frame(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003293 sta_ds->assocId, sta_ds->staAddr,
3294 sta_ds->mlmStaContext.subType, sta_ds,
3295 session_entry);
3296 goto end;
3297 } else {
3298 /*
3299 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3300 * to be associated since the HAL sta entry is created for
3301 * denied STA we need to remove this HAL entry.
3302 * So to do that set updateContext to 1
3303 */
3304 if (!sta_ds->mlmStaContext.updateContext)
3305 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003306 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003307 assoc_cnf.statusCode, sta_ds->assocId);
3308 lim_reject_association(mac_ctx, sta_ds->staAddr,
3309 sta_ds->mlmStaContext.subType,
3310 true, sta_ds->mlmStaContext.authType,
3311 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003312 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003313 session_entry);
3314 }
3315end:
3316 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3317 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3318 assoc_req = (tpSirAssocReq)
3319 session_entry->parsedAssocReq[sta_ds->assocId];
3320 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303321 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003322 assoc_req->assocReqFrame = NULL;
3323 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303324 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003325 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3326 }
3327}
3328
3329static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3330{
3331 tpDphHashNode pStaDs;
3332 tSirMacAddr peerMac;
3333 tpSirAddtsReq pSirAddts;
3334 uint32_t timeout;
3335 tpPESession psessionEntry;
3336 uint8_t sessionId; /* PE sessionId */
3337 uint8_t smesessionId;
3338 uint16_t smetransactionId;
3339
3340 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003341 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003342 return;
3343 }
3344
3345 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3346 &smetransactionId);
3347
3348 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3349
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003350 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3351 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003352 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003353 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003354 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303355 NULL, pSirAddts->req.tspec,
3356 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003357 return;
3358 }
3359#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3360 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3361 0);
3362#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3363
3364 /* if sta
3365 * - verify assoc state
3366 * - send addts request to ap
3367 * - wait for addts response from ap
3368 * if ap, just ignore with error log
3369 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003370 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3371 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3372 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003373
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003374 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003375 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303376 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003377 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003378
3379 pStaDs =
3380 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3381 &psessionEntry->dph.dphHashTable);
3382
3383 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003384 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303385 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003386 }
3387
3388 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3389 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003390 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303391 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003392 }
3393
3394 pSirAddts->req.wsmTspecPresent = 0;
3395 pSirAddts->req.wmeTspecPresent = 0;
3396 pSirAddts->req.lleTspecPresent = 0;
3397
3398 if ((pStaDs->wsmEnabled) &&
3399 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3400 SIR_MAC_ACCESSPOLICY_EDCA))
3401 pSirAddts->req.wsmTspecPresent = 1;
3402 else if (pStaDs->wmeEnabled)
3403 pSirAddts->req.wmeTspecPresent = 1;
3404 else if (pStaDs->lleEnabled)
3405 pSirAddts->req.lleTspecPresent = 1;
3406 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003407 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303408 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003409 }
3410
3411 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3412 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003413 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003414 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303415 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003416 }
3417
3418 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003419 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003420 pMac->lim.gLimAddtsReq.req.dialogToken,
3421 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3422 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3423 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303424 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003425 }
3426
3427 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3428
3429 /* save the addts request */
3430 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303431 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003432 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3433
3434 /* ship out the message now */
3435 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3436 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303437 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003438 /* start a timer to wait for the response */
3439 if (pSirAddts->timeout)
3440 timeout = pSirAddts->timeout;
Arif Hussain43e09712018-09-18 19:31:57 -07003441 else
3442 timeout = pMac->mlme_cfg->timeouts.addts_rsp_timeout;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003443
3444 timeout = SYS_MS_TO_TICKS(timeout);
3445 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3446 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003447 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303448 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003449 }
3450 pMac->lim.gLimAddtsRspTimerCount++;
3451 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3452 pMac->lim.gLimAddtsRspTimerCount) !=
3453 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003454 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303455 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003456 }
3457 MTRACE(mac_trace
3458 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3459 eLIM_ADDTS_RSP_TIMER));
3460
3461 /* add the sessionId to the timer object */
3462 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3463 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3464 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003465 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303466 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003467 }
3468 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303469
3470send_failure_addts_rsp:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003471 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303472 psessionEntry, pSirAddts->req.tspec,
3473 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003474}
3475
3476static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3477{
3478 tSirMacAddr peerMacAddr;
3479 uint8_t ac;
3480 tSirMacTSInfo *pTsinfo;
3481 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3482 tpDphHashNode pStaDs = NULL;
3483 tpPESession psessionEntry;
3484 uint8_t sessionId;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003485 uint32_t status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003486 uint8_t smesessionId;
3487 uint16_t smetransactionId;
3488
3489 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3490 &smetransactionId);
3491
3492 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003493 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003494 &sessionId);
3495 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003496 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003497 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003498 goto end;
3499 }
3500#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3501 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3502 0);
3503#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3504
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003505 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003506 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003507 pe_err("lim_validate_delts_req failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003508 status = QDF_STATUS_E_FAILURE;
3509 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_E_FAILURE, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003510 smesessionId, smetransactionId);
3511 return;
3512 }
3513
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003514 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3515 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003516 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3517
3518 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3519 pDeltsReq->req.wmeTspecPresent,
3520 &pDeltsReq->req.tsinfo,
3521 &pDeltsReq->req.tspec, psessionEntry);
3522
3523 pTsinfo =
3524 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3525 tsinfo : &pDeltsReq->req.tsinfo;
3526
3527 /* We've successfully send DELTS frame to AP. Update the
3528 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3529 * is no longer trigger enabled or delivery enabled
3530 */
3531 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3532 pTsinfo, CLEAR_UAPSD_MASK);
3533
3534 /* We're deleting the TSPEC, so this particular AC is no longer
3535 * admitted. PE needs to downgrade the EDCA
3536 * parameters(for the AC for which TS is being deleted) to the
3537 * next best AC for which ACM is not enabled, and send the
3538 * updated values to HAL.
3539 */
3540 ac = upToAc(pTsinfo->traffic.userPrio);
3541
3542 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3543 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3544 ~(1 << ac);
3545 } else if (pTsinfo->traffic.direction ==
3546 SIR_MAC_DIRECTION_DNLINK) {
3547 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3548 ~(1 << ac);
3549 } else if (pTsinfo->traffic.direction ==
3550 SIR_MAC_DIRECTION_BIDIR) {
3551 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3552 ~(1 << ac);
3553 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3554 ~(1 << ac);
3555 }
3556
3557 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3558 psessionEntry);
3559
3560 pStaDs =
3561 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3562 &psessionEntry->dph.dphHashTable);
3563 if (pStaDs != NULL) {
3564 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003565 pStaDs->bssId, false);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003566 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003567 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003568 pe_err("Self entry missing in Hash Table");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003569 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003570 }
3571#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003572 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003573#endif
3574
3575 /* send an sme response back */
3576end:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003577 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_SUCCESS, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003578 smesessionId, smetransactionId);
3579}
3580
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303581void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003582{
3583 /* fetch the sessionEntry based on the sessionId */
3584 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003585
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586 psessionEntry = pe_find_session_by_session_id(pMac,
3587 pMac->lim.limTimers.gLimAddtsRspTimer.
3588 sessionId);
3589 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003590 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003591 return;
3592 }
3593
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003594 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003595 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003596 GET_LIM_SYSTEM_ROLE(psessionEntry));
3597 pMac->lim.gLimAddtsSent = false;
3598 return;
3599 }
3600
3601 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003602 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003603 return;
3604 }
3605
3606 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003607 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003608 pMac->lim.gLimAddtsRspTimerCount);
3609 return;
3610 }
3611 /* this a real response timeout */
3612 pMac->lim.gLimAddtsSent = false;
3613 pMac->lim.gLimAddtsRspTimerCount++;
3614
3615 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3616 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3617 psessionEntry->smeSessionId,
3618 psessionEntry->transactionId);
3619}
3620
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003621#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003622/**
3623 * __lim_process_sme_get_statistics_request()
3624 *
3625 ***FUNCTION:
3626 *
3627 *
3628 ***NOTE:
3629 *
3630 * @param pMac Pointer to Global MAC structure
3631 * @param *pMsgBuf A pointer to the SME message buffer
3632 * @return None
3633 */
3634static void
3635__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3636{
3637 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003638 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003639
3640 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3641
3642 msgQ.type = WMA_GET_STATISTICS_REQ;
3643
3644 msgQ.reserved = 0;
3645 msgQ.bodyptr = pMsgBuf;
3646 msgQ.bodyval = 0;
3647 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3648
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003649 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303650 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003651 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003652 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003653 return;
3654 }
3655
3656 return;
3657}
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003658#else
3659static void __lim_process_sme_get_statistics_request(
3660 struct sAniSirGlobal *mac_ctx, uint32_t *pMsgBuf) {}
3661#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003662
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003663#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003664/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003665 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003667 * @pMac: Pointer to Global MAC structure
3668 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003669 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003670 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003671 */
3672static void
3673__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3674{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003675 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003676
3677 msgQ.type = WMA_TSM_STATS_REQ;
3678 msgQ.reserved = 0;
3679 msgQ.bodyptr = pMsgBuf;
3680 msgQ.bodyval = 0;
3681 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3682
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003683 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303684 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003685 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003686 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003687 return;
3688 }
3689}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003690#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003691
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08003692static void lim_process_sme_set_addba_accept(tpAniSirGlobal mac_ctx,
3693 struct sme_addba_accept *msg)
3694{
3695 if (!msg) {
3696 pe_err("Msg Buffer is NULL");
3697 return;
3698 }
3699 if (!msg->addba_accept)
3700 mac_ctx->reject_addba_req = 1;
3701 else
3702 mac_ctx->reject_addba_req = 0;
3703}
3704
Arif Hussaineb8ba362018-03-07 19:15:13 -08003705static void lim_process_sme_update_edca_params(tpAniSirGlobal mac_ctx,
3706 uint32_t sme_session_id)
3707{
3708 tpPESession pe_session;
3709 tpDphHashNode sta_ds_ptr;
3710
3711 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3712 if (!pe_session) {
3713 pe_err("Session does not exist: sme_id %d", sme_session_id);
3714 return;
3715 }
3716 pe_session->gLimEdcaParamsActive[EDCA_AC_BE].no_ack =
3717 mac_ctx->no_ack_policy_cfg[EDCA_AC_BE];
3718 pe_session->gLimEdcaParamsActive[EDCA_AC_BK].no_ack =
3719 mac_ctx->no_ack_policy_cfg[EDCA_AC_BK];
3720 pe_session->gLimEdcaParamsActive[EDCA_AC_VI].no_ack =
3721 mac_ctx->no_ack_policy_cfg[EDCA_AC_VI];
3722 pe_session->gLimEdcaParamsActive[EDCA_AC_VO].no_ack =
3723 mac_ctx->no_ack_policy_cfg[EDCA_AC_VO];
3724 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3725 &pe_session->dph.dphHashTable);
3726 if (sta_ds_ptr)
3727 lim_send_edca_params(mac_ctx,
3728 pe_session->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003729 sta_ds_ptr->bssId, false);
Arif Hussaineb8ba362018-03-07 19:15:13 -08003730 else
3731 pe_err("Self entry missing in Hash Table");
3732}
3733
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07003734static void lim_process_sme_update_mu_edca_params(tpAniSirGlobal mac_ctx,
3735 uint32_t sme_session_id)
3736{
3737 tpPESession pe_session;
3738 tpDphHashNode sta_ds_ptr;
3739
3740 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3741 if (!pe_session) {
3742 pe_err("Session does not exist: sme_id %d", sme_session_id);
3743 return;
3744 }
3745 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3746 &pe_session->dph.dphHashTable);
3747 if (sta_ds_ptr)
3748 lim_send_edca_params(mac_ctx, mac_ctx->usr_mu_edca_params,
3749 sta_ds_ptr->bssId, true);
3750 else
3751 pe_err("Self entry missing in Hash Table");
3752}
3753
Naveen Rawat8029a402017-06-01 10:54:19 -07003754static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3755 struct update_config *msg)
3756{
3757 tpPESession pe_session;
3758
3759 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3760 if (msg == NULL) {
3761 pe_err("Buffer is Pointing to NULL");
3762 return;
3763 }
3764
3765 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3766 msg->sme_session_id);
3767 if (pe_session == NULL) {
3768 pe_warn("Session does not exist for given BSSID");
3769 return;
3770 }
3771
3772 switch (msg->capab) {
3773 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3774 pe_session->htConfig.ht_rx_ldpc = msg->value;
3775 break;
3776 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3777 pe_session->htConfig.ht_tx_stbc = msg->value;
3778 break;
3779 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3780 pe_session->htConfig.ht_rx_stbc = msg->value;
3781 break;
3782 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3783 pe_session->htConfig.ht_sgi20 = msg->value;
3784 break;
3785 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3786 pe_session->htConfig.ht_sgi40 = msg->value;
3787 break;
3788 }
3789
3790 if (LIM_IS_AP_ROLE(pe_session)) {
3791 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3792 lim_send_beacon_ind(mac_ctx, pe_session);
3793 }
3794}
3795
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003796void
3797lim_send_vdev_restart(tpAniSirGlobal pMac,
3798 tpPESession psessionEntry, uint8_t sessionId)
3799{
3800 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003801 struct scheduler_msg msgQ = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003802 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003803
3804 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003805 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003806 return;
3807 }
3808
3809 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303810 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003811 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003812 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003813 return;
3814 }
3815
3816 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3817 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003818 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003819
3820 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3821 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3822 msgQ.bodyval = 0;
3823
3824 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003825 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003826 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303827 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003828 }
3829}
3830
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303831/**
3832 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3833 * @mac_ctx: Pointer to Global MAC structure
3834 * @msg_buf: Pointer to SME message buffer
3835 *
3836 * Return: None
3837 */
3838static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3839 uint32_t *msg_buf)
3840{
3841 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003842 struct scheduler_msg wma_msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003843 QDF_STATUS status;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303844 tSirRoamOffloadScanReq *req_buffer;
3845 uint16_t local_ie_len;
3846 uint8_t *local_ie_buf;
3847
3848 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3849 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3850 req_buffer->sessionId);
3851
3852 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3853 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003854 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303855 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303856 return;
3857 }
3858
3859 local_ie_len = req_buffer->assoc_ie.length;
3860 /* Update ext cap IE if present */
3861 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003862 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3863 local_ie_buf, &local_ie_len)) {
3864 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003865 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3866 req_buffer->assoc_ie.length = local_ie_len;
3867 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3868 local_ie_buf, local_ie_len);
3869 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303870 }
3871 qdf_mem_free(local_ie_buf);
3872
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303873 if (pe_session)
3874 lim_update_fils_rik(pe_session, req_buffer);
3875
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303876 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3877 wma_msg.bodyptr = req_buffer;
3878
3879 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003880 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003881 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303882 qdf_mem_free(req_buffer);
3883 }
3884}
3885
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303886/*
3887 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3888 * @mac_ctx: Pointer to global mac context
3889 * @session: Pointer to PE session
3890 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3891 * 1 - Disable broadcast SSID
3892 *
3893 * Return: None
3894 */
3895static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3896 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003897{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003898 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003899 session->ssidHidden, ssid_hidden);
3900
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003901 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303902 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003903 } else {
3904 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05303905 return;
3906 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003907
Abhishek Singh6c681f42018-09-12 15:52:36 +05303908#ifdef CONFIG_VDEV_SM
3909 ap_mlme_set_hidden_ssid_restart_in_progress(session->vdev, true);
3910 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3911 WLAN_VDEV_SM_EV_FW_VDEV_RESTART,
3912 sizeof(*session), session);
3913#else
3914
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003915 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303916 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Abhishek Singh6c681f42018-09-12 15:52:36 +05303917#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003918
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003919 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303920}
3921
3922/**
3923 * __lim_process_sme_session_update - process SME session update msg
3924 *
3925 * @mac_ctx: Pointer to global mac context
3926 * @msg_buf: Pointer to the received message buffer
3927 *
3928 * Return: None
3929 */
3930static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
3931 uint32_t *msg_buf)
3932{
3933 struct sir_update_session_param *msg;
3934 tpPESession session;
3935
3936 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003937 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303938 return;
3939 }
3940
3941 msg = (struct sir_update_session_param *) msg_buf;
3942
3943 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
3944 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003945 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303946 msg->session_id);
3947 return;
3948 }
3949
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003950 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303951 msg->param_type, msg->param_val);
3952 switch (msg->param_type) {
3953 case SIR_PARAM_SSID_HIDDEN:
3954 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
3955 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303956 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
3957 session->ignore_assoc_disallowed = msg->param_val;
3958 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303959 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003960 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303961 break;
3962 }
3963}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003964
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003965/*
3966 Update the beacon Interval dynamically if beaconInterval is different in MCC
3967 */
3968static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3969{
3970 tpSirChangeBIParams pChangeBIParams;
3971 tpPESession psessionEntry;
3972 uint8_t sessionId = 0;
3973 tUpdateBeaconParams beaconParams;
3974
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003975 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003976
3977 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003978 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003979 return;
3980 }
3981
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303982 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003983 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
3984
3985 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08003986 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003987 &sessionId);
3988 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003989 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003990 return;
3991 }
3992
3993 /*Update sessionEntry Beacon Interval */
3994 if (psessionEntry->beaconParams.beaconInterval !=
3995 pChangeBIParams->beaconInterval) {
3996 psessionEntry->beaconParams.beaconInterval =
3997 pChangeBIParams->beaconInterval;
3998 }
3999
4000 /*Update sch beaconInterval */
4001 if (pMac->sch.schObject.gSchBeaconInterval !=
4002 pChangeBIParams->beaconInterval) {
4003 pMac->sch.schObject.gSchBeaconInterval =
4004 pChangeBIParams->beaconInterval;
4005
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004006 pe_debug("LIM send update BeaconInterval Indication: %d",
4007 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004008
4009 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4010 /* Update beacon */
4011 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4012
4013 beaconParams.bssIdx = psessionEntry->bssIdx;
4014 /* Set change in beacon Interval */
4015 beaconParams.beaconInterval =
4016 pChangeBIParams->beaconInterval;
4017 beaconParams.paramChangeBitmap =
4018 PARAM_BCN_INTERVAL_CHANGED;
4019 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4020 }
4021 }
4022
4023 return;
4024} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4025
4026#ifdef QCA_HT_2040_COEX
4027static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4028 uint32_t *pMsgBuf)
4029{
4030 tpSirSetHT2040Mode pSetHT2040Mode;
4031 tpPESession psessionEntry;
4032 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004033 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004034 tUpdateVHTOpMode *pHtOpMode = NULL;
4035 uint16_t staId = 0;
4036 tpDphHashNode pStaDs = NULL;
4037
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004038 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004039 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004040 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004041 return;
4042 }
4043
4044 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4045
4046 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004047 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004048 &sessionId);
4049 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004050 pe_debug("Session does not exist for given BSSID");
4051 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004052 return;
4053 }
4054
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004055 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004056 pSetHT2040Mode->cbMode);
4057 /*Update sessionEntry HT related fields */
4058 switch (pSetHT2040Mode->cbMode) {
4059 case PHY_SINGLE_CHANNEL_CENTERED:
4060 psessionEntry->htSecondaryChannelOffset =
4061 PHY_SINGLE_CHANNEL_CENTERED;
4062 psessionEntry->htRecommendedTxWidthSet = 0;
4063 if (pSetHT2040Mode->obssEnabled)
4064 psessionEntry->htSupportedChannelWidthSet
4065 = eHT_CHANNEL_WIDTH_40MHZ;
4066 else
4067 psessionEntry->htSupportedChannelWidthSet
4068 = eHT_CHANNEL_WIDTH_20MHZ;
4069 break;
4070 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4071 psessionEntry->htSecondaryChannelOffset =
4072 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4073 psessionEntry->htRecommendedTxWidthSet = 1;
4074 break;
4075 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4076 psessionEntry->htSecondaryChannelOffset =
4077 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4078 psessionEntry->htRecommendedTxWidthSet = 1;
4079 break;
4080 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004081 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004082 return;
4083 }
4084
4085 /* Update beacon */
4086 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4087 lim_send_beacon_ind(pMac, psessionEntry);
4088
4089 /* update OP Mode for each associated peer */
4090 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4091 pStaDs = dph_get_hash_entry(pMac, staId,
4092 &psessionEntry->dph.dphHashTable);
4093 if (NULL == pStaDs)
4094 continue;
4095
4096 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304097 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004098 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004099 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004100 return;
4101 }
4102 pHtOpMode->opMode =
4103 (psessionEntry->htSecondaryChannelOffset ==
4104 PHY_SINGLE_CHANNEL_CENTERED) ?
4105 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4106 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304107 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004108 sizeof(tSirMacAddr));
4109 pHtOpMode->smesessionId = sessionId;
4110
4111 msg.type = WMA_UPDATE_OP_MODE;
4112 msg.reserved = 0;
4113 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004114 if (!QDF_IS_STATUS_SUCCESS
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05304115 (scheduler_post_message(QDF_MODULE_ID_PE,
4116 QDF_MODULE_ID_WMA,
4117 QDF_MODULE_ID_WMA,
4118 &msg))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004119 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304120 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004121 return;
4122 }
Jeff Johnson47d75242018-05-12 15:58:53 -07004123 pe_debug("Notified FW about OP mode: %d for staId=%d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004124 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004125
4126 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004127 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004128 }
4129
4130 return;
4131}
4132#endif
4133
4134/* -------------------------------------------------------------------- */
4135/**
4136 * __lim_process_report_message
4137 *
4138 * FUNCTION: Processes the next received Radio Resource Management message
4139 *
4140 * LOGIC:
4141 *
4142 * ASSUMPTIONS:
4143 *
4144 * NOTE:
4145 *
4146 * @param None
4147 * @return None
4148 */
4149
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004150static void __lim_process_report_message(tpAniSirGlobal pMac,
4151 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004152{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004153 switch (pMsg->type) {
4154 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4155 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4156 break;
4157 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004158 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004159 break;
4160 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004161 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004162 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004163}
4164
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004165/* -------------------------------------------------------------------- */
4166/**
4167 * lim_send_set_max_tx_power_req
4168 *
4169 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4170 *
4171 * LOGIC:
4172 *
4173 * ASSUMPTIONS:
4174 *
4175 * NOTE:
4176 *
4177 * @param txPower txPower to be set.
4178 * @param pSessionEntry session entry.
4179 * @return None
4180 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004181QDF_STATUS
Amar Singhala297bfa2015-10-15 15:07:29 -07004182lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004183 tpPESession pSessionEntry)
4184{
4185 tpMaxTxPowerParams pMaxTxParams = NULL;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004186 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004187 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004188
4189 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004190 pe_err("Invalid parameters");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004191 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004192 }
4193
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304194 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004195 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004196 pe_err("Unable to allocate memory for pMaxTxParams");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004197 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004198
4199 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004200 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304201 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304202 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304203 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004204 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304205 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004206
4207 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4208 msgQ.bodyptr = pMaxTxParams;
4209 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004210 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004211 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4212 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004213 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004214 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304215 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004216 }
4217 return retCode;
4218}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004219
4220/**
4221 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4222 *
4223 * @mac_ctx: Pointer to Global MAC structure
4224 * @msg_buf: pointer to the SME message buffer
4225 *
4226 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4227 * from SME. It Register this information within PE.
4228 *
4229 * Return: None
4230 */
4231static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4232 uint32_t *msg_buf)
4233{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304234 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004235 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4236 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4237 struct mgmt_frm_reg_info *next = NULL;
4238 bool match = false;
4239
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004240 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004241 sme_req->registerFrame, sme_req->frameType,
4242 sme_req->matchLen);
4243 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304244 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304245 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4246 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304247 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004248
4249 while (lim_mgmt_regn != NULL) {
4250 if (lim_mgmt_regn->frameType != sme_req->frameType)
4251 goto skip_match;
4252 if (sme_req->matchLen) {
4253 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304254 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004255 sme_req->matchData,
4256 lim_mgmt_regn->matchLen))) {
4257 /* found match! */
4258 match = true;
4259 break;
4260 }
4261 } else {
4262 /* found match! */
4263 match = true;
4264 break;
4265 }
4266skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304267 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304268 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004269 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304270 (qdf_list_node_t *)lim_mgmt_regn,
4271 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304272 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004273 lim_mgmt_regn = next;
4274 next = NULL;
4275 }
4276 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304277 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004278 if (QDF_STATUS_SUCCESS ==
4279 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004280 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004281 (qdf_list_node_t *)lim_mgmt_regn))
4282 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304283 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004284 }
4285
4286 if (sme_req->registerFrame) {
4287 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304288 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004289 sme_req->matchLen);
4290 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004291 lim_mgmt_regn->frameType = sme_req->frameType;
4292 lim_mgmt_regn->matchLen = sme_req->matchLen;
4293 lim_mgmt_regn->sessionId = sme_req->sessionId;
4294 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304295 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004296 sme_req->matchData,
4297 sme_req->matchLen);
4298 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304299 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004300 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304301 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004302 gLimMgmtFrameRegistratinQueue,
4303 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304304 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004305 &mac_ctx->lim.lim_frame_register_lock);
4306 }
4307 }
4308 return;
4309}
4310
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004311static void
4312__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4313{
4314 tpSirResetAPCapsChange pResetCapsChange;
4315 tpPESession psessionEntry;
4316 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004317
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004318 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004319 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004320 return;
4321 }
4322
4323 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4324 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004325 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4326 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004327 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004328 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004329 return;
4330 }
4331
4332 psessionEntry->limSentCapsChangeNtf = false;
4333 return;
4334}
4335
4336/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304337 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4338 * indication callback in PE.
4339 * @mac_ptr: Mac pointer
4340 * @msg_buf: Msg pointer containing the callback
4341 *
4342 * This function is used save the Management frame
4343 * indication callback in PE.
4344 *
4345 * Return: None
4346 */
4347static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4348 uint32_t *msg_buf)
4349{
4350 struct sir_sme_mgmt_frame_cb_req *sme_req =
4351 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4352
4353 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004354 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304355 return;
4356 }
4357 if (sme_req->callback)
4358 mac_ctx->mgmt_frame_ind_cb =
4359 (sir_mgmt_frame_ind_callback)sme_req->callback;
4360 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004361 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304362}
4363
4364/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304365 *__lim_process_send_disassoc_frame: function processes disassoc frame
4366 * @mac_ctx: pointer to mac context
4367 * @msg_buf: message buffer
4368 *
4369 * function processes disassoc request received from SME
4370 *
4371 * return: none
4372 */
4373static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4374 uint32_t *msg_buf)
4375{
4376 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004377 QDF_STATUS status;
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304378 tpPESession session_entry = NULL;
4379 uint8_t sme_session_id;
4380 uint16_t sme_trans_id;
4381
4382 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004383 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304384 return;
4385 }
4386
4387 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4388 &sme_trans_id);
4389
4390 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4391 &sme_send_disassoc_frame_req,
4392 (uint8_t *)msg_buf);
4393
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004394 if ((QDF_STATUS_E_FAILURE == status) ||
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304395 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4396 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004397 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304398 return;
4399 }
4400
4401 session_entry = pe_find_session_by_sme_session_id(
4402 mac_ctx, sme_session_id);
4403 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004404 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304405 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4406 return;
4407 }
4408
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004409 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 +05304410 sme_send_disassoc_frame_req.msg_type,
4411 sme_send_disassoc_frame_req.length,
4412 sme_send_disassoc_frame_req.session_id,
4413 sme_send_disassoc_frame_req.trans_id,
4414 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4415 sme_send_disassoc_frame_req.reason,
4416 sme_send_disassoc_frame_req.wait_for_ack);
4417
4418 lim_send_disassoc_mgmt_frame(mac_ctx,
4419 sme_send_disassoc_frame_req.reason,
4420 sme_send_disassoc_frame_req.peer_mac,
4421 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4422}
4423
4424/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004425 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4426 * @mac_ctx: Pointer to Global MAC structure
4427 * @pdev_id: pdev id to set the IE.
4428 * @nss: Nss values to prepare the HT IE.
4429 *
4430 * Prepares the HT IE with self capabilities for different
4431 * Nss values and sends the set HT IE req to FW.
4432 *
4433 * Return: None
4434 */
4435static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4436 uint8_t nss)
4437{
4438 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004439 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004440 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004441 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004442 tHtCaps *p_ht_cap;
4443 int i;
4444
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004445 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004446 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4447 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004448 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004449 return;
4450 }
4451 ie_params->nss = i;
4452 ie_params->pdev_id = pdev_id;
4453 ie_params->ie_type = DOT11_HT_IE;
4454 /* 2 for IE len and EID */
4455 ie_params->ie_len = 2 + sizeof(tHtCaps);
4456 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4457 if (NULL == ie_params->ie_ptr) {
4458 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004459 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004460 return;
4461 }
4462 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4463 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4464 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4465 ie_params->ie_len);
4466
4467 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004468 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4469 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004470 if (NULL == p_ie) {
4471 qdf_mem_free(ie_params->ie_ptr);
4472 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004473 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004474 return;
4475 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004476 p_ht_cap = (tHtCaps *)&p_ie[2];
4477 p_ht_cap->supportedMCSSet[1] = 0;
4478 p_ht_cap->txSTBC = 0;
4479 }
4480
4481 msg.type = WMA_SET_PDEV_IE_REQ;
4482 msg.bodyptr = ie_params;
4483 msg.bodyval = 0;
4484
4485 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004486 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004487 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004488 qdf_mem_free(ie_params->ie_ptr);
4489 qdf_mem_free(ie_params);
4490 return;
4491 }
4492 }
4493}
4494
4495/**
4496 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4497 * @mac_ctx: Pointer to Global MAC structure
4498 * @pdev_id: pdev id to set the IE.
4499 * @nss: Nss values to prepare the VHT IE.
4500 *
4501 * Prepares the VHT IE with self capabilities for different
4502 * Nss values and sends the set VHT IE req to FW.
4503 *
4504 * Return: None
4505 */
4506static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4507 uint8_t nss)
4508{
4509 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004510 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004511 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004512 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004513 tSirMacVHTCapabilityInfo *vht_cap;
4514 int i;
4515 tSirVhtMcsInfo *vht_mcs;
4516
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004517 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004518 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4519 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004520 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004521 return;
4522 }
4523 ie_params->nss = i;
4524 ie_params->pdev_id = pdev_id;
4525 ie_params->ie_type = DOT11_VHT_IE;
4526 /* 2 for IE len and EID */
4527 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4528 sizeof(tSirVhtMcsInfo);
4529 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4530 if (NULL == ie_params->ie_ptr) {
4531 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004532 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004533 return;
4534 }
4535 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4536 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4537 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4538 ie_params->ie_len);
4539
4540 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004541 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4542 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004543 if (NULL == p_ie) {
4544 qdf_mem_free(ie_params->ie_ptr);
4545 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004546 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004547 return;
4548 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004549 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4550 vht_cap->txSTBC = 0;
4551 vht_mcs =
4552 (tSirVhtMcsInfo *)&p_ie[2 +
4553 sizeof(tSirMacVHTCapabilityInfo)];
4554 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4555 vht_mcs->rxHighest =
4556 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4557 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4558 vht_mcs->txHighest =
4559 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4560 }
4561 msg.type = WMA_SET_PDEV_IE_REQ;
4562 msg.bodyptr = ie_params;
4563 msg.bodyval = 0;
4564
4565 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004566 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004567 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004568 qdf_mem_free(ie_params->ie_ptr);
4569 qdf_mem_free(ie_params);
4570 return;
4571 }
4572 }
4573}
4574
4575/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004576 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4577 * @mac_ctx: Pointer to Global MAC structure
4578 * @msg_buf: Pointer to the SME message buffer
4579 *
4580 * This function is called by limProcessMessageQueue(). This function sets the
4581 * VDEV IEs to the FW.
4582 *
4583 * Return: None
4584 */
4585static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4586 uint32_t *msg_buf)
4587{
4588 struct sir_set_vdev_ies_per_band *p_msg =
4589 (struct sir_set_vdev_ies_per_band *)msg_buf;
4590
4591 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004592 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004593 return;
4594 }
4595
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004596 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004597 p_msg->vdev_id);
4598 /* intentionally using NULL here so that self capabilty are sent */
4599 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4600 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004601 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004602}
4603
4604/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004605 * lim_process_set_pdev_IEs() - process the set pdev IE req
4606 * @mac_ctx: Pointer to Global MAC structure
4607 * @msg_buf: Pointer to the SME message buffer
4608 *
4609 * This function is called by limProcessMessageQueue(). This
4610 * function sets the PDEV IEs to the FW.
4611 *
4612 * Return: None
4613 */
4614static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4615{
4616 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4617
4618 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4619
4620 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004621 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004622 return;
4623 }
4624
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004625 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004626 ht_vht_cfg->nss);
4627 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4628
4629 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4630 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4631 ht_vht_cfg->nss);
4632}
4633
4634/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304635 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4636 *
4637 * access policy
4638 * @mac_ctx: pointer to mac context
4639 * @msg: message buffer
4640 *
4641 * function processes vendor IE and access policy from SME and updates PE
4642 *
4643 * session entry
4644 *
4645 * return: none
4646*/
4647static void lim_process_sme_update_access_policy_vendor_ie(
4648 tpAniSirGlobal mac_ctx,
4649 uint32_t *msg)
4650{
4651 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4652 struct sPESession *pe_session_entry;
Pragaspathi Thilagaraj9b7a1162018-05-07 16:28:13 +05304653 uint16_t num_bytes;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304654
4655 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004656 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304657 return;
4658 }
4659 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4660 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4661 update_vendor_ie->sme_session_id);
4662
4663 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004664 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304665 update_vendor_ie->sme_session_id);
4666 return;
4667 }
4668 if (pe_session_entry->access_policy_vendor_ie)
4669 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4670
4671 num_bytes = update_vendor_ie->ie[1] + 2;
4672 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4673
4674 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004675 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304676 return;
4677 }
4678 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4679 &update_vendor_ie->ie[0], num_bytes);
4680
4681 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4682}
4683
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004684#ifdef CONFIG_VDEV_SM
4685QDF_STATUS lim_sta_mlme_vdev_disconnect_bss(struct vdev_mlme_obj *vdev_mlme,
4686 uint16_t data_len, void *data)
4687{
4688 tpAniSirGlobal mac_ctx;
4689 struct scheduler_msg *msg = (struct scheduler_msg *)data;
4690
4691 mac_ctx = cds_get_context(QDF_MODULE_ID_PE);
4692 if (!mac_ctx) {
4693 pe_err("mac_ctx is NULL");
4694 if (data)
4695 qdf_mem_free(data);
4696 return QDF_STATUS_E_INVAL;
4697 }
4698 pe_debug("VDEV Manager disconnect bss callback type:(%d)", msg->type);
4699
4700 switch (msg->type) {
4701 case eWNI_SME_DEAUTH_REQ:
4702 __lim_process_sme_deauth_req(mac_ctx,
4703 (uint32_t *)msg->bodyptr);
4704 break;
4705 case eWNI_SME_DISASSOC_CNF:
4706 case eWNI_SME_DEAUTH_CNF:
4707 __lim_process_sme_disassoc_cnf(mac_ctx,
4708 (uint32_t *)msg->bodyptr);
4709 break;
4710 case eWNI_SME_DISASSOC_REQ:
4711 __lim_process_sme_disassoc_req(mac_ctx,
4712 (uint32_t *)msg->bodyptr);
4713 break;
4714 default:
4715 pe_debug("Wrong message type received %d", msg->type);
4716 }
4717 return QDF_STATUS_SUCCESS;
4718}
4719#endif
4720
4721static void lim_process_sme_disassoc_cnf(tpAniSirGlobal mac_ctx,
4722 struct scheduler_msg *msg)
4723{
4724#ifdef CONFIG_VDEV_SM
4725 tSirSmeDisassocCnf sme_disassoc_cnf;
4726 tpPESession session;
4727 uint8_t session_id;
4728 QDF_STATUS status;
4729
4730 qdf_mem_copy(&sme_disassoc_cnf, msg->bodyptr,
4731 sizeof(struct sSirSmeDisassocCnf));
4732
4733 session = pe_find_session_by_bssid(mac_ctx,
4734 sme_disassoc_cnf.bssid.bytes,
4735 &session_id);
4736
4737 if (LIM_IS_STA_ROLE(session)) {
4738 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4739 WLAN_VDEV_SM_EV_DOWN,
4740 sizeof(*msg),
4741 msg);
4742 } else {
4743 __lim_process_sme_disassoc_cnf(mac_ctx,
4744 (uint32_t *)msg->bodyptr);
4745 }
4746#else
4747 __lim_process_sme_disassoc_cnf(mac_ctx, (uint32_t *)msg->bodyptr);
4748#endif
4749}
4750
4751static void lim_process_sme_disassoc_req(tpAniSirGlobal mac_ctx,
4752 struct scheduler_msg *msg)
4753{
4754#ifdef CONFIG_VDEV_SM
4755 tSirSmeDisassocReq disassoc_req;
4756 tpPESession session;
4757 uint8_t session_id;
4758 QDF_STATUS status;
4759
4760 qdf_mem_copy(&disassoc_req, msg->bodyptr, sizeof(tSirSmeDisassocReq));
4761
4762 session = pe_find_session_by_bssid(mac_ctx,
4763 disassoc_req.bssid.bytes,
4764 &session_id);
4765 if (LIM_IS_STA_ROLE(session)) {
4766 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4767 WLAN_VDEV_SM_EV_DOWN,
4768 sizeof(*msg),
4769 msg);
4770 } else {
4771 __lim_process_sme_disassoc_req(mac_ctx,
4772 (uint32_t *)msg->bodyptr);
4773 }
4774#else
4775 __lim_process_sme_disassoc_req(mac_ctx, (uint32_t *)msg->bodyptr);
4776#endif
4777}
4778
4779static void lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
4780 struct scheduler_msg *msg)
4781{
4782#ifdef CONFIG_VDEV_SM
4783 tSirSmeDeauthReq sme_deauth_req;
4784 tpPESession session;
4785 uint8_t session_id;
4786 QDF_STATUS status;
4787
4788 qdf_mem_copy(&sme_deauth_req, msg->bodyptr, sizeof(tSirSmeDeauthReq));
4789
4790 session = pe_find_session_by_bssid(mac_ctx,
4791 sme_deauth_req.bssid.bytes,
4792 &session_id);
4793 if (LIM_IS_STA_ROLE(session)) {
4794 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4795 WLAN_VDEV_SM_EV_DOWN,
4796 sizeof(*msg),
4797 msg);
4798 } else {
4799 __lim_process_sme_deauth_req(mac_ctx,
4800 (uint32_t *)msg->bodyptr);
4801 }
4802#else
4803 __lim_process_sme_deauth_req(mac_ctx, (uint32_t *)msg->bodyptr);
4804#endif
4805}
4806
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304807/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004808 * lim_process_sme_req_messages()
4809 *
4810 ***FUNCTION:
4811 * This function is called by limProcessMessageQueue(). This
4812 * function processes SME request messages from HDD or upper layer
4813 * application.
4814 *
4815 ***LOGIC:
4816 *
4817 ***ASSUMPTIONS:
4818 *
4819 ***NOTE:
4820 *
4821 * @param pMac Pointer to Global MAC structure
4822 * @param msgType Indicates the SME message type
4823 * @param *pMsgBuf A pointer to the SME message buffer
4824 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4825 * false - if pMsgBuf is not to be freed.
4826 */
4827
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004828bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4829 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004830{
Jeff Johnson33142e62018-05-06 17:58:36 -07004831 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 -08004832 uint32_t *pMsgBuf = pMsg->bodyptr;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004833
4834 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004835 lim_msg_str(pMsg->type), pMsg->type,
4836 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4837 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004838
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004839 /* If no insert NOA required then execute the code below */
4840
4841 switch (pMsg->type) {
4842 case eWNI_SME_SYS_READY_IND:
4843 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4844 break;
4845
4846 case eWNI_SME_START_BSS_REQ:
4847 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4848 break;
4849
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004850 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4851 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4852 break;
4853 case eWNI_SME_JOIN_REQ:
4854 __lim_process_sme_join_req(pMac, pMsgBuf);
4855 break;
4856
4857 case eWNI_SME_REASSOC_REQ:
4858 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4859 break;
4860
4861 case eWNI_SME_DISASSOC_REQ:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004862 lim_process_sme_disassoc_req(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004863 break;
4864
4865 case eWNI_SME_DISASSOC_CNF:
4866 case eWNI_SME_DEAUTH_CNF:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004867 lim_process_sme_disassoc_cnf(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004868 break;
4869
4870 case eWNI_SME_DEAUTH_REQ:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004871 lim_process_sme_deauth_req(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004872 break;
4873
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304874 case eWNI_SME_SEND_DISASSOC_FRAME:
4875 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4876 break;
4877
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004878 case eWNI_SME_SETCONTEXT_REQ:
4879 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4880 break;
4881
4882 case eWNI_SME_STOP_BSS_REQ:
4883 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4884 break;
4885
4886 case eWNI_SME_ASSOC_CNF:
4887 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004888 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004889 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4890 pMsgBuf);
4891 break;
4892
4893 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004894 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004895 __lim_process_sme_addts_req(pMac, pMsgBuf);
4896 break;
4897
4898 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004899 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004900 __lim_process_sme_delts_req(pMac, pMsgBuf);
4901 break;
4902
4903 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004904 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004905 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4906 break;
4907
4908 case eWNI_SME_GET_STATISTICS_REQ:
4909 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4910 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4911 bufConsumed = false;
4912 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004913#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004914 case eWNI_SME_GET_TSM_STATS_REQ:
4915 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4916 bufConsumed = false;
4917 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004918#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004919 case eWNI_SME_GET_ASSOC_STAS_REQ:
4920 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4921 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304922 case eWNI_SME_SESSION_UPDATE_PARAM:
4923 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004924 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304925 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4926 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4927 bufConsumed = false;
4928 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004929 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4930 /* Update the beaconInterval */
4931 __lim_process_sme_change_bi(pMac, pMsgBuf);
4932 break;
4933
4934#ifdef QCA_HT_2040_COEX
4935 case eWNI_SME_SET_HT_2040_MODE:
4936 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4937 break;
4938#endif
4939
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004940 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4941 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4942 __lim_process_report_message(pMac, pMsg);
4943 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004944
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004945 case eWNI_SME_FT_PRE_AUTH_REQ:
4946 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4947 break;
4948 case eWNI_SME_FT_UPDATE_KEY:
4949 lim_process_ft_update_key(pMac, pMsgBuf);
4950 break;
4951
4952 case eWNI_SME_FT_AGGR_QOS_REQ:
4953 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4954 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004955
4956 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4957 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4958 break;
4959#ifdef FEATURE_WLAN_TDLS
4960 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4961 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4962 break;
4963 case eWNI_SME_TDLS_ADD_STA_REQ:
4964 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4965 break;
4966 case eWNI_SME_TDLS_DEL_STA_REQ:
4967 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4968 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004969#endif
4970 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4971 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4972 break;
4973
4974 case eWNI_SME_CHANNEL_CHANGE_REQ:
4975 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4976 break;
4977
4978 case eWNI_SME_START_BEACON_REQ:
4979 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4980 break;
4981
4982 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4983 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4984 break;
4985
4986 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4987 lim_process_update_add_ies(pMac, pMsgBuf);
4988 break;
4989
4990 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4991 lim_process_modify_add_ies(pMac, pMsgBuf);
4992 break;
4993 case eWNI_SME_SET_HW_MODE_REQ:
4994 lim_process_set_hw_mode(pMac, pMsgBuf);
4995 break;
4996 case eWNI_SME_NSS_UPDATE_REQ:
4997 lim_process_nss_update_request(pMac, pMsgBuf);
4998 break;
4999 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5000 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5001 break;
5002 case eWNI_SME_SET_IE_REQ:
5003 lim_process_set_ie_req(pMac, pMsgBuf);
5004 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305005 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5006 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5007 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305008 case eWNI_SME_EXT_CHANGE_CHANNEL:
5009 lim_process_ext_change_channel(pMac, pMsgBuf);
5010 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005011 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5012 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5013 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005014 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5015 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005016 break;
5017 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5018 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5019 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305020 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5021 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5022 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07005023 case eWNI_SME_UPDATE_CONFIG:
5024 lim_process_sme_update_config(pMac,
5025 (struct update_config *)pMsgBuf);
5026 break;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08005027 case eWNI_SME_SET_ADDBA_ACCEPT:
5028 lim_process_sme_set_addba_accept(pMac,
5029 (struct sme_addba_accept *)pMsgBuf);
5030 break;
Arif Hussaineb8ba362018-03-07 19:15:13 -08005031 case eWNI_SME_UPDATE_EDCA_PROFILE:
5032 lim_process_sme_update_edca_params(pMac, pMsg->bodyval);
5033 break;
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07005034 case WNI_SME_UPDATE_MU_EDCA_PARAMS:
5035 lim_process_sme_update_mu_edca_params(pMac, pMsg->bodyval);
5036 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005037 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305038 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005039 pMsg->bodyptr = NULL;
5040 break;
5041 } /* switch (msgType) */
5042
5043 return bufConsumed;
5044} /*** end lim_process_sme_req_messages() ***/
5045
5046/**
5047 * lim_process_sme_start_beacon_req()
5048 *
5049 ***FUNCTION:
5050 * This function is called by limProcessMessageQueue(). This
5051 * function processes SME request messages from HDD or upper layer
5052 * application.
5053 *
5054 ***LOGIC:
5055 *
5056 ***ASSUMPTIONS:
5057 *
5058 ***NOTE:
5059 *
5060 * @param pMac Pointer to Global MAC structure
5061 * @param msgType Indicates the SME message type
5062 * @param *pMsgBuf A pointer to the SME message buffer
5063 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5064 * false - if pMsgBuf is not to be freed.
5065 */
5066static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5067{
5068 tpSirStartBeaconIndication pBeaconStartInd;
5069 tpPESession psessionEntry;
5070 uint8_t sessionId; /* PE sessionID */
5071
5072 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005073 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005074 return;
5075 }
5076
5077 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5078 psessionEntry = pe_find_session_by_bssid(pMac,
5079 pBeaconStartInd->bssid,
5080 &sessionId);
5081 if (psessionEntry == NULL) {
5082 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005083 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005084 return;
5085 }
5086
5087 if (pBeaconStartInd->beaconStartStatus == true) {
5088 /*
5089 * Currently this Indication comes from SAP
5090 * to start Beacon Tx on a DFS channel
5091 * since beaconing has to be done on DFS
5092 * channel only after CAC WAIT is completed.
5093 * On a DFS Channel LIM does not start beacon
5094 * Tx right after the WMA_ADD_BSS_RSP.
5095 */
5096 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05305097 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005098 FL("Start Beacon with ssid %s Ch %d"),
5099 psessionEntry->ssId.ssId,
5100 psessionEntry->currentOperChannel);
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05305101 lim_send_beacon(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08005102 lim_enable_obss_detection_config(pMac, psessionEntry);
Arif Hussain05fb4872018-01-03 16:02:55 -08005103 lim_send_obss_color_collision_cfg(pMac, psessionEntry,
5104 OBSS_COLOR_COLLISION_DETECTION);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005105 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005106 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005107 return;
5108 }
5109}
5110
5111/**
5112 * lim_process_sme_channel_change_request() - process sme ch change req
5113 *
5114 * @mac_ctx: Pointer to Global MAC structure
5115 * @msg_buf: pointer to the SME message buffer
5116 *
5117 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5118 *
5119 * Return: None
5120 */
5121static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5122 uint32_t *msg_buf)
5123{
5124 tpSirChanChangeRequest ch_change_req;
5125 tpPESession session_entry;
5126 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005127 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005128 uint32_t val = 0;
5129
5130 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005131 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005132 return;
5133 }
5134 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5135
5136 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5137 ch_change_req->targetChannel);
5138
5139 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5140 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005141 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005142 return;
5143 }
5144
5145 session_entry = pe_find_session_by_bssid(mac_ctx,
5146 ch_change_req->bssid, &session_id);
5147 if (session_entry == NULL) {
5148 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005149 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005150 return;
5151 }
5152
Manjunathappa Prakash34fda792018-02-07 18:23:42 -08005153 if ((session_entry->currentOperChannel ==
5154 ch_change_req->targetChannel) &&
5155 (session_entry->ch_width == ch_change_req->ch_width)) {
5156 pe_err("Target channel and mode is same as current channel and mode channel %d and mode %d",
5157 session_entry->currentOperChannel, session_entry->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005158 return;
5159 }
5160
5161 if (LIM_IS_AP_ROLE(session_entry))
5162 session_entry->channelChangeReasonCode =
5163 LIM_SWITCH_CHANNEL_SAP_DFS;
5164 else
5165 session_entry->channelChangeReasonCode =
5166 LIM_SWITCH_CHANNEL_OPERATION;
5167
Bala Venkateshb39ed152017-12-26 19:35:27 +05305168 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d, nw_type %d, dot11mode %d",
5169 session_entry->currentOperChannel,
5170 ch_change_req->targetChannel,
5171 ch_change_req->ch_width,
5172 ch_change_req->nw_type,
5173 ch_change_req->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005174
5175 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005176 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005177 session_entry->ch_center_freq_seg0 =
5178 ch_change_req->center_freq_seg_0;
5179 session_entry->ch_center_freq_seg1 =
5180 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005181 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005182 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005183 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005184 session_entry->htRecommendedTxWidthSet =
5185 session_entry->htSupportedChannelWidthSet;
5186 session_entry->currentOperChannel =
5187 ch_change_req->targetChannel;
5188 session_entry->limRFBand =
5189 lim_get_rf_band(session_entry->currentOperChannel);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305190 session_entry->cac_duration_ms = ch_change_req->cac_duration_ms;
5191 session_entry->dfs_regdomain = ch_change_req->dfs_regdomain;
5192 session_entry->maxTxPower = max_tx_pwr;
Vignesh Viswanathan153ae932018-04-11 14:24:13 +05305193
5194 /* Update the global beacon filter */
5195 lim_update_bcn_probe_filter(mac_ctx, session_entry);
5196
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005197 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08005198 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005199 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005200 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005201 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005202 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005203 }
5204
5205 session_entry->lim11hEnable = val;
5206 session_entry->dot11mode = ch_change_req->dot11mode;
Bala Venkateshb39ed152017-12-26 19:35:27 +05305207 session_entry->nwType = ch_change_req->nw_type;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305208 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005209 &ch_change_req->operational_rateset,
5210 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305211 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005212 &ch_change_req->extended_rateset,
5213 sizeof(session_entry->extRateSet));
Abhishek Singh20a8e442018-09-12 15:50:44 +05305214
5215#ifdef CONFIG_VDEV_SM
Abhishek Singha063f1c2018-09-19 11:37:51 +05305216 mlme_set_chan_switch_in_progress(session_entry->vdev, true);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305217 if (wlan_vdev_mlme_get_state(session_entry->vdev) ==
5218 WLAN_VDEV_S_DFS_CAC_WAIT)
5219 wlan_vdev_mlme_sm_deliver_evt(session_entry->vdev,
5220 WLAN_VDEV_SM_EV_RADAR_DETECTED,
5221 sizeof(*session_entry),
5222 session_entry);
5223 else
5224 wlan_vdev_mlme_sm_deliver_evt(session_entry->vdev,
5225 WLAN_VDEV_SM_EV_CSA_COMPLETE,
5226 sizeof(*session_entry),
5227 session_entry);
5228
5229
5230#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005231 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5232 session_entry->ch_center_freq_seg0,
5233 session_entry->ch_center_freq_seg1,
5234 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07005235 max_tx_pwr, session_entry->peSessionId,
5236 ch_change_req->cac_duration_ms,
5237 ch_change_req->dfs_regdomain);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305238#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005239}
5240
5241/******************************************************************************
5242* lim_start_bss_update_add_ie_buffer()
5243*
5244***FUNCTION:
5245* This function checks the src buffer and its length and then malloc for
5246* dst buffer update the same
5247*
5248***LOGIC:
5249*
5250***ASSUMPTIONS:
5251*
5252***NOTE:
5253*
5254* @param pMac Pointer to Global MAC structure
5255* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5256* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5257* @param *pSrcData_buff A pointer of uint8_t src buffer
5258* @param srcDataLen src buffer length
5259******************************************************************************/
5260
5261static void
5262lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5263 uint8_t **pDstData_buff,
5264 uint16_t *pDstDataLen,
5265 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5266{
5267
5268 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5269 *pDstDataLen = srcDataLen;
5270
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305271 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005272
5273 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005274 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005275 return;
5276 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305277 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005278 } else {
5279 *pDstData_buff = NULL;
5280 *pDstDataLen = 0;
5281 }
5282}
5283
5284/******************************************************************************
5285* lim_update_add_ie_buffer()
5286*
5287***FUNCTION:
5288* This function checks the src buffer and length if src buffer length more
5289* than dst buffer length then free the dst buffer and malloc for the new src
5290* length, and update the dst buffer and length. But if dst buffer is bigger
5291* than src buffer length then it just update the dst buffer and length
5292*
5293***LOGIC:
5294*
5295***ASSUMPTIONS:
5296*
5297***NOTE:
5298*
5299* @param pMac Pointer to Global MAC structure
5300* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5301* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5302* @param *pSrcData_buff A pointer of uint8_t src buffer
5303* @param srcDataLen src buffer length
5304******************************************************************************/
5305
5306static void
5307lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5308 uint8_t **pDstData_buff,
5309 uint16_t *pDstDataLen,
5310 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5311{
5312
5313 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005314 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005315 return;
5316 }
5317
5318 if (srcDataLen > *pDstDataLen) {
5319 *pDstDataLen = srcDataLen;
5320 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305321 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005322 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305323 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005324
5325 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005326 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005327 *pDstDataLen = 0;
5328 return;
5329 }
5330 }
5331
5332 /* copy the content of buffer into dst buffer
5333 */
5334 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305335 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005336
5337}
5338
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005339/**
5340 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5341 * @pMac : Pointer to Global MAC structure
5342 * @pDstData_buff : A pointer to pointer of dst buffer
5343 * @pDstDataLen : A pointer to pointer of dst buffer length
5344 * @pModifyIE : A pointer to tSirModifyIE
5345 *
5346 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5347 *
5348 * Return:
5349 * True or false depending upon whether IE is updated or not
5350 */
5351static bool
5352lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5353 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5354{
Hong Shi1553d692016-09-28 12:16:19 +08005355 int32_t oui_length;
5356 uint8_t *ibss_ie = NULL;
5357 uint8_t *vendor_ie;
5358#define MAC_VENDOR_OUI "\x00\x16\x32"
5359#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005360
5361 ibss_ie = pModifyIE->pIEBuffer;
5362 oui_length = pModifyIE->oui_length;
5363
5364 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005365 pe_err("Invalid set IBSS vendor IE command length %d",
5366 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005367 return false;
5368 }
5369
Hong Shi1553d692016-09-28 12:16:19 +08005370 /*
5371 * Why replace only beacon OUI data here:
5372 * 1. other ie (such as wpa) shall not be overwritten here.
5373 * 2. per spec, beacon oui ie might be set twice and original one
5374 * shall be updated.
5375 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005376 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005377 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5378 if (vendor_ie) {
5379 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5380 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5381 pModifyIE->ieBufferlength);
5382 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005383 uint16_t new_length;
5384 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005385
Naveen Rawat668dee32017-09-29 14:39:40 -07005386 /*
5387 * check for uint16 overflow before using sum of two numbers as
5388 * length of size to malloc
5389 */
5390 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5391 pe_err("U16 overflow due to %d + %d",
5392 pModifyIE->ieBufferlength, *pDstDataLen);
5393 return false;
5394 }
5395
5396 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5397 new_ptr = qdf_mem_malloc(new_length);
Hong Shi1553d692016-09-28 12:16:19 +08005398 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005399 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005400 return false;
5401 }
5402 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5403 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5404 pModifyIE->ieBufferlength);
5405 qdf_mem_free(*pDstData_buff);
5406 *pDstDataLen = new_length;
5407 *pDstData_buff = new_ptr;
5408 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005409 return true;
5410}
5411
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005412/*
5413* lim_process_modify_add_ies() - process modify additional IE req.
5414*
5415* @mac_ctx: Pointer to Global MAC structure
5416* @msg_buf: pointer to the SME message buffer
5417*
5418* This function update the PE buffers for additional IEs.
5419*
5420* Return: None
5421*/
5422static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5423 uint32_t *msg_buf)
5424{
5425 tpSirModifyIEsInd modify_add_ies;
5426 tpPESession session_entry;
5427 uint8_t session_id;
5428 bool ret = false;
5429 tSirAddIeParams *add_ie_params;
5430
5431 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005432 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005433 return;
5434 }
5435
5436 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5437 /* Incoming message has smeSession, use BSSID to find PE session */
5438 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005439 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005440
5441 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005442 pe_err("Session not found for given bssid"
5443 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005444 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005445 goto end;
5446 }
5447 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5448 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5449 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005450 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005451 modify_add_ies->modifyIE.pIEBuffer,
5452 modify_add_ies->modifyIE.ieBufferlength,
5453 modify_add_ies->modifyIE.ieID,
5454 modify_add_ies->modifyIE.ieIDLen,
5455 modify_add_ies->updateType);
5456 goto end;
5457 }
5458 add_ie_params = &session_entry->addIeParams;
5459 switch (modify_add_ies->updateType) {
5460 case eUPDATE_IE_PROBE_RESP:
5461 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005462 if (LIM_IS_IBSS_ROLE(session_entry)) {
5463 lim_update_ibss_prop_add_ies(mac_ctx,
5464 &add_ie_params->probeRespData_buff,
5465 &add_ie_params->probeRespDataLen,
5466 &modify_add_ies->modifyIE);
5467 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005468 break;
5469 case eUPDATE_IE_ASSOC_RESP:
5470 /* assoc resp IE */
5471 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305472 QDF_TRACE(QDF_MODULE_ID_PE,
5473 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005474 "assoc resp add ie not present %d"),
5475 add_ie_params->assocRespDataLen);
5476 }
5477 /* search through the buffer and modify the IE */
5478 break;
5479 case eUPDATE_IE_PROBE_BCN:
5480 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005481 if (LIM_IS_IBSS_ROLE(session_entry)) {
5482 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5483 &add_ie_params->probeRespBCNData_buff,
5484 &add_ie_params->probeRespBCNDataLen,
5485 &modify_add_ies->modifyIE);
5486 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005487 if (ret == true && modify_add_ies->modifyIE.notify) {
5488 lim_handle_param_update(mac_ctx,
5489 modify_add_ies->updateType);
5490 }
5491 break;
5492 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005493 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005494 modify_add_ies->updateType);
5495 break;
5496 }
5497end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305498 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005499 modify_add_ies->modifyIE.pIEBuffer = NULL;
5500}
5501
5502/*
5503* lim_process_update_add_ies() - process additional IE update req
5504*
5505* @mac_ctx: Pointer to Global MAC structure
5506* @msg_buf: pointer to the SME message buffer
5507*
5508* This function update the PE buffers for additional IEs.
5509*
5510* Return: None
5511*/
5512static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5513 uint32_t *msg_buf)
5514{
5515 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5516 uint8_t session_id;
5517 tpPESession session_entry;
5518 tSirAddIeParams *addn_ie;
5519 uint16_t new_length = 0;
5520 uint8_t *new_ptr = NULL;
5521 tSirUpdateIE *update_ie;
5522
5523 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005524 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005525 return;
5526 }
5527 update_ie = &update_add_ies->updateIE;
5528 /* incoming message has smeSession, use BSSID to find PE session */
5529 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005530 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005531
5532 if (NULL == session_entry) {
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05305533 pe_debug("Session not found for given bssid"
5534 MAC_ADDRESS_STR,
5535 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005536 goto end;
5537 }
5538 addn_ie = &session_entry->addIeParams;
5539 /* if len is 0, upper layer requested freeing of buffer */
5540 if (0 == update_ie->ieBufferlength) {
5541 switch (update_add_ies->updateType) {
5542 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305543 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005544 addn_ie->probeRespData_buff = NULL;
5545 addn_ie->probeRespDataLen = 0;
5546 break;
5547 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305548 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005549 addn_ie->assocRespData_buff = NULL;
5550 addn_ie->assocRespDataLen = 0;
5551 break;
5552 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305553 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005554 addn_ie->probeRespBCNData_buff = NULL;
5555 addn_ie->probeRespBCNDataLen = 0;
5556
5557 if (update_ie->notify)
5558 lim_handle_param_update(mac_ctx,
5559 update_add_ies->updateType);
5560 break;
5561 default:
5562 break;
5563 }
5564 return;
5565 }
5566 switch (update_add_ies->updateType) {
5567 case eUPDATE_IE_PROBE_RESP:
5568 if (update_ie->append) {
5569 /*
5570 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005571 * with combined length.
5572 * Multiple back to back append commands
5573 * can lead to a huge length.So, check
5574 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005575 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005576 if (addn_ie->probeRespDataLen >
5577 (USHRT_MAX - update_ie->ieBufferlength)) {
5578 pe_err("IE Length overflow, curr:%d, new:%d",
5579 addn_ie->probeRespDataLen,
5580 update_ie->ieBufferlength);
5581 goto end;
5582 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005583 new_length = update_ie->ieBufferlength +
5584 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305585 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005586 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005587 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005588 goto end;
5589 }
5590 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305591 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005592 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305593 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005594 update_ie->pAdditionIEBuffer,
5595 update_ie->ieBufferlength);
5596 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305597 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005598 /* adjust length accordingly */
5599 addn_ie->probeRespDataLen = new_length;
5600 /* save refernece of local buffer in PE session */
5601 addn_ie->probeRespData_buff = new_ptr;
5602 goto end;
5603 }
5604 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5605 &addn_ie->probeRespDataLen,
5606 update_ie->pAdditionIEBuffer,
5607 update_ie->ieBufferlength);
5608 break;
5609 case eUPDATE_IE_ASSOC_RESP:
5610 /* assoc resp IE */
5611 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5612 &addn_ie->assocRespDataLen,
5613 update_ie->pAdditionIEBuffer,
5614 update_ie->ieBufferlength);
5615 break;
5616 case eUPDATE_IE_PROBE_BCN:
5617 /* probe resp Bcn IE */
5618 lim_update_add_ie_buffer(mac_ctx,
5619 &addn_ie->probeRespBCNData_buff,
5620 &addn_ie->probeRespBCNDataLen,
5621 update_ie->pAdditionIEBuffer,
5622 update_ie->ieBufferlength);
5623 if (update_ie->notify)
5624 lim_handle_param_update(mac_ctx,
5625 update_add_ies->updateType);
5626 break;
5627 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005628 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005629 break;
5630 }
5631end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305632 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005633 update_ie->pAdditionIEBuffer = NULL;
5634}
5635
5636/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305637 * send_extended_chan_switch_action_frame()- function to send ECSA
5638 * action frame for each sta connected to SAP/GO and AP in case of
5639 * STA .
5640 * @mac_ctx: pointer to global mac structure
5641 * @new_channel: new channel to switch to.
5642 * @ch_bandwidth: BW of channel to calculate op_class
5643 * @session_entry: pe session
5644 *
5645 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5646 *
5647 * Return: void
5648 */
5649
5650static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5651 uint16_t new_channel, uint8_t ch_bandwidth,
5652 tpPESession session_entry)
5653{
5654 uint16_t op_class;
5655 uint8_t switch_mode = 0, i;
5656 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005657 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305658
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005659 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305660 mac_ctx->scan.countryCodeCurrent,
5661 new_channel,
5662 ch_bandwidth);
5663
5664 if (LIM_IS_AP_ROLE(session_entry) &&
5665 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005666 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305667
gaoleze2920bd2017-03-21 17:38:42 +08005668 switch_count = session_entry->gLimChannelSwitch.switchCount;
5669
Abhishek Singh518323d2015-10-19 17:42:01 +05305670 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005671 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305672 psta =
5673 session_entry->dph.dphHashTable.pDphNodeArray + i;
5674 if (psta && psta->added)
5675 lim_send_extended_chan_switch_action_frame(
5676 mac_ctx,
5677 psta->staAddr,
5678 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005679 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305680 }
5681 } else if (LIM_IS_STA_ROLE(session_entry)) {
5682 lim_send_extended_chan_switch_action_frame(mac_ctx,
5683 session_entry->bssId,
5684 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005685 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305686 }
5687
5688}
5689
gaolez76d2a162017-03-21 19:23:58 +08005690void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5691 uint16_t new_channel,
5692 uint8_t ch_bandwidth,
5693 tpPESession session_entry)
5694{
5695 uint16_t op_class;
5696 uint8_t switch_mode = 0, i;
5697 uint8_t switch_count;
5698 tpDphHashNode psta;
5699 tpDphHashNode dph_node_array_ptr;
5700
5701 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5702
5703 op_class = wlan_reg_dmn_get_opclass_from_channel(
5704 mac_ctx->scan.countryCodeCurrent,
5705 new_channel, ch_bandwidth);
5706
5707 if (LIM_IS_AP_ROLE(session_entry) &&
5708 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5709 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5710
5711 switch_count = session_entry->gLimChannelSwitch.switchCount;
5712
5713 if (LIM_IS_AP_ROLE(session_entry)) {
5714 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5715 psta = dph_node_array_ptr + i;
5716 if (!(psta && psta->added))
5717 continue;
5718 if (session_entry->lim_non_ecsa_cap_num == 0)
5719 lim_send_extended_chan_switch_action_frame
5720 (mac_ctx, psta->staAddr, switch_mode,
5721 op_class, new_channel, switch_count,
5722 session_entry);
5723 else
5724 lim_send_channel_switch_mgmt_frame
5725 (mac_ctx, psta->staAddr, switch_mode,
5726 new_channel, switch_count,
5727 session_entry);
5728 }
5729 } else if (LIM_IS_STA_ROLE(session_entry)) {
5730 lim_send_extended_chan_switch_action_frame
5731 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5732 new_channel, switch_count, session_entry);
5733 }
5734}
5735
5736/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005737 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5738 *
5739 * @mac_ctx: Pointer to Global MAC structure
5740 * @msg_buf: pointer to the SME message buffer
5741 *
5742 * This function processes SME request messages from HDD or upper layer
5743 * application.
5744 *
5745 * Return: None
5746 */
5747static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5748 uint32_t *msg_buf)
5749{
5750 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5751 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005752 uint8_t session_id;
5753 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005754 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005755
5756 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005757 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005758 return;
5759 }
5760
5761 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5762 session_entry = pe_find_session_by_bssid(mac_ctx,
5763 dfs_csa_ie_req->bssid, &session_id);
5764 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005765 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005766 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5767 return;
5768 }
5769
5770 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005771 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005772 GET_LIM_SYSTEM_ROLE(session_entry));
5773 return;
5774 }
5775
5776 /* target channel */
5777 session_entry->gLimChannelSwitch.primaryChannel =
5778 dfs_csa_ie_req->targetChannel;
5779
5780 /* Channel switch announcement needs to be included in beacon */
5781 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005782 session_entry->gLimChannelSwitch.switchCount =
5783 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005784 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005785 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305786 session_entry->gLimChannelSwitch.sec_ch_offset =
5787 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005788 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005789 session_entry->gLimChannelSwitch.switchMode =
5790 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005791
5792 /*
5793 * Validate if SAP is operating HT or VHT mode and set the Channel
5794 * Switch Wrapper element with the Wide Band Switch subelement.
5795 */
5796 if (true != session_entry->vhtCapability)
5797 goto skip_vht;
5798
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005799 /* Now encode the Wider Ch BW element depending on the ch width */
5800 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005801 switch (dfs_csa_ie_req->ch_params.ch_width) {
5802 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005803 /*
5804 * Wide channel BW sublement in channel wrapper element is not
5805 * required in case of 20 Mhz operation. Currently It is set
5806 * only set in case of 40/80 Mhz Operation.
5807 */
5808 session_entry->dfsIncludeChanWrapperIe = false;
5809 wider_bw_ch_switch->newChanWidth =
5810 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5811 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005812 case CH_WIDTH_40MHZ:
5813 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005814 wider_bw_ch_switch->newChanWidth =
5815 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5816 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005817 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005818 session_entry->dfsIncludeChanWrapperIe = true;
5819 wider_bw_ch_switch->newChanWidth =
5820 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5821 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005822 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005823 session_entry->dfsIncludeChanWrapperIe = true;
5824 wider_bw_ch_switch->newChanWidth =
5825 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5826 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005827 case CH_WIDTH_80P80MHZ:
5828 session_entry->dfsIncludeChanWrapperIe = true;
5829 wider_bw_ch_switch->newChanWidth =
5830 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005831 /*
5832 * This is not applicable for 20/40/80 Mhz.
5833 * Only used when we support 80+80 Mhz operation.
5834 * In case of 80+80 Mhz, this parameter indicates
5835 * center channel frequency index of 80 Mhz channel of
5836 * frequency segment 1.
5837 */
5838 wider_bw_ch_switch->newCenterChanFreq1 =
5839 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005840 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005841 default:
5842 session_entry->dfsIncludeChanWrapperIe = false;
5843 /*
5844 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5845 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5846 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005847 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005848 break;
5849 }
5850 /* Fetch the center channel based on the channel width */
5851 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005852 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005853skip_vht:
5854 /* Send CSA IE request from here */
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05305855 lim_send_dfs_chan_sw_ie_update(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305856
5857 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5858 ch_offset = BW80;
5859 else
5860 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5861
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005862 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305863 session_entry->gLimChannelSwitch.switchCount,
5864 session_entry->gLimChannelSwitch.primaryChannel,
5865 session_entry->gLimChannelSwitch.ch_width,
5866 session_entry->dfsIncludeChanWrapperIe,
5867 ch_offset);
5868
gaolez76d2a162017-03-21 19:23:58 +08005869 /* Send ECSA/CSA Action frame after updating the beacon */
5870 if (CHAN_HOP_ALL_BANDS_ENABLE)
5871 lim_send_chan_switch_action_frame(mac_ctx,
5872 session_entry->gLimChannelSwitch.primaryChannel,
5873 ch_offset, session_entry);
5874 else
5875 send_extended_chan_switch_action_frame(mac_ctx,
5876 session_entry->gLimChannelSwitch.primaryChannel,
5877 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005878}
5879
5880/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305881 * lim_process_ext_change_channel()- function to send ECSA
5882 * action frame for STA/CLI .
5883 * @mac_ctx: pointer to global mac structure
5884 * @msg: params from sme for new channel.
5885 *
5886 * This function is called to send ECSA frame for STA/CLI.
5887 *
5888 * Return: void
5889 */
5890
5891static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5892 uint32_t *msg)
5893{
5894 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5895 (struct sir_sme_ext_cng_chan_req *) msg;
5896 tpPESession session_entry = NULL;
5897
5898 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005899 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305900 return;
5901 }
5902 session_entry =
5903 pe_find_session_by_sme_session_id(mac_ctx,
5904 ext_chng_channel->session_id);
5905 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005906 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305907 ext_chng_channel->session_id);
5908 return;
5909 }
5910 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005911 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305912 return;
5913 }
5914 send_extended_chan_switch_action_frame(mac_ctx,
5915 ext_chng_channel->new_channel,
5916 0, session_entry);
5917}
5918
5919/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005920 * lim_process_nss_update_request() - process sme nss update req
5921 *
5922 * @mac_ctx: Pointer to Global MAC structure
5923 * @msg_buf: pointer to the SME message buffer
5924 *
5925 * This function processes SME request messages from HDD or upper layer
5926 * application.
5927 *
5928 * Return: None
5929 */
5930static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5931 uint32_t *msg_buf)
5932{
5933 struct sir_nss_update_request *nss_update_req_ptr;
5934 tpPESession session_entry = NULL;
5935
5936 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005937 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005938 return;
5939 }
5940
5941 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305942 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005943 nss_update_req_ptr->vdev_id);
5944 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005945 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005946 nss_update_req_ptr->vdev_id);
5947 return;
5948 }
5949
5950 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005951 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005952 GET_LIM_SYSTEM_ROLE(session_entry));
5953 return;
5954 }
5955
5956 /* populate nss field in the beacon */
5957 session_entry->gLimOperatingMode.present = 1;
5958 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05305959 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
5960
5961 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
5962 (session_entry->ch_width > CH_WIDTH_80MHZ))
5963 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
5964
5965 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
5966
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005967 /* Send nss update request from here */
5968 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005969 QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005970 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005971 return;
5972 }
5973
5974 lim_send_beacon_ind(mac_ctx, session_entry);
5975}
5976
5977/**
5978 * lim_process_set_ie_req() - process sme set IE request
5979 *
5980 * @mac_ctx: Pointer to Global MAC structure
5981 * @msg_buf: pointer to the SME message buffer
5982 *
5983 * This function processes SME request messages from HDD or upper layer
5984 * application.
5985 *
5986 * Return: None
5987 */
5988static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5989{
5990 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305991 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005992
5993 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005994 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005995 return;
5996 }
5997
5998 msg = (struct send_extcap_ie *)msg_buf;
5999 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306000 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006001 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006002
6003}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006004
6005#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Arif Hussain05fb4872018-01-03 16:02:55 -08006006
6007/**
6008 * obss_color_collision_process_color_disable() - Disable bss color
6009 * @mac_ctx: Pointer to Global MAC structure
6010 * @session: pointer to session
6011 *
6012 * This function will disbale bss color.
6013 *
6014 * Return: None
6015 */
6016static void obss_color_collision_process_color_disable(tpAniSirGlobal mac_ctx,
6017 tpPESession session)
6018{
6019 tUpdateBeaconParams beacon_params;
6020
6021 if (!session) {
6022 pe_err("Invalid session");
6023 return;
6024 }
6025
6026 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6027 pe_err("Invalid SystemRole %d",
6028 GET_LIM_SYSTEM_ROLE(session));
6029 return;
6030 }
6031
6032 if (session->bss_color_changing == 1) {
6033 pe_warn("%d: color change in progress", session->smeSessionId);
6034 /* Continue color collision detection */
6035 lim_send_obss_color_collision_cfg(mac_ctx, session,
6036 OBSS_COLOR_COLLISION_DETECTION);
6037 return;
6038 }
6039
6040 if (session->he_op.bss_col_disabled == 1) {
6041 pe_warn("%d: bss color already disabled",
6042 session->smeSessionId);
6043 /* Continue free color detection */
6044 lim_send_obss_color_collision_cfg(mac_ctx, session,
6045 OBSS_COLOR_FREE_SLOT_AVAILABLE);
6046 return;
6047 }
6048
6049 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
6050 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
6051 session->he_op.bss_col_disabled = 1;
Arif Hussain05fb4872018-01-03 16:02:55 -08006052 beacon_params.bss_color_disabled = 1;
Arif Hussain2f2d3512018-03-06 12:37:03 -08006053 beacon_params.bss_color = session->he_op.bss_color;
Arif Hussain05fb4872018-01-03 16:02:55 -08006054
6055 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006056 QDF_STATUS_SUCCESS) {
Arif Hussain05fb4872018-01-03 16:02:55 -08006057 pe_err("Unable to set op mode IE in beacon");
6058 return;
6059 }
6060
6061 lim_send_beacon_params(mac_ctx, &beacon_params, session);
6062 lim_send_obss_color_collision_cfg(mac_ctx, session,
6063 OBSS_COLOR_FREE_SLOT_AVAILABLE);
6064}
6065
6066/**
6067 * obss_color_collision_process_color_change() - Process bss color change
6068 * @mac_ctx: Pointer to Global MAC structure
6069 * @session: pointer to session
6070 * @obss_color_info: obss color collision/free slot indication info
6071 *
6072 * This function selects new color ib case of bss color collision.
6073 *
6074 * Return: None
6075 */
6076static void obss_color_collision_process_color_change(tpAniSirGlobal mac_ctx,
6077 tpPESession session,
6078 struct wmi_obss_color_collision_info *obss_color_info)
6079{
6080 int i, num_bss_color = 0;
6081 uint32_t bss_color_bitmap;
6082 uint8_t bss_color_index_array[MAX_BSS_COLOR_VALUE];
6083 uint32_t rand_byte = 0;
6084 struct sir_set_he_bss_color he_bss_color;
6085 bool is_color_collision = false;
6086
6087
6088 if (session->bss_color_changing == 1) {
6089 pe_err("%d: color change in progress", session->smeSessionId);
6090 return;
6091 }
6092
6093 if (!session->he_op.bss_col_disabled) {
6094 if (session->he_op.bss_color < 32)
6095 is_color_collision = (obss_color_info->
6096 obss_color_bitmap_bit0to31 >>
6097 session->he_op.bss_color) & 0x01;
6098 else
6099 is_color_collision = (obss_color_info->
6100 obss_color_bitmap_bit32to63 >>
6101 (session->he_op.bss_color -
Arif Hussain9e8c5612018-04-12 16:35:48 -07006102 32)) & 0x01;
Arif Hussain05fb4872018-01-03 16:02:55 -08006103 if (!is_color_collision) {
6104 pe_err("%d: color collision not found, curr_color: %d",
6105 session->smeSessionId,
6106 session->he_op.bss_color);
6107 return;
6108 }
6109 }
6110
6111 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit0to31;
6112
6113 /* Skip color zero */
6114 bss_color_bitmap = bss_color_bitmap >> 1;
6115 for (i = 0; (i < 31) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
6116 if (!(bss_color_bitmap & 0x01)) {
6117 bss_color_index_array[num_bss_color] = i + 1;
6118 num_bss_color++;
6119 }
6120 bss_color_bitmap = bss_color_bitmap >> 1;
6121 }
6122
6123 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit32to63;
6124 for (i = 0; (i < 32) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
6125 if (!(bss_color_bitmap & 0x01)) {
6126 bss_color_index_array[num_bss_color] = i + 32;
6127 num_bss_color++;
6128 }
6129 bss_color_bitmap = bss_color_bitmap >> 1;
6130 }
6131
6132 if (num_bss_color) {
6133 qdf_get_random_bytes((void *) &rand_byte, 1);
6134 i = (rand_byte + qdf_mc_timer_get_system_ticks()) %
6135 num_bss_color;
6136 pe_debug("New bss color = %d", bss_color_index_array[i]);
6137 he_bss_color.session_id = obss_color_info->vdev_id;
6138 he_bss_color.bss_color = bss_color_index_array[i];
6139 lim_process_set_he_bss_color(mac_ctx,
6140 (uint32_t *)&he_bss_color);
6141 } else {
6142 pe_err("Unable to find bss color from bitmasp");
6143 if (obss_color_info->evt_type ==
6144 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY &&
6145 session->obss_color_collision_dec_evt ==
6146 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6147 /* In dot11BSSColorCollisionAPPeriod and
6148 * timer expired, time to disable bss color.
6149 */
6150 obss_color_collision_process_color_disable(mac_ctx,
6151 session);
6152 else
6153 /*
6154 * Enter dot11BSSColorCollisionAPPeriod period.
6155 */
6156 lim_send_obss_color_collision_cfg(mac_ctx, session,
6157 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY);
6158 }
6159}
6160
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006161void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6162{
6163 struct sir_set_he_bss_color *bss_color;
6164 tpPESession session_entry = NULL;
6165 tUpdateBeaconParams beacon_params;
6166
6167 if (!msg_buf) {
6168 pe_err("Buffer is Pointing to NULL");
6169 return;
6170 }
6171
6172 bss_color = (struct sir_set_he_bss_color *)msg_buf;
6173 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
6174 bss_color->session_id);
6175 if (!session_entry) {
6176 pe_err("Session not found for given session_id %d",
6177 bss_color->session_id);
6178 return;
6179 }
6180
6181 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6182 pe_err("Invalid SystemRole %d",
6183 GET_LIM_SYSTEM_ROLE(session_entry));
6184 return;
6185 }
6186
6187 if (bss_color->bss_color == session_entry->he_op.bss_color) {
6188 pe_err("No change in BSS color, current BSS color %d",
6189 bss_color->bss_color);
6190 return;
6191 }
6192 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
6193 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
6194 session_entry->he_op.bss_col_disabled = 1;
6195 session_entry->he_bss_color_change.countdown =
6196 BSS_COLOR_SWITCH_COUNTDOWN;
6197 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08006198 beacon_params.bss_color_disabled = 1;
6199 beacon_params.bss_color = session_entry->he_op.bss_color;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006200 session_entry->bss_color_changing = 1;
6201
6202 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006203 QDF_STATUS_SUCCESS) {
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006204 pe_err("Unable to set op mode IE in beacon");
6205 return;
6206 }
6207
6208 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
Arif Hussain05fb4872018-01-03 16:02:55 -08006209 lim_send_obss_color_collision_cfg(mac_ctx, session_entry,
6210 OBSS_COLOR_COLLISION_DETECTION_DISABLE);
6211}
6212
6213void lim_send_obss_color_collision_cfg(tpAniSirGlobal mac_ctx,
6214 tpPESession session,
6215 enum wmi_obss_color_collision_evt_type
6216 event_type)
6217{
6218 struct wmi_obss_color_collision_cfg_param *cfg_param;
6219 struct scheduler_msg msg = {0};
6220
6221 if (!session) {
6222 pe_err("Invalid session");
6223 return;
6224 }
6225
6226 if (!session->he_capable ||
6227 !session->is_session_obss_color_collision_det_enabled) {
6228 pe_debug("%d: obss color det not enabled, he_cap:%d, sup:%d:%d",
6229 session->smeSessionId, session->he_capable,
6230 session->is_session_obss_color_collision_det_enabled,
6231 mac_ctx->lim.global_obss_color_collision_det_offload);
6232 return;
6233 }
6234
6235 cfg_param = qdf_mem_malloc(sizeof(*cfg_param));
6236 if (!cfg_param) {
6237 pe_err("Failed to allocate memory");
6238 return;
6239 }
6240
6241 pe_debug("%d: sending event:%d", session->smeSessionId, event_type);
6242 qdf_mem_zero(cfg_param, sizeof(*cfg_param));
6243 cfg_param->vdev_id = session->smeSessionId;
6244 cfg_param->evt_type = event_type;
6245 if (LIM_IS_AP_ROLE(session))
6246 cfg_param->detection_period_ms =
6247 OBSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS;
6248 else
6249 cfg_param->detection_period_ms =
6250 OBSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS;
6251
6252 cfg_param->scan_period_ms = OBSS_COLOR_COLLISION_SCAN_PERIOD_MS;
6253 if (event_type == OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6254 cfg_param->free_slot_expiry_time_ms =
6255 OBSS_COLOR_COLLISION_FREE_SLOT_EXPIRY_MS;
6256
6257 msg.type = WMA_OBSS_COLOR_COLLISION_REQ;
6258 msg.bodyptr = cfg_param;
6259 msg.reserved = 0;
6260
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05306261 if (QDF_IS_STATUS_ERROR(scheduler_post_message(QDF_MODULE_ID_PE,
6262 QDF_MODULE_ID_WMA,
6263 QDF_MODULE_ID_WMA,
6264 &msg))) {
Arif Hussain05fb4872018-01-03 16:02:55 -08006265 pe_err("Failed to post WMA_OBSS_COLOR_COLLISION_REQ to WMA");
6266 qdf_mem_free(cfg_param);
6267 } else {
6268 session->obss_color_collision_dec_evt = event_type;
6269 }
6270}
6271
6272void lim_process_obss_color_collision_info(tpAniSirGlobal mac_ctx,
6273 uint32_t *msg_buf)
6274{
6275 struct wmi_obss_color_collision_info *obss_color_info;
6276 tpPESession session;
6277
6278 if (!msg_buf) {
6279 pe_err("Buffer is Pointing to NULL");
6280 return;
6281 }
6282
6283 obss_color_info = (struct wmi_obss_color_collision_info *)msg_buf;
6284 session = pe_find_session_by_sme_session_id(mac_ctx,
6285 obss_color_info->vdev_id);
6286 if (!session) {
6287 pe_err("Session not found for given session_id %d",
6288 obss_color_info->vdev_id);
6289 return;
6290 }
6291
6292 pe_debug("vdev_id:%d, evt:%d:%d, 0to31:0x%x, 32to63:0x%x, cap:%d:%d:%d",
6293 obss_color_info->vdev_id,
6294 obss_color_info->evt_type,
6295 session->obss_color_collision_dec_evt,
6296 obss_color_info->obss_color_bitmap_bit0to31,
6297 obss_color_info->obss_color_bitmap_bit32to63,
6298 session->he_capable,
6299 session->is_session_obss_color_collision_det_enabled,
6300 mac_ctx->lim.global_obss_color_collision_det_offload);
6301
6302 if (!session->he_capable ||
6303 !session->is_session_obss_color_collision_det_enabled) {
6304 return;
6305 }
6306
6307 switch (obss_color_info->evt_type) {
6308 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
6309 pe_err("%d: FW disabled obss color det. he_cap:%d, sup:%d:%d",
6310 session->smeSessionId, session->he_capable,
6311 session->is_session_obss_color_collision_det_enabled,
6312 mac_ctx->lim.global_obss_color_collision_det_offload);
6313 session->is_session_obss_color_collision_det_enabled = false;
6314 return;
6315 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
6316 case OBSS_COLOR_COLLISION_DETECTION:
6317 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
6318 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6319 pe_debug("Invalid System Role %d",
6320 GET_LIM_SYSTEM_ROLE(session));
6321 return;
6322 }
6323
6324 if (session->obss_color_collision_dec_evt !=
6325 obss_color_info->evt_type) {
6326 pe_debug("%d: Wrong event: %d, skiping",
6327 obss_color_info->vdev_id,
6328 obss_color_info->evt_type);
6329 return;
6330 }
6331 obss_color_collision_process_color_change(mac_ctx, session,
6332 obss_color_info);
6333 break;
6334 default:
6335 pe_err("%d: Invalid event type %d",
6336 obss_color_info->vdev_id, obss_color_info->evt_type);
6337 return;
6338 }
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006339}
6340#endif
Abhishek Singh20a8e442018-09-12 15:50:44 +05306341
6342#ifdef CONFIG_VDEV_SM
6343void lim_send_csa_restart_req(tpAniSirGlobal mac_ctx, uint8_t vdev_id)
6344{
6345 tpPESession session;
6346
6347 session = pe_find_session_by_sme_session_id(mac_ctx, vdev_id);
6348
6349 if (!session) {
6350 pe_err("session not found for vdev id %d", vdev_id);
6351 return;
6352 }
6353
6354 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
6355 WLAN_VDEV_SM_EV_CSA_RESTART,
6356 sizeof(*session), session);
6357}
6358#endif