blob: 07943cc8996cc36687d57b16a614d7b83f3a0286 [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;
Abhinav Kumarb074f2f2018-09-15 15:32:11 +0530808 if (!mac_ctx->mlme_cfg->vht_caps.vht_cap_info.enable2x2)
Kiran Kumar Lokerebc6fb2f2018-05-09 19:04:11 -0700809 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)) {
Arif Hussain88d1fdd2018-09-26 16:12:24 -07001039 session->lim11hEnable =
1040 mac_ctx->mlme_cfg->
1041 dfs_cfg.dfs_master_capable;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001042 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001043 }
1044
1045 if (!session->lim11hEnable) {
1046 if (cfg_set_int(mac_ctx,
1047 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001048 QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049 /*
1050 * Failed to set the CFG param
1051 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1052 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001053 pe_err("Set LOCAL_POWER_CONSTRAINT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001054 }
1055
Jiachao Wu712d4fd2017-08-23 16:52:34 +08001056 mlm_start_req->beacon_tx_rate = session->beacon_tx_rate;
1057
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001058 session->limPrevSmeState = session->limSmeState;
1059 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1060 MTRACE(mac_trace
1061 (mac_ctx, TRACE_CODE_SME_STATE,
1062 session->peSessionId,
1063 session->limSmeState));
1064
Abhishek Singhdfa69c32018-08-30 15:39:34 +05301065 qdf_status = lim_send_start_vdev_req(session, mlm_start_req);
1066 if (QDF_IS_STATUS_ERROR(qdf_status))
1067 goto free;
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05301068 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001069 return;
1070 } else {
1071
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001072 pe_err("Received unexpected START_BSS_REQ, in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001073 mac_ctx->lim.gLimSmeState);
1074 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001075 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001076 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1077
1078free:
1079 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001080 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001081 session->pLimStartBssReq = NULL;
1082 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001083 if (NULL != sme_start_bss_req)
1084 qdf_mem_free(sme_start_bss_req);
1085 if (NULL != mlm_start_req)
1086 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001087 if (NULL != session) {
1088 pe_delete_session(mac_ctx, session);
1089 session = NULL;
1090 }
1091 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1092 session, sme_session_id, sme_transaction_id);
1093}
1094
1095/**
1096 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1097 *
1098 * @pMac: Global MAC context
1099 * @pMsg: Message pointer
1100 *
1101 * Wrapper for the function __lim_handle_sme_start_bss_request
1102 * This message will be defered until softmac come out of
1103 * scan mode or if we have detected radar on the current
1104 * operating channel.
1105 *
1106 * return true - If we consumed the buffer
1107 * false - If have defered the message.
1108 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001109static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1110 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001111{
1112 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1113 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1114 /**
1115 * If message defered, buffer is not consumed yet.
1116 * So return false
1117 */
1118 return false;
1119 }
1120
1121 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1122 return true;
1123}
1124
1125/**
1126 * lim_get_random_bssid()
1127 *
1128 * FUNCTION:This function is called to process generate the random number for bssid
1129 * This function is called to process SME_SCAN_REQ message
1130 * from HDD or upper layer application.
1131 *
1132 * LOGIC:
1133 *
1134 * ASSUMPTIONS:
1135 *
1136 * NOTE:
1137 * 1. geneartes the unique random number for bssid in ibss
1138 *
1139 * @param pMac Pointer to Global MAC structure
1140 * @param *data Pointer to bssid buffer
1141 * @return None
1142 */
1143void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1144{
1145 uint32_t random[2];
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001146
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001147 random[0] = tx_time_get();
1148 random[0] |= (random[0] << 15);
1149 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301150 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001151}
1152
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001153/**
1154 * __lim_process_clear_dfs_channel_list()
1155 *
1156 ***FUNCTION:
Jeff Johnsonc00ae5b2018-05-06 16:06:35 -07001157 ***Clear DFS channel list when country is changed/acquired.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001158 .*This message is sent from SME.
1159 *
1160 ***LOGIC:
1161 *
1162 ***ASSUMPTIONS:
1163 *
1164 ***NOTE:
1165 *
1166 * @param pMac Pointer to Global MAC structure
1167 * @param *pMsgBuf A pointer to the SME message buffer
1168 * @return None
1169 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001170static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1171 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001172{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301173 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001174}
1175
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301176#ifdef WLAN_FEATURE_SAE
1177
1178/**
1179 * lim_update_sae_config()- This API update SAE session info to csr config
1180 * from join request.
1181 * @session: PE session
1182 * @sme_join_req: pointer to join request
1183 *
1184 * Return: None
1185 */
1186static void lim_update_sae_config(tpPESession session,
1187 tpSirSmeJoinReq sme_join_req)
1188{
1189 session->sae_pmk_cached = sme_join_req->sae_pmk_cached;
1190
1191 pe_debug("pmk_cached %d for BSSID=" MAC_ADDRESS_STR,
1192 session->sae_pmk_cached,
1193 MAC_ADDR_ARRAY(sme_join_req->bssDescription.bssId));
1194}
1195#else
1196static inline void lim_update_sae_config(tpPESession session,
1197 tpSirSmeJoinReq sme_join_req)
1198{}
1199#endif
1200
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001201/**
1202 * lim_send_join_req() - send vdev start request
1203 *@session: pe session
1204 *@mlm_join_req: join req
1205 *
1206 * Return: QDF_STATUS
1207 */
1208
1209#ifdef CONFIG_VDEV_SM
1210static QDF_STATUS lim_send_join_req(tpPESession session,
1211 tLimMlmJoinReq *mlm_join_req)
1212{
1213 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
1214 WLAN_VDEV_SM_EV_START,
1215 sizeof(*mlm_join_req),
1216 mlm_join_req);
1217}
1218#else
1219static QDF_STATUS lim_send_join_req(tpPESession session,
1220 tLimMlmJoinReq *mlm_join_req)
1221{
1222 lim_process_mlm_join_req(session->mac_ctx, mlm_join_req);
1223
1224 return QDF_STATUS_SUCCESS;
1225}
1226#endif
1227
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301228
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229/**
1230 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1231 * @mac_ctx: Pointer to Global MAC structure
1232 * @msg_buf: A pointer to the SME message buffer
1233 *
1234 * This function is called to process SME_JOIN_REQ message
1235 * from HDD or upper layer application.
1236 *
1237 * Return: None
1238 */
1239static void
1240__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1241{
1242 tpSirSmeJoinReq sme_join_req = NULL;
1243 tLimMlmJoinReq *mlm_join_req;
1244 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1245 uint32_t val = 0;
1246 uint16_t n_size;
1247 uint8_t session_id;
1248 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301249 uint8_t sme_session_id = 0;
1250 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001251 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001252 uint16_t ie_len;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001253 const uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001254 tSirBssDescription *bss_desc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001255
Arif Hussain995fcaf2016-07-18 11:28:22 -07001256 if (!mac_ctx || !msg_buf) {
1257 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1258 FL("JOIN REQ with invalid data"));
1259 return;
1260 }
1261
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001262/* FEATURE_WLAN_DIAG_SUPPORT */
1263#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1264 /*
1265 * Not sending any session, since it is not created yet.
1266 * The response whould have correct state.
1267 */
1268 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1269#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1270
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001271 /*
1272 * Expect Join request in idle state.
1273 * Reassociate request is expected in link established state.
1274 */
1275
1276 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1277 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1278 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1279 msg_buf);
1280
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301281 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001282 if (NULL == sme_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001283 pe_err("AllocateMemory failed for sme_join_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001284 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301285 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301287 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001288 n_size);
1289
1290 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1291 /* Received invalid eWNI_SME_JOIN_REQ */
1292 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001293 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001294 sme_join_req->sessionId);
1295 ret_code = eSIR_SME_INVALID_PARAMETERS;
1296 goto end;
1297 }
1298
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001299 /*
1300 * Update the capability here itself as this is used in
1301 * lim_extract_ap_capability() below. If not updated issues
1302 * like not honoring power constraint on 1st association after
1303 * driver loading might occur.
1304 */
1305 lim_update_rrm_capability(mac_ctx, sme_join_req);
1306
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001307 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001309 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001310 &session_id);
1311
1312 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001313 pe_err("Session(%d) Already exists for BSSID: "
1314 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001315 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001316 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001317 session->limSmeState);
1318
1319 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1320 session->smeSessionId == sme_join_req->sessionId) {
1321 /*
1322 * Received eWNI_SME_JOIN_REQ for same
1323 * BSS as currently associated.
1324 * Log the event and send success
1325 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001326 pe_warn("SessionId: %d", session_id);
1327 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328 /* Send Join success response to host */
1329 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1330 session = NULL;
1331 goto end;
1332 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001333 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334 ret_code = eSIR_SME_REFUSED;
1335 session = NULL;
1336 goto end;
1337 }
1338 } else {
1339 /*
1340 * Session Entry does not exist for given BSSId
1341 * Try to Create a new session
1342 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001343 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001344 &session_id, mac_ctx->lim.maxStation,
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +05301345 eSIR_INFRASTRUCTURE_MODE,
1346 sme_join_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001347 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001348 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001349 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1350 goto end;
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301351 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001352 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001353 session_id);
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301354 }
1355
1356 /* Update the beacon/probe filter in mac_ctx */
1357 lim_set_bcn_probe_filter(mac_ctx, session,
1358 &sme_join_req->ssId,
1359 bss_desc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001360 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001361 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Arif Hussain6686c0b2018-08-21 18:21:05 -07001362 session->enable_session_twt_support =
1363 sme_join_req->enable_session_twt_support;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001364 /*
1365 * Store Session related parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001366 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001367
1368 /* store the smejoin req handle in session table */
1369 session->pLimJoinReq = sme_join_req;
1370
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001371 /* Store SME transaction Id in session Table */
1372 session->transactionId = sme_join_req->transactionId;
1373
1374 /* Store beaconInterval */
1375 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001376 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301378 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001379 sizeof(session->htConfig));
1380
Sandeep Puligilla98917432016-06-10 13:50:28 -07001381 qdf_mem_copy(&(session->vht_config),
1382 &(sme_join_req->vht_config),
1383 sizeof(session->vht_config));
1384
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001385 /* Copying of bssId is already done, while creating session */
1386 sir_copy_mac_addr(session->selfMacAddr,
1387 sme_join_req->selfMacAddr);
1388 session->bssType = sme_join_req->bsstype;
1389
1390 session->statypeForBss = STA_ENTRY_PEER;
1391 session->limWmeEnabled = sme_join_req->isWMEenabled;
1392 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301393 session->wps_registration = sme_join_req->wps_registration;
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001394 session->he_with_wep_tkip = sme_join_req->he_with_wep_tkip;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001395
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301396 session->enable_bcast_probe_rsp =
1397 sme_join_req->enable_bcast_probe_rsp;
1398
Jeff Johnson179fd8a2018-05-11 14:20:05 -07001399 /* Store vendor specific IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001400 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1402
Naveen Rawat08db88f2017-09-08 15:07:48 -07001403 vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001404 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001405 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001406
1407 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001408 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001409 session->isCiscoVendorAP = true;
1410 } else {
1411 session->isCiscoVendorAP = false;
1412 }
1413
1414 /* Copy the dot 11 mode in to the session table */
1415
1416 session->dot11mode = sme_join_req->dot11mode;
1417#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1418 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1419#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001420 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001421 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1422 session->enableHtSmps = sme_join_req->enableHtSmps;
1423 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001424 session->send_smps_action =
1425 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001426 /*
1427 * By default supported NSS 1x1 is set to true
1428 * and later on updated while determining session
1429 * supported rates which is the intersection of
1430 * self and peer rates
1431 */
1432 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301433 /*Store Persona */
1434 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001435 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 -08001436 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001437 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001438 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301439 session->supported_nss_1x1,
1440 session->pePersona,
1441 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001442
1443 /*Store Persona */
1444 session->pePersona = sme_join_req->staPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +05301445 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301446 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d force_24ghz_in_ht20 %d"),
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001447 session->pePersona, sme_join_req->cbMode,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301448 session->nwType, session->dot11mode,
1449 sme_join_req->force_24ghz_in_ht20);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001450
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001451 /* Copy The channel Id to the session Table */
1452 session->currentOperChannel = bss_desc->channelId;
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301453
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001454 session->vhtCapability =
1455 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001456 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301457 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001458 session->vht_config.su_beam_formee =
1459 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001460 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001461 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001462 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001463 session->enableVhtpAid =
1464 sme_join_req->enableVhtpAid;
1465 session->enableVhtGid =
1466 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001467 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001468 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001469 }
Krunal Soni53993f72016-07-08 18:20:03 -07001470
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001471 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301472 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001473 session->vht_config.su_beam_formee,
1474 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001475 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001476 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001477 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001478 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301479 session->force_24ghz_in_ht20 =
1480 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001481 /* cbMode is already merged value of peer and self -
1482 * done by csr in csr_get_cb_mode_from_ies */
1483 session->htSupportedChannelWidthSet =
1484 (sme_join_req->cbMode) ? 1 : 0;
1485 session->htRecommendedTxWidthSet =
1486 session->htSupportedChannelWidthSet;
1487 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1488
1489 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1490 session->ch_center_freq_seg0 =
1491 session->currentOperChannel - 2;
1492 session->ch_width = CH_WIDTH_40MHZ;
1493 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1494 sme_join_req->cbMode) {
1495 session->ch_center_freq_seg0 =
1496 session->currentOperChannel + 2;
1497 session->ch_width = CH_WIDTH_40MHZ;
1498 } else {
1499 session->ch_center_freq_seg0 = 0;
1500 session->ch_width = CH_WIDTH_20MHZ;
1501 }
1502
Naveen Rawataeca1b92017-10-16 16:55:31 -07001503 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1504 lim_update_session_he_capable(mac_ctx, session);
1505 lim_copy_join_req_he_cap(session, sme_join_req);
1506 }
1507
1508
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001509 /* Record if management frames need to be protected */
1510#ifdef WLAN_FEATURE_11W
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +05301511 if ((eSIR_ED_AES_128_CMAC ==
1512 sme_join_req->MgmtEncryptionType) ||
1513 (eSIR_ED_AES_GMAC_128 == sme_join_req->MgmtEncryptionType) ||
1514 (eSIR_ED_AES_GMAC_256 == sme_join_req->MgmtEncryptionType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001515 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001516 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001517 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001518#endif
1519
1520#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001521 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001522#endif
1523
1524 /* Copy the SSID from smejoinreq to session entry */
1525 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301526 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001527 session->ssId.length);
1528
1529 /*
1530 * Determin 11r or ESE connection based on input from SME
1531 * which inturn is dependent on the profile the user wants
1532 * to connect to, So input is coming from supplicant
1533 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001534 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001535#ifdef FEATURE_WLAN_ESE
1536 session->isESEconnection = sme_join_req->isESEconnection;
1537#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001538 session->isFastTransitionEnabled =
1539 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001540
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001541 session->isFastRoamIniFeatureEnabled =
1542 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001543 session->txLdpcIniFeatureEnabled =
1544 sme_join_req->txLdpcIniFeatureEnabled;
1545
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301546 lim_update_fils_config(session, sme_join_req);
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301547 lim_update_sae_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001548 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1549 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001550 } else {
1551 /*
1552 * Throw an error and return and make
1553 * sure to delete the session.
1554 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001555 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001556 session->bssType);
1557 ret_code = eSIR_SME_INVALID_PARAMETERS;
1558 goto end;
1559 }
1560
1561 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301562 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001563 &sme_join_req->addIEScan, sizeof(tSirAddie));
1564
1565 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301566 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001567 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1568
1569 val = sizeof(tLimMlmJoinReq) +
1570 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301571 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001572 if (NULL == mlm_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001573 pe_err("AllocateMemory failed for mlmJoinReq");
Nitesh Shah0102cac2016-07-13 14:38:30 +05301574 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1575 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001576 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001577
1578 /* PE SessionId is stored as a part of JoinReq */
1579 mlm_join_req->sessionId = session->peSessionId;
1580
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301582 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001583 (void *)&sme_join_req->operationalRateSet,
1584 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301585 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001586 (void *)&sme_join_req->extendedRateSet,
1587 sizeof(tSirMacRateSet));
1588 /*
1589 * this may not be needed anymore now, as rateSet is now
1590 * included in the session entry and MLM has session context.
1591 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301592 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001593 (void *)&session->rateSet,
1594 sizeof(tSirMacRateSet));
1595
1596 session->encryptType = sme_join_req->UCEncryptionType;
1597
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301598 session->supported_nss_1x1 = sme_join_req->supported_nss_1x1;
1599 session->vdev_nss = sme_join_req->vdev_nss;
1600 session->nss = sme_join_req->nss;
1601 session->nss_forced_1x1 = sme_join_req->nss_forced_1x1;
1602
1603 pe_debug("nss %d, vdev_nss %d, supported_nss_1x1 %d",
1604 session->nss,
1605 session->vdev_nss,
1606 session->supported_nss_1x1);
1607
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001608 mlm_join_req->bssDescription.length =
1609 session->pLimJoinReq->bssDescription.length;
1610
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301611 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001612 (uint8_t *)
1613 &session->pLimJoinReq->bssDescription.bssId,
1614 session->pLimJoinReq->bssDescription.length + 2);
1615
1616 session->limCurrentBssCaps =
1617 session->pLimJoinReq->bssDescription.capabilityInfo;
1618
1619 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1620 session->currentOperChannel);
1621 local_power_constraint = reg_max;
1622
1623 lim_extract_ap_capability(mac_ctx,
1624 (uint8_t *)
1625 session->pLimJoinReq->bssDescription.ieFields,
1626 lim_get_ielen_from_bss_description(
1627 &session->pLimJoinReq->bssDescription),
1628 &session->limCurrentBssQosCaps,
1629 &session->limCurrentBssPropCap,
1630 &session->gLimCurrentBssUapsd,
1631 &local_power_constraint, session);
1632
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001633 session->maxTxPower = lim_get_max_tx_power(reg_max,
1634 local_power_constraint,
1635 mac_ctx->roam.configParam.nTxPowerCap);
Abhinav Kumard528d192018-03-09 17:31:12 +05301636 session->def_max_tx_pwr = session->maxTxPower;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301637
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001638 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301639 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001640
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301641 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1642 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1643 pe_debug("Update MaxTxPower in join Req to %d",
1644 sme_join_req->powerCap.maxTxPower);
1645 }
1646
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001647 if (session->gLimCurrentBssUapsd) {
1648 session->gUapsdPerAcBitmask =
1649 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001650 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001651 session->gUapsdPerAcBitmask);
1652
1653 /* resetting the dynamic uapsd mask */
1654 session->gUapsdPerAcDeliveryEnableMask = 0;
1655 session->gUapsdPerAcTriggerEnableMask = 0;
1656 }
1657
1658 session->limRFBand =
1659 lim_get_rf_band(session->currentOperChannel);
1660
1661 /* Initialize 11h Enable Flag */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001662 if (BAND_5G == session->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001663 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001664 &val) != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001665 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001666 session->lim11hEnable =
1667 WNI_CFG_11H_ENABLED_STADEF;
1668 } else {
1669 session->lim11hEnable = val;
1670 }
1671 } else {
1672 session->lim11hEnable = 0;
1673 }
1674
1675 /*
1676 * To care of the scenario when STA transitions from
1677 * IBSS to Infrastructure mode.
1678 */
1679 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1680
1681 session->limPrevSmeState = session->limSmeState;
1682 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1683 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1684 session->peSessionId,
1685 session->limSmeState));
1686
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001687 /* Indicate whether spectrum management is enabled */
1688 session->spectrumMgtEnabled =
1689 sme_join_req->spectrumMgtIndicator;
1690
1691 /* Enable the spectrum management if this is a DFS channel */
1692 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001693 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001694 session->currentOperChannel))
1695 session->spectrumMgtEnabled = true;
1696
1697 session->isOSENConnection = sme_join_req->isOSENConnection;
1698
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001699 /* Issue LIM_MLM_JOIN_REQ to MLM */
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001700 lim_send_join_req(session, mlm_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001701 return;
1702
1703 } else {
1704 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001705 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001706 mac_ctx->lim.gLimSmeState);
1707 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1708 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1709 session = NULL;
1710 goto end;
1711 }
1712
1713end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301714 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1715 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001716
1717 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301718 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001719 sme_join_req = NULL;
1720 if (NULL != session)
1721 session->pLimJoinReq = NULL;
1722 }
1723 if (ret_code != eSIR_SME_SUCCESS) {
1724 if (NULL != session) {
1725 pe_delete_session(mac_ctx, session);
1726 session = NULL;
1727 }
1728 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001729 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001730 sme_session_id, ret_code);
1731 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1732 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1733 sme_transaction_id);
1734}
1735
Amar Singhala297bfa2015-10-15 15:07:29 -07001736uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001737 uint8_t iniTxPower)
1738{
1739 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301740 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001741
Anurag Chouhan6d760662016-02-20 16:05:43 +05301742 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001743 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1744 maxTxPower = txPower;
1745 else if (txPower < MIN_TX_PWR_CAP)
1746 maxTxPower = MIN_TX_PWR_CAP;
1747 else
1748 maxTxPower = MAX_TX_PWR_CAP;
1749
1750 return maxTxPower;
1751}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001752
1753/**
1754 * __lim_process_sme_reassoc_req() - process reassoc req
1755 *
1756 * @mac_ctx: Pointer to Global MAC structure
1757 * @msg_buf: pointer to the SME message buffer
1758 *
1759 * This function is called to process SME_REASSOC_REQ message
1760 * from HDD or upper layer application.
1761 *
1762 * Return: None
1763 */
1764
1765static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
1766 uint32_t *msg_buf)
1767{
1768 uint16_t caps;
1769 uint32_t val;
1770 tpSirSmeJoinReq reassoc_req = NULL;
1771 tLimMlmReassocReq *mlm_reassoc_req;
1772 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1773 tpPESession session_entry = NULL;
1774 uint8_t session_id;
1775 uint8_t sme_session_id;
1776 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001777 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001778 uint32_t tele_bcn_en = 0;
1779 uint16_t size;
1780
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001781 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301782 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001783 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001784 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001785
1786 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1787 goto end;
1788 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301789 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001790
1791 if (!lim_is_sme_join_req_valid(mac_ctx,
1792 (tpSirSmeJoinReq)reassoc_req)) {
1793 /*
1794 * Received invalid eWNI_SME_REASSOC_REQ
1795 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001796 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001797
1798 ret_code = eSIR_SME_INVALID_PARAMETERS;
1799 goto end;
1800 }
1801
1802 session_entry = pe_find_session_by_bssid(mac_ctx,
1803 reassoc_req->bssDescription.bssId,
1804 &session_id);
1805 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001806 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001807 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
1808 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001810 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
1811 &sme_session_id, &transaction_id);
1812 session_entry =
1813 pe_find_session_by_sme_session_id(mac_ctx,
1814 sme_session_id);
1815 if (session_entry != NULL)
1816 lim_handle_sme_join_result(mac_ctx,
1817 eSIR_SME_INVALID_PARAMETERS,
1818 eSIR_MAC_UNSPEC_FAILURE_STATUS,
1819 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001820 goto end;
1821 }
1822#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
1823 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001824 session_entry, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001825#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1826 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
1827
1828 /* Store the reassoc handle in the session Table */
1829 session_entry->pLimReAssocReq = reassoc_req;
1830
1831 session_entry->dot11mode = reassoc_req->dot11mode;
1832 session_entry->vhtCapability =
1833 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001834
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301835 if (session_entry->vhtCapability) {
1836 if (session_entry->pePersona == QDF_STA_MODE) {
1837 session_entry->vht_config.su_beam_formee =
1838 reassoc_req->vht_config.su_beam_formee;
1839 } else {
1840 reassoc_req->vht_config.su_beam_formee = 0;
1841 }
1842 session_entry->enableVhtpAid =
1843 reassoc_req->enableVhtpAid;
1844 session_entry->enableVhtGid =
1845 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001846 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301847 }
1848
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301849 session_entry->supported_nss_1x1 = reassoc_req->supported_nss_1x1;
1850 session_entry->vdev_nss = reassoc_req->vdev_nss;
1851 session_entry->nss = reassoc_req->nss;
1852 session_entry->nss_forced_1x1 = reassoc_req->nss_forced_1x1;
1853
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001854 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301855 session_entry->vhtCapability,
1856 session_entry->vht_config.su_beam_formee,
1857 session_entry->vht_config.su_beam_former);
1858
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001859 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
1860 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001861 session_entry->send_smps_action =
1862 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001863 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001864 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001865 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001866 session_entry->send_smps_action,
1867 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868 /*
1869 * Reassociate request is expected
1870 * in link established state only.
1871 */
1872
1873 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001874 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
1875 /*
1876 * May be from 11r FT pre-auth. So lets check it
1877 * before we bail out
1878 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001879 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001880 session_entry->peSessionId);
1881
1882 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301883 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001884 session_entry->limReAssocbssId,
1885 6)) {
1886 lim_print_mac_addr(mac_ctx,
1887 reassoc_req->bssDescription.
1888 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001889 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890 ret_code = eSIR_SME_INVALID_PARAMETERS;
1891 goto end;
1892 }
1893
1894 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
1895 session_entry);
1896 return;
1897 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001898 /*
1899 * Should not have received eWNI_SME_REASSOC_REQ
1900 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001901 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001902 session_entry->limSmeState);
1903 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
1904
1905 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1906 goto end;
1907 }
1908
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301909 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001910 session_entry->pLimReAssocReq->bssDescription.bssId,
1911 sizeof(tSirMacAddr));
1912
1913 session_entry->limReassocChannelId =
1914 session_entry->pLimReAssocReq->bssDescription.channelId;
1915
1916 session_entry->reAssocHtSupportedChannelWidthSet =
1917 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
1918 session_entry->reAssocHtRecommendedTxWidthSet =
1919 session_entry->reAssocHtSupportedChannelWidthSet;
1920 session_entry->reAssocHtSecondaryChannelOffset =
1921 session_entry->pLimReAssocReq->cbMode;
1922
1923 session_entry->limReassocBssCaps =
1924 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
1925 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1926 session_entry->currentOperChannel);
1927 local_pwr_constraint = reg_max;
1928
1929 lim_extract_ap_capability(mac_ctx,
1930 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
1931 lim_get_ielen_from_bss_description(
1932 &session_entry->pLimReAssocReq->bssDescription),
1933 &session_entry->limReassocBssQosCaps,
1934 &session_entry->limReassocBssPropCap,
1935 &session_entry->gLimCurrentBssUapsd,
1936 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05301937 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001938 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301939 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001940 /* Copy the SSID from session entry to local variable */
1941 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301942 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001943 reassoc_req->ssId.ssId,
1944 session_entry->limReassocSSID.length);
1945 if (session_entry->gLimCurrentBssUapsd) {
1946 session_entry->gUapsdPerAcBitmask =
1947 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001948 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001949 session_entry->gUapsdPerAcBitmask);
1950 }
1951
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301952 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001953 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001954 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001955
1956 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1957 goto end;
1958 }
1959
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301960 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001961 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
1962
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001963 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001964 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001965 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301966
1967 lim_update_caps_info_for_bss(mac_ctx, &caps,
1968 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001969 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301970
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001971 mlm_reassoc_req->capabilityInfo = caps;
1972
1973 /* Update PE session_id */
1974 mlm_reassoc_req->sessionId = session_id;
1975
1976 /*
1977 * If telescopic beaconing is enabled, set listen interval to
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05301978 * CFG_TELE_BCN_MAX_LI
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001979 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001980
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05301981 tele_bcn_en = mac_ctx->mlme_cfg->sap_cfg.tele_bcn_wakeup_en;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001982
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05301983 if (tele_bcn_en)
1984 val = mac_ctx->mlme_cfg->sap_cfg.tele_bcn_max_li;
1985 else
1986 val = mac_ctx->mlme_cfg->sap_cfg.listen_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987
1988 mlm_reassoc_req->listenInterval = (uint16_t) val;
1989
1990 /* Indicate whether spectrum management is enabled */
1991 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
1992
1993 /* Enable the spectrum management if this is a DFS channel */
1994 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001995 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001996 session_entry->currentOperChannel))
1997 session_entry->spectrumMgtEnabled = true;
1998
1999 session_entry->limPrevSmeState = session_entry->limSmeState;
2000 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2001
2002 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2003 session_entry->peSessionId,
2004 session_entry->limSmeState));
2005
2006 lim_post_mlm_message(mac_ctx,
2007 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2008 return;
2009end:
2010 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302011 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002012 if (session_entry)
2013 session_entry->pLimReAssocReq = NULL;
2014 }
2015
2016 if (session_entry) {
2017 /*
2018 * error occurred after we determined the session so extract
2019 * session and transaction info from there
2020 */
2021 sme_session_id = session_entry->smeSessionId;
2022 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002023 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002024 /*
2025 * error occurred before or during the time we determined
2026 * the session so extract the session and transaction info
2027 * from the message
2028 */
2029 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2030 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002031 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002032 /*
2033 * Send Reassoc failure response to host
2034 * (note session_entry may be NULL, but that's OK)
2035 */
2036 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2037 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2038 session_entry, sme_session_id,
2039 transaction_id);
2040}
2041
2042bool send_disassoc_frame = 1;
2043/**
2044 * __lim_process_sme_disassoc_req()
2045 *
2046 ***FUNCTION:
2047 * This function is called to process SME_DISASSOC_REQ message
2048 * from HDD or upper layer application.
2049 *
2050 ***LOGIC:
2051 *
2052 ***ASSUMPTIONS:
2053 *
2054 ***NOTE:
2055 *
2056 * @param pMac Pointer to Global MAC structure
2057 * @param *pMsgBuf A pointer to the SME message buffer
2058 * @return None
2059 */
2060
2061static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2062{
2063 uint16_t disassocTrigger, reasonCode;
2064 tLimMlmDisassocReq *pMlmDisassocReq;
2065 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2066 tSirSmeDisassocReq smeDisassocReq;
2067 tpPESession psessionEntry = NULL;
2068 uint8_t sessionId;
2069 uint8_t smesessionId;
2070 uint16_t smetransactionId;
2071
2072 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002073 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002074 return;
2075 }
2076
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302077 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002078 smesessionId = smeDisassocReq.sessionId;
2079 smetransactionId = smeDisassocReq.transactionId;
2080 if (!lim_is_sme_disassoc_req_valid(pMac,
2081 &smeDisassocReq,
2082 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002083 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002084 if (pMac->lim.gLimRspReqd) {
2085 pMac->lim.gLimRspReqd = false;
2086
2087 retCode = eSIR_SME_INVALID_PARAMETERS;
2088 disassocTrigger = eLIM_HOST_DISASSOC;
2089 goto sendDisassoc;
2090 }
2091
2092 return;
2093 }
2094
2095 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002096 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002097 &sessionId);
2098 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002099 pe_err("session does not exist for given bssId "
2100 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002101 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002102 retCode = eSIR_SME_INVALID_PARAMETERS;
2103 disassocTrigger = eLIM_HOST_DISASSOC;
2104 goto sendDisassoc;
2105 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002106 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2107 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002108 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2109 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002110 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002111
2112#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2113 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2114 0, smeDisassocReq.reasonCode);
2115#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2116
2117 /* Update SME session Id and SME transaction ID */
2118
2119 psessionEntry->smeSessionId = smesessionId;
2120 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002121 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002122 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002123
2124 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2125 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002126 switch (psessionEntry->limSmeState) {
2127 case eLIM_SME_ASSOCIATED_STATE:
2128 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002129 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002130 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002131 psessionEntry->limPrevSmeState =
2132 psessionEntry->limSmeState;
2133 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002134 /* Delete all TDLS peers connected before leaving BSS */
2135 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002136 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2137 psessionEntry->peSessionId,
2138 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002139 break;
2140
2141 case eLIM_SME_WT_DEAUTH_STATE:
2142 /* PE shall still process the DISASSOC_REQ and proceed with
2143 * link tear down even if it had already sent a DEAUTH_IND to
2144 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2145 * its been set when PE entered WT_DEAUTH_STATE.
2146 */
2147 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2148 MTRACE(mac_trace
2149 (pMac, TRACE_CODE_SME_STATE,
2150 psessionEntry->peSessionId,
2151 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002152 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002153 break;
2154
2155 case eLIM_SME_WT_DISASSOC_STATE:
Jeff Johnson47d75242018-05-12 15:58:53 -07002156 /* PE Received a Disassoc frame. Normally it gets DISASSOC_CNF but it
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002157 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2158 * PE can continue processing DISASSOC_REQ and send the response instead
2159 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2160 * for disassoc frame.
2161 *
2162 * It will send a disassoc, which is ok. However, we can use the global flag
2163 * sendDisassoc to not send disassoc frame.
2164 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002165 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002166 break;
2167
2168 case eLIM_SME_JOIN_FAILURE_STATE: {
2169 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002170 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002171 if (pMac->lim.gLimRspReqd) {
2172 retCode = eSIR_SME_SUCCESS;
2173 disassocTrigger = eLIM_HOST_DISASSOC;
2174 goto sendDisassoc;
2175 }
2176 }
2177 break;
2178 default:
2179 /**
2180 * STA is not currently associated.
2181 * Log error and send response to host
2182 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002183 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002184 psessionEntry->limSmeState);
2185 lim_print_sme_state(pMac, LOGE,
2186 psessionEntry->limSmeState);
2187
2188 if (pMac->lim.gLimRspReqd) {
2189 if (psessionEntry->limSmeState !=
2190 eLIM_SME_WT_ASSOC_STATE)
2191 pMac->lim.gLimRspReqd = false;
2192
2193 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2194 disassocTrigger = eLIM_HOST_DISASSOC;
2195 goto sendDisassoc;
2196 }
2197
2198 return;
2199 }
2200
2201 break;
2202
2203 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002204 /* Fall through */
2205 break;
2206
2207 case eLIM_STA_IN_IBSS_ROLE:
2208 default:
2209 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002210 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002211 GET_LIM_SYSTEM_ROLE(psessionEntry));
2212
2213 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2214 disassocTrigger = eLIM_HOST_DISASSOC;
2215 goto sendDisassoc;
2216 } /* end switch (pMac->lim.gLimSystemRole) */
2217
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302218 disassocTrigger = eLIM_HOST_DISASSOC;
2219 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002220
2221 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002222 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002223 send_disassoc_frame = 0;
2224 }
2225 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002226 pe_debug("Sending Disasscoc with disassoc Trigger"
2227 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002228 disassocTrigger, reasonCode);
2229
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302230 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002231 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002232 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002233 return;
2234 }
2235
Anurag Chouhanc5548422016-02-24 18:33:27 +05302236 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002237 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002238
2239 pMlmDisassocReq->reasonCode = reasonCode;
2240 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2241
2242 /* Update PE session ID */
2243 pMlmDisassocReq->sessionId = sessionId;
2244
2245 lim_post_mlm_message(pMac,
2246 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2247 return;
2248
2249sendDisassoc:
2250 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002251 lim_send_sme_disassoc_ntf(pMac,
2252 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002253 retCode,
2254 disassocTrigger,
2255 1, smesessionId, smetransactionId,
2256 psessionEntry);
2257 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002258 lim_send_sme_disassoc_ntf(pMac,
2259 smeDisassocReq.peer_macaddr.bytes,
2260 retCode, disassocTrigger, 1,
2261 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002262
2263} /*** end __lim_process_sme_disassoc_req() ***/
2264
2265/** -----------------------------------------------------------------
2266 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2267
2268 This function is called to process SME_DISASSOC_CNF message
2269 from HDD or upper layer application.
2270
2271 \param pMac - global mac structure
2272 \param pStaDs - station dph hash node
2273 \return none
2274 \sa
2275 ----------------------------------------------------------------- */
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002276void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002277{
2278 tSirSmeDisassocCnf smeDisassocCnf;
2279 uint16_t aid;
2280 tpDphHashNode pStaDs;
2281 tpPESession psessionEntry;
2282 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302283 uint32_t *msg = NULL;
2284 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002285
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302286 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002287 sizeof(struct sSirSmeDisassocCnf));
2288
2289 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002290 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002291 &sessionId);
2292 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002293 pe_err("session does not exist for given bssId");
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302294 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302295 smeDisassocCnf.sme_session_id,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302296 eSIR_SME_INVALID_SESSION,
2297 NULL);
2298 if (QDF_IS_STATUS_SUCCESS(status))
2299 lim_send_sme_disassoc_deauth_ntf(pMac,
2300 QDF_STATUS_SUCCESS,
2301 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002302 return;
2303 }
2304
2305 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002306 pe_err("received invalid SME_DISASSOC_CNF message");
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302307 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2308 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302309 eSIR_SME_INVALID_PARAMETERS,
2310 &smeDisassocCnf.bssid.bytes[0]);
2311 if (QDF_IS_STATUS_SUCCESS(status))
2312 lim_send_sme_disassoc_deauth_ntf(pMac,
2313 QDF_STATUS_SUCCESS,
2314 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002315 return;
2316 }
2317#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2318 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2319 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2320 psessionEntry,
2321 (uint16_t) smeDisassocCnf.statusCode, 0);
2322 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2323 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2324 psessionEntry,
2325 (uint16_t) smeDisassocCnf.statusCode, 0);
2326#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2327
2328 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2329 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002330 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2331 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2332 && (psessionEntry->limSmeState !=
2333 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002334 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002335 psessionEntry->limSmeState);
2336 lim_print_sme_state(pMac, LOGE,
2337 psessionEntry->limSmeState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302338 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302339 psessionEntry->smeSessionId,
2340 eSIR_SME_INVALID_STATE,
2341 &smeDisassocCnf.bssid.bytes[0]);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302342 if (QDF_IS_STATUS_SUCCESS(status))
2343 lim_send_sme_disassoc_deauth_ntf(pMac,
2344 QDF_STATUS_SUCCESS,
2345 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002346 return;
2347 }
2348 break;
2349
2350 case eLIM_AP_ROLE:
2351 /* Fall through */
2352 break;
2353
2354 case eLIM_STA_IN_IBSS_ROLE:
2355 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002356 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002357 GET_LIM_SYSTEM_ROLE(psessionEntry));
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302358 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2359 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302360 eSIR_SME_INVALID_STATE,
2361 &smeDisassocCnf.bssid.bytes[0]);
2362 if (QDF_IS_STATUS_SUCCESS(status))
2363 lim_send_sme_disassoc_deauth_ntf(pMac,
2364 QDF_STATUS_SUCCESS,
2365 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002366 return;
2367 }
2368
2369 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2370 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2371 LIM_IS_AP_ROLE(psessionEntry)) {
2372 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002373 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002374 &psessionEntry->dph.dphHashTable);
2375 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002376 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2377 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002378 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302379 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302380 psessionEntry->smeSessionId,
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05302381 eSIR_SME_INVALID_PARAMETERS,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302382 &smeDisassocCnf.bssid.bytes[0]);
2383 if (QDF_IS_STATUS_SUCCESS(status))
2384 lim_send_sme_disassoc_deauth_ntf(pMac,
2385 QDF_STATUS_SUCCESS,
2386 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002387 return;
2388 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302389
2390 if ((pStaDs->mlmStaContext.mlmState ==
2391 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2392 (pStaDs->mlmStaContext.mlmState ==
Arif Hussain5fa13782018-05-10 11:29:52 -07002393 eLIM_MLM_WT_DEL_BSS_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002394 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002395 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302396 pStaDs->mlmStaContext.mlmState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302397 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302398 psessionEntry->smeSessionId,
2399 eSIR_SME_SUCCESS,
2400 NULL);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302401 if (QDF_IS_STATUS_SUCCESS(status))
2402 lim_send_sme_disassoc_deauth_ntf(pMac,
2403 QDF_STATUS_SUCCESS,
2404 (uint32_t *)msg);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302405 return;
2406 }
2407
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 /* Delete FT session if there exists one */
2409 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002410 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2411
2412 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002413 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002414 }
2415
2416 return;
2417}
2418
2419/**
2420 * __lim_process_sme_deauth_req() - process sme deauth req
2421 * @mac_ctx: Pointer to Global MAC structure
2422 * @msg_buf: pointer to the SME message buffer
2423 *
2424 * This function is called to process SME_DEAUTH_REQ message
2425 * from HDD or upper layer application.
2426 *
2427 * Return: None
2428 */
2429
2430static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2431 uint32_t *msg_buf)
2432{
2433 uint16_t deauth_trigger, reason_code;
2434 tLimMlmDeauthReq *mlm_deauth_req;
2435 tSirSmeDeauthReq sme_deauth_req;
2436 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2437 tpPESession session_entry;
2438 uint8_t session_id; /* PE sessionId */
2439 uint8_t sme_session_id;
2440 uint16_t sme_transaction_id;
2441
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302442 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002443 sme_session_id = sme_deauth_req.sessionId;
2444 sme_transaction_id = sme_deauth_req.transactionId;
2445
2446 /*
2447 * We need to get a session first but we don't even know
2448 * if the message is correct.
2449 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002450 session_entry = pe_find_session_by_bssid(mac_ctx,
2451 sme_deauth_req.bssid.bytes,
2452 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002453 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002454 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002455 ret_code = eSIR_SME_INVALID_PARAMETERS;
2456 deauth_trigger = eLIM_HOST_DEAUTH;
2457 goto send_deauth;
2458 }
2459
2460 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2461 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002462 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002463 mac_ctx->lim.gLimRspReqd = false;
2464
2465 ret_code = eSIR_SME_INVALID_PARAMETERS;
2466 deauth_trigger = eLIM_HOST_DEAUTH;
2467 goto send_deauth;
2468 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002469 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2470 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002471 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2472 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002473 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002474#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2475 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2476 session_entry, 0, sme_deauth_req.reasonCode);
2477#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2478
2479 /* Update SME session ID and Transaction ID */
2480 session_entry->smeSessionId = sme_session_id;
2481 session_entry->transactionId = sme_transaction_id;
2482
2483 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2484 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002485 switch (session_entry->limSmeState) {
2486 case eLIM_SME_ASSOCIATED_STATE:
2487 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302488 /* Delete all TDLS peers connected before leaving BSS */
2489 lim_delete_tdls_peers(mac_ctx, session_entry);
Abhinav Kumarac12c762018-05-02 13:51:02 +05302490 /* fallthrough */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002491 case eLIM_SME_WT_ASSOC_STATE:
2492 case eLIM_SME_JOIN_FAILURE_STATE:
2493 case eLIM_SME_IDLE_STATE:
2494 session_entry->limPrevSmeState =
2495 session_entry->limSmeState;
2496 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2497 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2498 session_entry->peSessionId,
2499 session_entry->limSmeState));
2500 /* Send Deauthentication request to MLM below */
2501 break;
2502 case eLIM_SME_WT_DEAUTH_STATE:
2503 case eLIM_SME_WT_DISASSOC_STATE:
2504 /*
Jeff Johnson47d75242018-05-12 15:58:53 -07002505 * PE Received a Deauth/Disassoc frame. Normally it get
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002506 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2507 * Which means host is also trying to disconnect.
2508 * PE can continue processing DEAUTH_REQ and send
2509 * the response instead of failing the request.
2510 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2511 * was sent for deauth/disassoc frame.
2512 */
2513 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002514 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002515 break;
2516 default:
2517 /*
2518 * STA is not in a state to deauthenticate with
2519 * peer. Log error and send response to host.
2520 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002521 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002522 session_entry->limSmeState);
2523 lim_print_sme_state(mac_ctx, LOGE,
2524 session_entry->limSmeState);
2525
2526 if (mac_ctx->lim.gLimRspReqd) {
2527 mac_ctx->lim.gLimRspReqd = false;
2528
2529 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2530 deauth_trigger = eLIM_HOST_DEAUTH;
2531
wadesong42968e92017-06-08 14:11:21 +08002532 /*
2533 * here we received deauth request from AP so
2534 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2535 * have ISSUED delSta then mlm state should be
2536 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2537 * delBSS rsp then mlm state should be
2538 * eLIM_MLM_IDLE_STATE so the below condition
2539 * captures the state where delSta not done
2540 * and firmware still in connected state.
2541 */
2542 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002543 eLIM_SME_WT_DEAUTH_STATE &&
2544 session_entry->limMlmState !=
2545 eLIM_MLM_IDLE_STATE &&
2546 session_entry->limMlmState !=
2547 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002548 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002549 goto send_deauth;
2550 }
2551 return;
2552 }
2553 break;
2554
2555 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002556 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002557 if (mac_ctx->lim.gLimRspReqd) {
2558 mac_ctx->lim.gLimRspReqd = false;
2559 ret_code = eSIR_SME_INVALID_PARAMETERS;
2560 deauth_trigger = eLIM_HOST_DEAUTH;
2561 goto send_deauth;
2562 }
2563 return;
2564 case eLIM_AP_ROLE:
2565 break;
2566 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002567 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002568 GET_LIM_SYSTEM_ROLE(session_entry));
2569 if (mac_ctx->lim.gLimRspReqd) {
2570 mac_ctx->lim.gLimRspReqd = false;
2571 ret_code = eSIR_SME_INVALID_PARAMETERS;
2572 deauth_trigger = eLIM_HOST_DEAUTH;
2573 goto send_deauth;
2574 }
2575 return;
2576 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2577
Yu Ouyang57c25532018-09-07 17:14:01 +08002578 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH &&
2579 session_entry->limSystemRole == eLIM_STA_ROLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002580 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002581 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002582 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2583 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2584 } else {
2585 deauth_trigger = eLIM_HOST_DEAUTH;
2586 reason_code = sme_deauth_req.reasonCode;
2587 }
2588
2589 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302590 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002591 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002592 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002593 if (mac_ctx->lim.gLimRspReqd) {
2594 mac_ctx->lim.gLimRspReqd = false;
2595 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2596 deauth_trigger = eLIM_HOST_DEAUTH;
2597 goto send_deauth;
2598 }
2599 return;
2600 }
2601
Anurag Chouhanc5548422016-02-24 18:33:27 +05302602 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002603 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002604
2605 mlm_deauth_req->reasonCode = reason_code;
2606 mlm_deauth_req->deauthTrigger = deauth_trigger;
2607
2608 /* Update PE session Id */
2609 mlm_deauth_req->sessionId = session_id;
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002610 lim_process_mlm_deauth_req(mac_ctx, (uint32_t *)mlm_deauth_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002611
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002612 return;
2613
2614send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002615 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2616 ret_code, deauth_trigger, 1,
2617 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002618}
2619
2620/**
2621 * __lim_process_sme_set_context_req()
2622 *
2623 * @mac_ctx: Pointer to Global MAC structure
2624 * @msg_buf: pointer to the SME message buffer
2625 *
2626 * This function is called to process SME_SETCONTEXT_REQ message
2627 * from HDD or upper layer application.
2628 *
2629 * Return: None
2630 */
2631
2632static void
2633__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2634{
2635 tpSirSmeSetContextReq set_context_req;
2636 tLimMlmSetKeysReq *mlm_set_key_req;
2637 tpPESession session_entry;
2638 uint8_t session_id; /* PE sessionID */
2639 uint8_t sme_session_id;
2640 uint16_t sme_transaction_id;
2641
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002642 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002643 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002644 return;
2645 }
2646
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302647 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002648 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002649 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002650 return;
2651 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302652 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002653 sizeof(struct sSirSmeSetContextReq));
2654 sme_session_id = set_context_req->sessionId;
2655 sme_transaction_id = set_context_req->transactionId;
2656
2657 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002658 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002659 goto end;
2660 }
2661
2662 if (set_context_req->keyMaterial.numKeys >
2663 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002664 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002665 set_context_req->keyMaterial.numKeys);
2666 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002667 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002668 eSIR_SME_INVALID_PARAMETERS, NULL,
2669 sme_session_id, sme_transaction_id);
2670 goto end;
2671 }
2672
2673 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002674 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002675 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002676 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002677 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002678 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002679 eSIR_SME_INVALID_PARAMETERS, NULL,
2680 sme_session_id, sme_transaction_id);
2681 goto end;
2682 }
2683#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2684 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2685 session_entry, 0, 0);
2686#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2687
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002688 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002689 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2690 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002691 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002692 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2693 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302694 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002695 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002696 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002697 goto end;
2698 }
2699 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2700 mlm_set_key_req->numKeys =
2701 set_context_req->keyMaterial.numKeys;
2702 if (mlm_set_key_req->numKeys >
2703 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002704 pe_err("no.of keys exceeded max num of default keys limit");
Jingxiang Ge4168a232018-01-03 18:47:15 +08002705 qdf_mem_free(mlm_set_key_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002706 goto end;
2707 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302708 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002709 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002710
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302711 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002712 (uint8_t *) &set_context_req->keyMaterial.key,
2713 sizeof(tSirKeys) *
2714 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2715 numKeys : 1));
2716
2717 mlm_set_key_req->sessionId = session_id;
2718 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002719 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002720 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002721
2722 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2723 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2724 LIM_IS_AP_ROLE(session_entry)) {
2725 if (set_context_req->keyMaterial.key[0].keyLength) {
2726 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002727
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002728 key_id =
2729 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302730 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002731 &session_entry->WEPKeyMaterial[key_id],
2732 (uint8_t *) &set_context_req->keyMaterial,
2733 sizeof(tSirKeyMaterial));
2734 } else {
2735 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002736
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002737 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2738 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302739 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002740 &mlm_set_key_req->key[i],
2741 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2742 sizeof(tSirKeys));
2743 }
2744 }
2745 }
2746 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2747 (uint32_t *) mlm_set_key_req);
2748 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002749 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002750 GET_LIM_SYSTEM_ROLE(session_entry),
2751 session_entry->limSmeState);
2752 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2753
2754 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002755 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002756 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2757 session_entry, sme_session_id,
2758 sme_transaction_id);
2759 }
2760end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302761 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002762 return;
2763}
2764
2765/**
2766 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2767 *
2768 * @mac_ctx: Pointer to Global MAC structure
2769 * @msg_buf: pointer to the SME message buffer
2770 *
2771 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2772 * from HDD or upper layer application.
2773 *
2774 * Return: None
2775 */
2776
Jeff Johnson801f1532016-10-07 07:54:50 -07002777static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2778 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002779{
2780 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2781 tpDphHashNode sta_ds = NULL;
2782 tpPESession session_entry = NULL;
2783 tSap_Event sap_event;
2784 tpWLAN_SAPEventCB sap_event_cb = NULL;
2785 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2786 uint8_t session_id = CSR_SESSION_ID_INVALID;
2787 uint8_t assoc_id = 0;
2788 uint8_t sta_cnt = 0;
2789
2790 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002791 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002792 return;
2793 }
2794
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302795 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002796 sizeof(struct sSirSmeGetAssocSTAsReq));
2797 /*
2798 * Get Associated stations from PE.
2799 * Find PE session Entry
2800 */
2801 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08002802 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002803 &session_id);
2804 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002805 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002806 goto lim_assoc_sta_end;
2807 }
2808
2809 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002810 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002811 session_entry->limSmeState,
2812 GET_LIM_SYSTEM_ROLE(session_entry));
2813 goto lim_assoc_sta_end;
2814 }
2815 /* Retrieve values obtained in the request message */
2816 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
2817 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2818
2819 if (NULL == assoc_sta_tmp)
2820 goto lim_assoc_sta_end;
2821 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
2822 assoc_id++) {
2823 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
2824 &session_entry->dph.dphHashTable);
2825 if (NULL == sta_ds)
2826 continue;
2827 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302828 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002829 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302830 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002831 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
2832 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
2833
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302834 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002835 (uint8_t *)&sta_ds->supportedRates,
2836 sizeof(tSirSupportedRates));
2837 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
2838 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
2839 assoc_sta_tmp->Support40Mhz =
2840 sta_ds->htDsssCckRate40MHzSupport;
2841
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002842 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002843 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002844 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002845 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002846 pe_debug("Association Id: %d Station Index: %d",
2847 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002848 assoc_sta_tmp++;
2849 sta_cnt++;
2850 }
2851 }
2852lim_assoc_sta_end:
2853 /*
2854 * Call hdd callback with sap event to send the list of
2855 * associated stations from PE
2856 */
2857 if (sap_event_cb != NULL) {
2858 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
2859 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302860 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002861 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
2862 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
2863 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2864 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
2865 }
2866}
2867
2868/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002869 * __lim_counter_measures()
2870 *
2871 * FUNCTION:
2872 * This function is called to "implement" MIC counter measure
2873 * and is *temporary* only
2874 *
2875 * LOGIC: on AP, disassoc all STA associated thru TKIP,
2876 * we don't do the proper STA disassoc sequence since the
Jeff Johnsond460e842018-05-11 13:25:53 -07002877 * BSS will be stopped anyway
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002878 *
2879 ***ASSUMPTIONS:
2880 *
2881 ***NOTE:
2882 *
2883 * @param pMac Pointer to Global MAC structure
2884 * @return None
2885 */
2886
2887static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
2888{
2889 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002890
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002891 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002892 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
2893 mac, psessionEntry, false);
2894};
2895
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05302896void lim_send_stop_bss_failure_resp(tpAniSirGlobal mac_ctx,
2897 tpPESession session)
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302898{
2899 session->limSmeState = session->limPrevSmeState;
2900
2901 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE, session->peSessionId,
2902 session->limSmeState));
2903
2904 lim_send_sme_rsp(mac_ctx, eWNI_SME_STOP_BSS_RSP,
2905 eSIR_SME_STOP_BSS_FAILURE, session->smeSessionId,
2906 session->transactionId);
2907}
2908
2909void lim_delete_all_peers(tpPESession session)
2910{
2911 uint8_t i = 0;
2912 tpAniSirGlobal mac_ctx = session->mac_ctx;
2913 tpDphHashNode sta_ds = NULL;
2914 QDF_STATUS status;
2915
2916 for (i = 1; i < session->dph.dphHashTable.size; i++) {
2917 sta_ds = dph_get_hash_entry(mac_ctx, i,
2918 &session->dph.dphHashTable);
2919 if (!sta_ds)
2920 continue;
2921 status = lim_del_sta(mac_ctx, sta_ds, false, session);
2922 if (QDF_STATUS_SUCCESS == status) {
2923 lim_delete_dph_hash_entry(mac_ctx, sta_ds->staAddr,
2924 sta_ds->assocId, session);
2925 lim_release_peer_idx(mac_ctx, sta_ds->assocId, session);
2926 } else {
2927 pe_err("lim_del_sta failed with Status: %d", status);
2928 QDF_ASSERT(0);
2929 }
2930 }
Abhishek Singhcaa61852018-09-12 15:50:04 +05302931
2932#ifdef CONFIG_VDEV_SM
2933 status =
2934 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
2935 WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE,
2936 sizeof(*session), session);
2937 if (QDF_IS_STATUS_ERROR(status)) {
2938 pe_err("failed to post WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE for vdevid %d",
2939 session->smeSessionId);
2940 lim_send_stop_bss_failure_resp(mac_ctx, session);
2941 }
2942#endif
2943
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302944}
2945
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002946QDF_STATUS lim_sta_send_del_bss(tpPESession session)
2947{
2948 tpAniSirGlobal mac_ctx = session->mac_ctx;
2949 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2950 tpDphHashNode sta_ds = NULL;
2951
2952 sta_ds = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
2953 &session->dph.dphHashTable);
2954 if (!sta_ds) {
2955 pe_err("DPH Entry for STA is missing, failed to send delbss");
2956 goto end;
2957 }
2958
2959 status = lim_del_bss(mac_ctx, sta_ds, 0, session);
2960 if (QDF_IS_STATUS_ERROR(status))
2961 pe_err("delBss failed for bss %d", session->bssIdx);
2962
2963end:
2964 return status;
2965}
2966
Abhishek Singhcaa61852018-09-12 15:50:04 +05302967QDF_STATUS lim_send_vdev_stop(tpPESession session)
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302968{
2969 tpAniSirGlobal mac_ctx = session->mac_ctx;
2970 QDF_STATUS status;
2971
2972 status = lim_del_bss(mac_ctx, NULL, session->bssIdx, session);
2973
2974 if (QDF_IS_STATUS_ERROR(status)) {
2975 pe_err("delBss failed for bss %d", session->bssIdx);
2976 lim_send_stop_bss_failure_resp(mac_ctx, session);
2977 }
Abhishek Singhcaa61852018-09-12 15:50:04 +05302978
2979 return status;
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302980}
2981
2982/**
2983 * lim_delete_peers_and_send_vdev_stop() -delete peers and send vdev stop
2984 * @session: session pointer
2985 *
2986 * Return None
2987 */
Abhishek Singhcaa61852018-09-12 15:50:04 +05302988#ifdef CONFIG_VDEV_SM
2989static void lim_delete_peers_and_send_vdev_stop(tpPESession session)
2990{
2991 tpAniSirGlobal mac_ctx = session->mac_ctx;
2992 QDF_STATUS status;
2993
Abhishek Singhc5a54082018-09-12 16:08:03 +05302994 if (wlan_vdev_mlme_get_substate(session->vdev) ==
2995 WLAN_VDEV_SS_START_RESTART_PROGRESS)
2996 status =
2997 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
2998 WLAN_VDEV_SM_EV_RESTART_REQ_FAIL,
Abhishek Singhcaa61852018-09-12 15:50:04 +05302999 sizeof(*session), session);
Abhishek Singhc5a54082018-09-12 16:08:03 +05303000 else
3001 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3002 WLAN_VDEV_SM_EV_DOWN,
3003 sizeof(*session),
3004 session);
Abhishek Singhcaa61852018-09-12 15:50:04 +05303005 if (QDF_IS_STATUS_ERROR(status)) {
3006 pe_err("failed to post WLAN_VDEV_SM_EV_DOWN for vdevid %d",
3007 session->smeSessionId);
3008 lim_send_stop_bss_failure_resp(mac_ctx, session);
3009 }
3010}
3011#else
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303012static void lim_delete_peers_and_send_vdev_stop(tpPESession session)
3013{
3014 lim_delete_all_peers(session);
3015 /* send a delBss to HAL and wait for a response */
3016 lim_send_vdev_stop(session);
3017}
Abhishek Singhcaa61852018-09-12 15:50:04 +05303018#endif
3019
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003020static void
3021__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3022{
3023 tSirSmeStopBssReq stopBssReq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003024 tLimSmeStates prevState;
3025 tpPESession psessionEntry;
3026 uint8_t smesessionId;
3027 uint8_t sessionId;
3028 uint16_t smetransactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003029
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303030 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003031 smesessionId = stopBssReq.sessionId;
3032 smetransactionId = stopBssReq.transactionId;
3033
3034 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003035 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003036 /* Send Stop BSS response to host */
3037 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3038 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3039 smetransactionId);
3040 return;
3041 }
3042
3043 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003044 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003045 &sessionId);
3046 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003047 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003048 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3049 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3050 smetransactionId);
3051 return;
3052 }
3053#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3054 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3055 0, 0);
3056#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3057
3058 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3059 LIM_IS_STA_ROLE(psessionEntry)) {
3060 /**
3061 * Should not have received STOP_BSS_REQ in states
3062 * other than 'normal' state or on STA in Infrastructure
3063 * mode. Log error and return response to host.
3064 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003065 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003066 psessionEntry->limSmeState,
3067 GET_LIM_SYSTEM_ROLE(psessionEntry));
3068 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3069 /* / Send Stop BSS response to host */
3070 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3071 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3072 smetransactionId);
3073 return;
3074 }
3075
3076 if (LIM_IS_AP_ROLE(psessionEntry))
3077 lim_wpspbc_close(pMac, psessionEntry);
3078
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003079 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003080 stopBssReq.reasonCode);
3081
3082 prevState = psessionEntry->limSmeState;
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303083 psessionEntry->limPrevSmeState = prevState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003084
3085 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3086 MTRACE(mac_trace
3087 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3088 psessionEntry->limSmeState));
3089
3090 /* Update SME session Id and Transaction Id */
3091 psessionEntry->smeSessionId = smesessionId;
3092 psessionEntry->transactionId = smetransactionId;
3093
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003094 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3095 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3096 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003097 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003098
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003099 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3100 /* Send disassoc all stations associated thru TKIP */
3101 __lim_counter_measures(pMac, psessionEntry);
3102 else
3103 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003104 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3105 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003106 }
3107
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003108 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3109 /* Free the buffer allocated in START_BSS_REQ */
3110 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3111 psessionEntry->addIeParams.probeRespDataLen = 0;
3112 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003113
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003114 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3115 psessionEntry->addIeParams.assocRespDataLen = 0;
3116 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003117
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003118 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3119 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3120 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003121
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003122 /*
3123 * lim_del_bss is also called as part of coalescing,
3124 * when we send DEL BSS followed by Add Bss msg.
3125 */
3126 pMac->lim.gLimIbssCoalescingHappened = false;
3127 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003128
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303129 lim_delete_peers_and_send_vdev_stop(psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003131}
3132
3133/**
3134 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3135 * @pMac: Global MAC context
3136 * @pMsg: Message from SME
3137 *
3138 * Wrapper for the function __lim_handle_sme_stop_bss_request
3139 * This message will be defered until softmac come out of
3140 * scan mode. Message should be handled even if we have
3141 * detected radar in the current operating channel.
3142 *
3143 * Return: true - If we consumed the buffer
3144 * false - If have defered the message.
3145 */
3146
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003147static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3148 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003149{
3150 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3151 /**
3152 * If message defered, buffer is not consumed yet.
3153 * So return false
3154 */
3155 return false;
3156 }
3157 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3158 return true;
3159} /*** end __lim_process_sme_stop_bss_req() ***/
3160
3161void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3162 uint32_t body, tpPESession psessionEntry)
3163{
3164
3165 (void)body;
3166 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3167 lim_ibss_delete(pMac, psessionEntry);
3168 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3169 lim_delete_pre_auth_list(pMac);
3170 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3171 psessionEntry->smeSessionId,
3172 psessionEntry->transactionId);
3173 return;
3174}
3175
3176/**
3177 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3178 *
3179 * @mac_ctx: pointer to mac context
3180 * @msg_type: message type
3181 * @msg_buf: pointer to the SME message buffer
3182 *
3183 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3184 * in BTAMP AP.
3185 *
3186 * Return: None
3187 */
3188
3189void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3190 uint32_t *msg_buf)
3191{
3192 tSirSmeAssocCnf assoc_cnf;
3193 tpDphHashNode sta_ds = NULL;
3194 tpPESession session_entry = NULL;
3195 uint8_t session_id;
3196 tpSirAssocReq assoc_req;
3197
3198 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003199 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003200 goto end;
3201 }
3202
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303203 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003204 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003205 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003206 goto end;
3207 }
3208
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003209 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003210 &session_id);
3211 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003212 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003213 goto end;
3214 }
3215
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003216 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003217 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3218 (session_entry->limSmeState !=
3219 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003220 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003221 msg_type, session_entry->limSmeState,
3222 GET_LIM_SYSTEM_ROLE(session_entry));
3223 goto end;
3224 }
3225 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3226 &session_entry->dph.dphHashTable);
3227 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003228 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003229 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303230 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003231
3232 /*
3233 * send a DISASSOC_IND message to WSM to make sure
3234 * the state in WSM and LIM is the same
3235 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003236 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003237 eSIR_SME_STA_NOT_ASSOCIATED,
3238 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3239 session_entry->smeSessionId,
3240 session_entry->transactionId,
3241 session_entry);
3242 goto end;
3243 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303244 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003245 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303246 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003247 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003248 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303249 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003250 goto end;
3251 }
3252
3253 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3254 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3255 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3256 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3257 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003258 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3259 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003260 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303261 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003262 goto end;
3263 }
3264 /*
3265 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3266 * has been received
3267 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003268 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003269 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3270 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3271
3272 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3273 /*
3274 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3275 * when it had received Assoc Request frame. Now, PE just needs
3276 * to send association rsp frame to the requesting BTAMP-STA.
3277 */
3278 sta_ds->mlmStaContext.mlmState =
3279 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003280 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003281 sta_ds->assocId);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003282 lim_send_assoc_rsp_mgmt_frame(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283 sta_ds->assocId, sta_ds->staAddr,
3284 sta_ds->mlmStaContext.subType, sta_ds,
3285 session_entry);
3286 goto end;
3287 } else {
3288 /*
3289 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3290 * to be associated since the HAL sta entry is created for
3291 * denied STA we need to remove this HAL entry.
3292 * So to do that set updateContext to 1
3293 */
3294 if (!sta_ds->mlmStaContext.updateContext)
3295 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003296 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003297 assoc_cnf.statusCode, sta_ds->assocId);
3298 lim_reject_association(mac_ctx, sta_ds->staAddr,
3299 sta_ds->mlmStaContext.subType,
3300 true, sta_ds->mlmStaContext.authType,
3301 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003302 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003303 session_entry);
3304 }
3305end:
3306 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3307 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3308 assoc_req = (tpSirAssocReq)
3309 session_entry->parsedAssocReq[sta_ds->assocId];
3310 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303311 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003312 assoc_req->assocReqFrame = NULL;
3313 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303314 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003315 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3316 }
3317}
3318
3319static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3320{
3321 tpDphHashNode pStaDs;
3322 tSirMacAddr peerMac;
3323 tpSirAddtsReq pSirAddts;
3324 uint32_t timeout;
3325 tpPESession psessionEntry;
3326 uint8_t sessionId; /* PE sessionId */
3327 uint8_t smesessionId;
3328 uint16_t smetransactionId;
3329
3330 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003331 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003332 return;
3333 }
3334
3335 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3336 &smetransactionId);
3337
3338 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3339
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003340 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3341 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003342 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003343 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003344 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303345 NULL, pSirAddts->req.tspec,
3346 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003347 return;
3348 }
3349#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3350 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3351 0);
3352#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3353
3354 /* if sta
3355 * - verify assoc state
3356 * - send addts request to ap
3357 * - wait for addts response from ap
3358 * if ap, just ignore with error log
3359 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003360 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3361 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3362 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003363
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003364 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003365 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303366 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003367 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003368
3369 pStaDs =
3370 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3371 &psessionEntry->dph.dphHashTable);
3372
3373 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003374 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303375 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003376 }
3377
3378 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3379 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003380 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303381 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003382 }
3383
3384 pSirAddts->req.wsmTspecPresent = 0;
3385 pSirAddts->req.wmeTspecPresent = 0;
3386 pSirAddts->req.lleTspecPresent = 0;
3387
3388 if ((pStaDs->wsmEnabled) &&
3389 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3390 SIR_MAC_ACCESSPOLICY_EDCA))
3391 pSirAddts->req.wsmTspecPresent = 1;
3392 else if (pStaDs->wmeEnabled)
3393 pSirAddts->req.wmeTspecPresent = 1;
3394 else if (pStaDs->lleEnabled)
3395 pSirAddts->req.lleTspecPresent = 1;
3396 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003397 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303398 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003399 }
3400
3401 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3402 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003403 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003404 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303405 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003406 }
3407
3408 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003409 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003410 pMac->lim.gLimAddtsReq.req.dialogToken,
3411 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3412 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3413 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303414 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003415 }
3416
3417 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3418
3419 /* save the addts request */
3420 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303421 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003422 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3423
3424 /* ship out the message now */
3425 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3426 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303427 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003428 /* start a timer to wait for the response */
3429 if (pSirAddts->timeout)
3430 timeout = pSirAddts->timeout;
Arif Hussain43e09712018-09-18 19:31:57 -07003431 else
3432 timeout = pMac->mlme_cfg->timeouts.addts_rsp_timeout;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003433
3434 timeout = SYS_MS_TO_TICKS(timeout);
3435 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3436 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003437 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303438 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003439 }
3440 pMac->lim.gLimAddtsRspTimerCount++;
3441 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3442 pMac->lim.gLimAddtsRspTimerCount) !=
3443 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003444 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303445 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003446 }
3447 MTRACE(mac_trace
3448 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3449 eLIM_ADDTS_RSP_TIMER));
3450
3451 /* add the sessionId to the timer object */
3452 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3453 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3454 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003455 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303456 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003457 }
3458 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303459
3460send_failure_addts_rsp:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003461 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303462 psessionEntry, pSirAddts->req.tspec,
3463 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003464}
3465
3466static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3467{
3468 tSirMacAddr peerMacAddr;
3469 uint8_t ac;
3470 tSirMacTSInfo *pTsinfo;
3471 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3472 tpDphHashNode pStaDs = NULL;
3473 tpPESession psessionEntry;
3474 uint8_t sessionId;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003475 uint32_t status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003476 uint8_t smesessionId;
3477 uint16_t smetransactionId;
3478
3479 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3480 &smetransactionId);
3481
3482 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003483 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003484 &sessionId);
3485 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003486 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003487 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003488 goto end;
3489 }
3490#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3491 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3492 0);
3493#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3494
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003495 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003497 pe_err("lim_validate_delts_req failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003498 status = QDF_STATUS_E_FAILURE;
3499 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_E_FAILURE, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003500 smesessionId, smetransactionId);
3501 return;
3502 }
3503
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003504 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3505 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003506 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3507
3508 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3509 pDeltsReq->req.wmeTspecPresent,
3510 &pDeltsReq->req.tsinfo,
3511 &pDeltsReq->req.tspec, psessionEntry);
3512
3513 pTsinfo =
3514 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3515 tsinfo : &pDeltsReq->req.tsinfo;
3516
3517 /* We've successfully send DELTS frame to AP. Update the
3518 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3519 * is no longer trigger enabled or delivery enabled
3520 */
3521 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3522 pTsinfo, CLEAR_UAPSD_MASK);
3523
3524 /* We're deleting the TSPEC, so this particular AC is no longer
3525 * admitted. PE needs to downgrade the EDCA
3526 * parameters(for the AC for which TS is being deleted) to the
3527 * next best AC for which ACM is not enabled, and send the
3528 * updated values to HAL.
3529 */
3530 ac = upToAc(pTsinfo->traffic.userPrio);
3531
3532 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3533 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3534 ~(1 << ac);
3535 } else if (pTsinfo->traffic.direction ==
3536 SIR_MAC_DIRECTION_DNLINK) {
3537 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3538 ~(1 << ac);
3539 } else if (pTsinfo->traffic.direction ==
3540 SIR_MAC_DIRECTION_BIDIR) {
3541 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3542 ~(1 << ac);
3543 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3544 ~(1 << ac);
3545 }
3546
3547 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3548 psessionEntry);
3549
3550 pStaDs =
3551 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3552 &psessionEntry->dph.dphHashTable);
3553 if (pStaDs != NULL) {
3554 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003555 pStaDs->bssId, false);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003556 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003557 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003558 pe_err("Self entry missing in Hash Table");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003559 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003560 }
3561#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003562 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003563#endif
3564
3565 /* send an sme response back */
3566end:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003567 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_SUCCESS, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003568 smesessionId, smetransactionId);
3569}
3570
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303571void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003572{
3573 /* fetch the sessionEntry based on the sessionId */
3574 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003575
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003576 psessionEntry = pe_find_session_by_session_id(pMac,
3577 pMac->lim.limTimers.gLimAddtsRspTimer.
3578 sessionId);
3579 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003580 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003581 return;
3582 }
3583
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003584 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003585 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586 GET_LIM_SYSTEM_ROLE(psessionEntry));
3587 pMac->lim.gLimAddtsSent = false;
3588 return;
3589 }
3590
3591 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003592 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003593 return;
3594 }
3595
3596 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003597 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598 pMac->lim.gLimAddtsRspTimerCount);
3599 return;
3600 }
3601 /* this a real response timeout */
3602 pMac->lim.gLimAddtsSent = false;
3603 pMac->lim.gLimAddtsRspTimerCount++;
3604
3605 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3606 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3607 psessionEntry->smeSessionId,
3608 psessionEntry->transactionId);
3609}
3610
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003611#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003612/**
3613 * __lim_process_sme_get_statistics_request()
3614 *
3615 ***FUNCTION:
3616 *
3617 *
3618 ***NOTE:
3619 *
3620 * @param pMac Pointer to Global MAC structure
3621 * @param *pMsgBuf A pointer to the SME message buffer
3622 * @return None
3623 */
3624static void
3625__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3626{
3627 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003628 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003629
3630 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3631
3632 msgQ.type = WMA_GET_STATISTICS_REQ;
3633
3634 msgQ.reserved = 0;
3635 msgQ.bodyptr = pMsgBuf;
3636 msgQ.bodyval = 0;
3637 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3638
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003639 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303640 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003641 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003642 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003643 return;
3644 }
3645
3646 return;
3647}
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003648#else
3649static void __lim_process_sme_get_statistics_request(
3650 struct sAniSirGlobal *mac_ctx, uint32_t *pMsgBuf) {}
3651#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003652
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003653#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003654/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003655 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003656 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003657 * @pMac: Pointer to Global MAC structure
3658 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003659 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003660 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003661 */
3662static void
3663__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3664{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003665 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666
3667 msgQ.type = WMA_TSM_STATS_REQ;
3668 msgQ.reserved = 0;
3669 msgQ.bodyptr = pMsgBuf;
3670 msgQ.bodyval = 0;
3671 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3672
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003673 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303674 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003675 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003676 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003677 return;
3678 }
3679}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003680#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003681
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08003682static void lim_process_sme_set_addba_accept(tpAniSirGlobal mac_ctx,
3683 struct sme_addba_accept *msg)
3684{
3685 if (!msg) {
3686 pe_err("Msg Buffer is NULL");
3687 return;
3688 }
3689 if (!msg->addba_accept)
3690 mac_ctx->reject_addba_req = 1;
3691 else
3692 mac_ctx->reject_addba_req = 0;
3693}
3694
Arif Hussaineb8ba362018-03-07 19:15:13 -08003695static void lim_process_sme_update_edca_params(tpAniSirGlobal mac_ctx,
3696 uint32_t sme_session_id)
3697{
3698 tpPESession pe_session;
3699 tpDphHashNode sta_ds_ptr;
3700
3701 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3702 if (!pe_session) {
3703 pe_err("Session does not exist: sme_id %d", sme_session_id);
3704 return;
3705 }
3706 pe_session->gLimEdcaParamsActive[EDCA_AC_BE].no_ack =
3707 mac_ctx->no_ack_policy_cfg[EDCA_AC_BE];
3708 pe_session->gLimEdcaParamsActive[EDCA_AC_BK].no_ack =
3709 mac_ctx->no_ack_policy_cfg[EDCA_AC_BK];
3710 pe_session->gLimEdcaParamsActive[EDCA_AC_VI].no_ack =
3711 mac_ctx->no_ack_policy_cfg[EDCA_AC_VI];
3712 pe_session->gLimEdcaParamsActive[EDCA_AC_VO].no_ack =
3713 mac_ctx->no_ack_policy_cfg[EDCA_AC_VO];
3714 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3715 &pe_session->dph.dphHashTable);
3716 if (sta_ds_ptr)
3717 lim_send_edca_params(mac_ctx,
3718 pe_session->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003719 sta_ds_ptr->bssId, false);
Arif Hussaineb8ba362018-03-07 19:15:13 -08003720 else
3721 pe_err("Self entry missing in Hash Table");
3722}
3723
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07003724static void lim_process_sme_update_mu_edca_params(tpAniSirGlobal mac_ctx,
3725 uint32_t sme_session_id)
3726{
3727 tpPESession pe_session;
3728 tpDphHashNode sta_ds_ptr;
3729
3730 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3731 if (!pe_session) {
3732 pe_err("Session does not exist: sme_id %d", sme_session_id);
3733 return;
3734 }
3735 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3736 &pe_session->dph.dphHashTable);
3737 if (sta_ds_ptr)
3738 lim_send_edca_params(mac_ctx, mac_ctx->usr_mu_edca_params,
3739 sta_ds_ptr->bssId, true);
3740 else
3741 pe_err("Self entry missing in Hash Table");
3742}
3743
Naveen Rawat8029a402017-06-01 10:54:19 -07003744static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3745 struct update_config *msg)
3746{
3747 tpPESession pe_session;
3748
3749 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3750 if (msg == NULL) {
3751 pe_err("Buffer is Pointing to NULL");
3752 return;
3753 }
3754
3755 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3756 msg->sme_session_id);
3757 if (pe_session == NULL) {
3758 pe_warn("Session does not exist for given BSSID");
3759 return;
3760 }
3761
3762 switch (msg->capab) {
3763 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3764 pe_session->htConfig.ht_rx_ldpc = msg->value;
3765 break;
3766 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3767 pe_session->htConfig.ht_tx_stbc = msg->value;
3768 break;
3769 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3770 pe_session->htConfig.ht_rx_stbc = msg->value;
3771 break;
3772 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3773 pe_session->htConfig.ht_sgi20 = msg->value;
3774 break;
3775 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3776 pe_session->htConfig.ht_sgi40 = msg->value;
3777 break;
3778 }
3779
3780 if (LIM_IS_AP_ROLE(pe_session)) {
3781 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3782 lim_send_beacon_ind(mac_ctx, pe_session);
3783 }
3784}
3785
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003786void
3787lim_send_vdev_restart(tpAniSirGlobal pMac,
3788 tpPESession psessionEntry, uint8_t sessionId)
3789{
3790 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003791 struct scheduler_msg msgQ = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003792 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003793
3794 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003795 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003796 return;
3797 }
3798
3799 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303800 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003801 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003802 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003803 return;
3804 }
3805
3806 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3807 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003808 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003809
3810 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3811 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3812 msgQ.bodyval = 0;
3813
3814 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003815 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003816 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303817 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003818 }
3819}
3820
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303821/**
3822 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3823 * @mac_ctx: Pointer to Global MAC structure
3824 * @msg_buf: Pointer to SME message buffer
3825 *
3826 * Return: None
3827 */
3828static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3829 uint32_t *msg_buf)
3830{
3831 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003832 struct scheduler_msg wma_msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003833 QDF_STATUS status;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303834 tSirRoamOffloadScanReq *req_buffer;
3835 uint16_t local_ie_len;
3836 uint8_t *local_ie_buf;
3837
3838 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3839 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3840 req_buffer->sessionId);
3841
3842 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3843 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003844 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303845 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303846 return;
3847 }
3848
3849 local_ie_len = req_buffer->assoc_ie.length;
3850 /* Update ext cap IE if present */
3851 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003852 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3853 local_ie_buf, &local_ie_len)) {
3854 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003855 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3856 req_buffer->assoc_ie.length = local_ie_len;
3857 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3858 local_ie_buf, local_ie_len);
3859 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303860 }
3861 qdf_mem_free(local_ie_buf);
3862
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303863 if (pe_session)
3864 lim_update_fils_rik(pe_session, req_buffer);
3865
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303866 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3867 wma_msg.bodyptr = req_buffer;
3868
3869 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003870 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003871 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303872 qdf_mem_free(req_buffer);
3873 }
3874}
3875
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303876/*
3877 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3878 * @mac_ctx: Pointer to global mac context
3879 * @session: Pointer to PE session
3880 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3881 * 1 - Disable broadcast SSID
3882 *
3883 * Return: None
3884 */
3885static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3886 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003887{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003888 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003889 session->ssidHidden, ssid_hidden);
3890
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003891 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303892 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003893 } else {
3894 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05303895 return;
3896 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003897
Abhishek Singh6c681f42018-09-12 15:52:36 +05303898#ifdef CONFIG_VDEV_SM
3899 ap_mlme_set_hidden_ssid_restart_in_progress(session->vdev, true);
3900 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3901 WLAN_VDEV_SM_EV_FW_VDEV_RESTART,
3902 sizeof(*session), session);
3903#else
3904
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003905 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303906 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Abhishek Singh6c681f42018-09-12 15:52:36 +05303907#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003908
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003909 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303910}
3911
3912/**
3913 * __lim_process_sme_session_update - process SME session update msg
3914 *
3915 * @mac_ctx: Pointer to global mac context
3916 * @msg_buf: Pointer to the received message buffer
3917 *
3918 * Return: None
3919 */
3920static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
3921 uint32_t *msg_buf)
3922{
3923 struct sir_update_session_param *msg;
3924 tpPESession session;
3925
3926 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003927 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303928 return;
3929 }
3930
3931 msg = (struct sir_update_session_param *) msg_buf;
3932
3933 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
3934 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003935 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303936 msg->session_id);
3937 return;
3938 }
3939
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003940 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303941 msg->param_type, msg->param_val);
3942 switch (msg->param_type) {
3943 case SIR_PARAM_SSID_HIDDEN:
3944 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
3945 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303946 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
3947 session->ignore_assoc_disallowed = msg->param_val;
3948 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303949 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003950 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303951 break;
3952 }
3953}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003954
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003955/*
3956 Update the beacon Interval dynamically if beaconInterval is different in MCC
3957 */
3958static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3959{
3960 tpSirChangeBIParams pChangeBIParams;
3961 tpPESession psessionEntry;
3962 uint8_t sessionId = 0;
3963 tUpdateBeaconParams beaconParams;
3964
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003965 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003966
3967 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003968 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003969 return;
3970 }
3971
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303972 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003973 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
3974
3975 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08003976 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003977 &sessionId);
3978 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003979 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003980 return;
3981 }
3982
3983 /*Update sessionEntry Beacon Interval */
3984 if (psessionEntry->beaconParams.beaconInterval !=
3985 pChangeBIParams->beaconInterval) {
3986 psessionEntry->beaconParams.beaconInterval =
3987 pChangeBIParams->beaconInterval;
3988 }
3989
3990 /*Update sch beaconInterval */
3991 if (pMac->sch.schObject.gSchBeaconInterval !=
3992 pChangeBIParams->beaconInterval) {
3993 pMac->sch.schObject.gSchBeaconInterval =
3994 pChangeBIParams->beaconInterval;
3995
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003996 pe_debug("LIM send update BeaconInterval Indication: %d",
3997 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003998
3999 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4000 /* Update beacon */
4001 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4002
4003 beaconParams.bssIdx = psessionEntry->bssIdx;
4004 /* Set change in beacon Interval */
4005 beaconParams.beaconInterval =
4006 pChangeBIParams->beaconInterval;
4007 beaconParams.paramChangeBitmap =
4008 PARAM_BCN_INTERVAL_CHANGED;
4009 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4010 }
4011 }
4012
4013 return;
4014} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4015
4016#ifdef QCA_HT_2040_COEX
4017static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4018 uint32_t *pMsgBuf)
4019{
4020 tpSirSetHT2040Mode pSetHT2040Mode;
4021 tpPESession psessionEntry;
4022 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004023 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004024 tUpdateVHTOpMode *pHtOpMode = NULL;
4025 uint16_t staId = 0;
4026 tpDphHashNode pStaDs = NULL;
4027
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004028 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004029 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004030 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004031 return;
4032 }
4033
4034 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4035
4036 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004037 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004038 &sessionId);
4039 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004040 pe_debug("Session does not exist for given BSSID");
4041 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004042 return;
4043 }
4044
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004045 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004046 pSetHT2040Mode->cbMode);
4047 /*Update sessionEntry HT related fields */
4048 switch (pSetHT2040Mode->cbMode) {
4049 case PHY_SINGLE_CHANNEL_CENTERED:
4050 psessionEntry->htSecondaryChannelOffset =
4051 PHY_SINGLE_CHANNEL_CENTERED;
4052 psessionEntry->htRecommendedTxWidthSet = 0;
4053 if (pSetHT2040Mode->obssEnabled)
4054 psessionEntry->htSupportedChannelWidthSet
4055 = eHT_CHANNEL_WIDTH_40MHZ;
4056 else
4057 psessionEntry->htSupportedChannelWidthSet
4058 = eHT_CHANNEL_WIDTH_20MHZ;
4059 break;
4060 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4061 psessionEntry->htSecondaryChannelOffset =
4062 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4063 psessionEntry->htRecommendedTxWidthSet = 1;
4064 break;
4065 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4066 psessionEntry->htSecondaryChannelOffset =
4067 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4068 psessionEntry->htRecommendedTxWidthSet = 1;
4069 break;
4070 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004071 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004072 return;
4073 }
4074
4075 /* Update beacon */
4076 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4077 lim_send_beacon_ind(pMac, psessionEntry);
4078
4079 /* update OP Mode for each associated peer */
4080 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4081 pStaDs = dph_get_hash_entry(pMac, staId,
4082 &psessionEntry->dph.dphHashTable);
4083 if (NULL == pStaDs)
4084 continue;
4085
4086 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304087 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004088 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004089 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004090 return;
4091 }
4092 pHtOpMode->opMode =
4093 (psessionEntry->htSecondaryChannelOffset ==
4094 PHY_SINGLE_CHANNEL_CENTERED) ?
4095 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4096 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304097 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004098 sizeof(tSirMacAddr));
4099 pHtOpMode->smesessionId = sessionId;
4100
4101 msg.type = WMA_UPDATE_OP_MODE;
4102 msg.reserved = 0;
4103 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004104 if (!QDF_IS_STATUS_SUCCESS
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05304105 (scheduler_post_message(QDF_MODULE_ID_PE,
4106 QDF_MODULE_ID_WMA,
4107 QDF_MODULE_ID_WMA,
4108 &msg))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004109 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304110 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004111 return;
4112 }
Jeff Johnson47d75242018-05-12 15:58:53 -07004113 pe_debug("Notified FW about OP mode: %d for staId=%d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004114 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004115
4116 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004117 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004118 }
4119
4120 return;
4121}
4122#endif
4123
4124/* -------------------------------------------------------------------- */
4125/**
4126 * __lim_process_report_message
4127 *
4128 * FUNCTION: Processes the next received Radio Resource Management message
4129 *
4130 * LOGIC:
4131 *
4132 * ASSUMPTIONS:
4133 *
4134 * NOTE:
4135 *
4136 * @param None
4137 * @return None
4138 */
4139
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004140static void __lim_process_report_message(tpAniSirGlobal pMac,
4141 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004142{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004143 switch (pMsg->type) {
4144 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4145 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4146 break;
4147 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004148 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004149 break;
4150 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004151 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004152 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004153}
4154
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004155/* -------------------------------------------------------------------- */
4156/**
4157 * lim_send_set_max_tx_power_req
4158 *
4159 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4160 *
4161 * LOGIC:
4162 *
4163 * ASSUMPTIONS:
4164 *
4165 * NOTE:
4166 *
4167 * @param txPower txPower to be set.
4168 * @param pSessionEntry session entry.
4169 * @return None
4170 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004171QDF_STATUS
Amar Singhala297bfa2015-10-15 15:07:29 -07004172lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004173 tpPESession pSessionEntry)
4174{
4175 tpMaxTxPowerParams pMaxTxParams = NULL;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004176 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004177 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004178
4179 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004180 pe_err("Invalid parameters");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004181 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004182 }
4183
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304184 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004185 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004186 pe_err("Unable to allocate memory for pMaxTxParams");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004187 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004188
4189 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004190 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304191 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304192 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304193 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004194 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304195 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004196
4197 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4198 msgQ.bodyptr = pMaxTxParams;
4199 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004200 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4202 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004203 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004204 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304205 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004206 }
4207 return retCode;
4208}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004209
4210/**
4211 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4212 *
4213 * @mac_ctx: Pointer to Global MAC structure
4214 * @msg_buf: pointer to the SME message buffer
4215 *
4216 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4217 * from SME. It Register this information within PE.
4218 *
4219 * Return: None
4220 */
4221static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4222 uint32_t *msg_buf)
4223{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304224 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004225 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4226 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4227 struct mgmt_frm_reg_info *next = NULL;
4228 bool match = false;
4229
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004230 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004231 sme_req->registerFrame, sme_req->frameType,
4232 sme_req->matchLen);
4233 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304234 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304235 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4236 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304237 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004238
4239 while (lim_mgmt_regn != NULL) {
4240 if (lim_mgmt_regn->frameType != sme_req->frameType)
4241 goto skip_match;
4242 if (sme_req->matchLen) {
4243 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304244 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004245 sme_req->matchData,
4246 lim_mgmt_regn->matchLen))) {
4247 /* found match! */
4248 match = true;
4249 break;
4250 }
4251 } else {
4252 /* found match! */
4253 match = true;
4254 break;
4255 }
4256skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304257 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304258 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004259 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304260 (qdf_list_node_t *)lim_mgmt_regn,
4261 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304262 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004263 lim_mgmt_regn = next;
4264 next = NULL;
4265 }
4266 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304267 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004268 if (QDF_STATUS_SUCCESS ==
4269 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004270 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004271 (qdf_list_node_t *)lim_mgmt_regn))
4272 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304273 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004274 }
4275
4276 if (sme_req->registerFrame) {
4277 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304278 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004279 sme_req->matchLen);
4280 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004281 lim_mgmt_regn->frameType = sme_req->frameType;
4282 lim_mgmt_regn->matchLen = sme_req->matchLen;
4283 lim_mgmt_regn->sessionId = sme_req->sessionId;
4284 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304285 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004286 sme_req->matchData,
4287 sme_req->matchLen);
4288 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304289 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004290 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304291 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004292 gLimMgmtFrameRegistratinQueue,
4293 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304294 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004295 &mac_ctx->lim.lim_frame_register_lock);
4296 }
4297 }
4298 return;
4299}
4300
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004301static void
4302__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4303{
4304 tpSirResetAPCapsChange pResetCapsChange;
4305 tpPESession psessionEntry;
4306 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004307
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004308 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004309 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004310 return;
4311 }
4312
4313 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4314 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004315 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4316 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004317 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004318 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004319 return;
4320 }
4321
4322 psessionEntry->limSentCapsChangeNtf = false;
4323 return;
4324}
4325
4326/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304327 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4328 * indication callback in PE.
4329 * @mac_ptr: Mac pointer
4330 * @msg_buf: Msg pointer containing the callback
4331 *
4332 * This function is used save the Management frame
4333 * indication callback in PE.
4334 *
4335 * Return: None
4336 */
4337static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4338 uint32_t *msg_buf)
4339{
4340 struct sir_sme_mgmt_frame_cb_req *sme_req =
4341 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4342
4343 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004344 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304345 return;
4346 }
4347 if (sme_req->callback)
4348 mac_ctx->mgmt_frame_ind_cb =
4349 (sir_mgmt_frame_ind_callback)sme_req->callback;
4350 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004351 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304352}
4353
4354/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304355 *__lim_process_send_disassoc_frame: function processes disassoc frame
4356 * @mac_ctx: pointer to mac context
4357 * @msg_buf: message buffer
4358 *
4359 * function processes disassoc request received from SME
4360 *
4361 * return: none
4362 */
4363static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4364 uint32_t *msg_buf)
4365{
4366 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004367 QDF_STATUS status;
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304368 tpPESession session_entry = NULL;
4369 uint8_t sme_session_id;
4370 uint16_t sme_trans_id;
4371
4372 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004373 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304374 return;
4375 }
4376
4377 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4378 &sme_trans_id);
4379
4380 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4381 &sme_send_disassoc_frame_req,
4382 (uint8_t *)msg_buf);
4383
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004384 if ((QDF_STATUS_E_FAILURE == status) ||
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304385 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4386 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004387 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304388 return;
4389 }
4390
4391 session_entry = pe_find_session_by_sme_session_id(
4392 mac_ctx, sme_session_id);
4393 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004394 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304395 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4396 return;
4397 }
4398
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004399 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 +05304400 sme_send_disassoc_frame_req.msg_type,
4401 sme_send_disassoc_frame_req.length,
4402 sme_send_disassoc_frame_req.session_id,
4403 sme_send_disassoc_frame_req.trans_id,
4404 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4405 sme_send_disassoc_frame_req.reason,
4406 sme_send_disassoc_frame_req.wait_for_ack);
4407
4408 lim_send_disassoc_mgmt_frame(mac_ctx,
4409 sme_send_disassoc_frame_req.reason,
4410 sme_send_disassoc_frame_req.peer_mac,
4411 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4412}
4413
4414/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004415 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4416 * @mac_ctx: Pointer to Global MAC structure
4417 * @pdev_id: pdev id to set the IE.
4418 * @nss: Nss values to prepare the HT IE.
4419 *
4420 * Prepares the HT IE with self capabilities for different
4421 * Nss values and sends the set HT IE req to FW.
4422 *
4423 * Return: None
4424 */
4425static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4426 uint8_t nss)
4427{
4428 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004429 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004430 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004431 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004432 tHtCaps *p_ht_cap;
4433 int i;
4434
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004435 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004436 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4437 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004438 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004439 return;
4440 }
4441 ie_params->nss = i;
4442 ie_params->pdev_id = pdev_id;
4443 ie_params->ie_type = DOT11_HT_IE;
4444 /* 2 for IE len and EID */
4445 ie_params->ie_len = 2 + sizeof(tHtCaps);
4446 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4447 if (NULL == ie_params->ie_ptr) {
4448 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004449 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004450 return;
4451 }
4452 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4453 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4454 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4455 ie_params->ie_len);
4456
4457 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004458 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4459 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004460 if (NULL == p_ie) {
4461 qdf_mem_free(ie_params->ie_ptr);
4462 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004463 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004464 return;
4465 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004466 p_ht_cap = (tHtCaps *)&p_ie[2];
4467 p_ht_cap->supportedMCSSet[1] = 0;
4468 p_ht_cap->txSTBC = 0;
4469 }
4470
4471 msg.type = WMA_SET_PDEV_IE_REQ;
4472 msg.bodyptr = ie_params;
4473 msg.bodyval = 0;
4474
4475 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004476 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004477 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004478 qdf_mem_free(ie_params->ie_ptr);
4479 qdf_mem_free(ie_params);
4480 return;
4481 }
4482 }
4483}
4484
4485/**
4486 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4487 * @mac_ctx: Pointer to Global MAC structure
4488 * @pdev_id: pdev id to set the IE.
4489 * @nss: Nss values to prepare the VHT IE.
4490 *
4491 * Prepares the VHT IE with self capabilities for different
4492 * Nss values and sends the set VHT IE req to FW.
4493 *
4494 * Return: None
4495 */
4496static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4497 uint8_t nss)
4498{
4499 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004500 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004501 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004502 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004503 tSirMacVHTCapabilityInfo *vht_cap;
4504 int i;
4505 tSirVhtMcsInfo *vht_mcs;
4506
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004507 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004508 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4509 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004510 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004511 return;
4512 }
4513 ie_params->nss = i;
4514 ie_params->pdev_id = pdev_id;
4515 ie_params->ie_type = DOT11_VHT_IE;
4516 /* 2 for IE len and EID */
4517 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4518 sizeof(tSirVhtMcsInfo);
4519 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4520 if (NULL == ie_params->ie_ptr) {
4521 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004522 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004523 return;
4524 }
4525 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4526 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4527 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4528 ie_params->ie_len);
4529
4530 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004531 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4532 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004533 if (NULL == p_ie) {
4534 qdf_mem_free(ie_params->ie_ptr);
4535 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004536 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004537 return;
4538 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004539 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4540 vht_cap->txSTBC = 0;
4541 vht_mcs =
4542 (tSirVhtMcsInfo *)&p_ie[2 +
4543 sizeof(tSirMacVHTCapabilityInfo)];
4544 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4545 vht_mcs->rxHighest =
4546 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4547 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4548 vht_mcs->txHighest =
4549 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4550 }
4551 msg.type = WMA_SET_PDEV_IE_REQ;
4552 msg.bodyptr = ie_params;
4553 msg.bodyval = 0;
4554
4555 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004556 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004557 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004558 qdf_mem_free(ie_params->ie_ptr);
4559 qdf_mem_free(ie_params);
4560 return;
4561 }
4562 }
4563}
4564
4565/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004566 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4567 * @mac_ctx: Pointer to Global MAC structure
4568 * @msg_buf: Pointer to the SME message buffer
4569 *
4570 * This function is called by limProcessMessageQueue(). This function sets the
4571 * VDEV IEs to the FW.
4572 *
4573 * Return: None
4574 */
4575static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4576 uint32_t *msg_buf)
4577{
4578 struct sir_set_vdev_ies_per_band *p_msg =
4579 (struct sir_set_vdev_ies_per_band *)msg_buf;
4580
4581 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004582 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004583 return;
4584 }
4585
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004586 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004587 p_msg->vdev_id);
4588 /* intentionally using NULL here so that self capabilty are sent */
4589 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4590 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004591 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004592}
4593
4594/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004595 * lim_process_set_pdev_IEs() - process the set pdev IE req
4596 * @mac_ctx: Pointer to Global MAC structure
4597 * @msg_buf: Pointer to the SME message buffer
4598 *
4599 * This function is called by limProcessMessageQueue(). This
4600 * function sets the PDEV IEs to the FW.
4601 *
4602 * Return: None
4603 */
4604static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4605{
4606 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4607
4608 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4609
4610 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004611 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004612 return;
4613 }
4614
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004615 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004616 ht_vht_cfg->nss);
4617 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4618
4619 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4620 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4621 ht_vht_cfg->nss);
4622}
4623
4624/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304625 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4626 *
4627 * access policy
4628 * @mac_ctx: pointer to mac context
4629 * @msg: message buffer
4630 *
4631 * function processes vendor IE and access policy from SME and updates PE
4632 *
4633 * session entry
4634 *
4635 * return: none
4636*/
4637static void lim_process_sme_update_access_policy_vendor_ie(
4638 tpAniSirGlobal mac_ctx,
4639 uint32_t *msg)
4640{
4641 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4642 struct sPESession *pe_session_entry;
Pragaspathi Thilagaraj9b7a1162018-05-07 16:28:13 +05304643 uint16_t num_bytes;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304644
4645 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004646 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304647 return;
4648 }
4649 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4650 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4651 update_vendor_ie->sme_session_id);
4652
4653 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004654 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304655 update_vendor_ie->sme_session_id);
4656 return;
4657 }
4658 if (pe_session_entry->access_policy_vendor_ie)
4659 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4660
4661 num_bytes = update_vendor_ie->ie[1] + 2;
4662 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4663
4664 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004665 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304666 return;
4667 }
4668 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4669 &update_vendor_ie->ie[0], num_bytes);
4670
4671 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4672}
4673
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004674#ifdef CONFIG_VDEV_SM
4675QDF_STATUS lim_sta_mlme_vdev_disconnect_bss(struct vdev_mlme_obj *vdev_mlme,
4676 uint16_t data_len, void *data)
4677{
4678 tpAniSirGlobal mac_ctx;
4679 struct scheduler_msg *msg = (struct scheduler_msg *)data;
4680
4681 mac_ctx = cds_get_context(QDF_MODULE_ID_PE);
4682 if (!mac_ctx) {
4683 pe_err("mac_ctx is NULL");
4684 if (data)
4685 qdf_mem_free(data);
4686 return QDF_STATUS_E_INVAL;
4687 }
4688 pe_debug("VDEV Manager disconnect bss callback type:(%d)", msg->type);
4689
4690 switch (msg->type) {
4691 case eWNI_SME_DEAUTH_REQ:
4692 __lim_process_sme_deauth_req(mac_ctx,
4693 (uint32_t *)msg->bodyptr);
4694 break;
4695 case eWNI_SME_DISASSOC_CNF:
4696 case eWNI_SME_DEAUTH_CNF:
4697 __lim_process_sme_disassoc_cnf(mac_ctx,
4698 (uint32_t *)msg->bodyptr);
4699 break;
4700 case eWNI_SME_DISASSOC_REQ:
4701 __lim_process_sme_disassoc_req(mac_ctx,
4702 (uint32_t *)msg->bodyptr);
4703 break;
4704 default:
4705 pe_debug("Wrong message type received %d", msg->type);
4706 }
4707 return QDF_STATUS_SUCCESS;
4708}
4709#endif
4710
4711static void lim_process_sme_disassoc_cnf(tpAniSirGlobal mac_ctx,
4712 struct scheduler_msg *msg)
4713{
4714#ifdef CONFIG_VDEV_SM
4715 tSirSmeDisassocCnf sme_disassoc_cnf;
4716 tpPESession session;
4717 uint8_t session_id;
4718 QDF_STATUS status;
4719
4720 qdf_mem_copy(&sme_disassoc_cnf, msg->bodyptr,
4721 sizeof(struct sSirSmeDisassocCnf));
4722
4723 session = pe_find_session_by_bssid(mac_ctx,
4724 sme_disassoc_cnf.bssid.bytes,
4725 &session_id);
4726
4727 if (LIM_IS_STA_ROLE(session)) {
4728 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4729 WLAN_VDEV_SM_EV_DOWN,
4730 sizeof(*msg),
4731 msg);
4732 } else {
4733 __lim_process_sme_disassoc_cnf(mac_ctx,
4734 (uint32_t *)msg->bodyptr);
4735 }
4736#else
4737 __lim_process_sme_disassoc_cnf(mac_ctx, (uint32_t *)msg->bodyptr);
4738#endif
4739}
4740
4741static void lim_process_sme_disassoc_req(tpAniSirGlobal mac_ctx,
4742 struct scheduler_msg *msg)
4743{
4744#ifdef CONFIG_VDEV_SM
4745 tSirSmeDisassocReq disassoc_req;
4746 tpPESession session;
4747 uint8_t session_id;
4748 QDF_STATUS status;
4749
4750 qdf_mem_copy(&disassoc_req, msg->bodyptr, sizeof(tSirSmeDisassocReq));
4751
4752 session = pe_find_session_by_bssid(mac_ctx,
4753 disassoc_req.bssid.bytes,
4754 &session_id);
4755 if (LIM_IS_STA_ROLE(session)) {
4756 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4757 WLAN_VDEV_SM_EV_DOWN,
4758 sizeof(*msg),
4759 msg);
4760 } else {
4761 __lim_process_sme_disassoc_req(mac_ctx,
4762 (uint32_t *)msg->bodyptr);
4763 }
4764#else
4765 __lim_process_sme_disassoc_req(mac_ctx, (uint32_t *)msg->bodyptr);
4766#endif
4767}
4768
4769static void lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
4770 struct scheduler_msg *msg)
4771{
4772#ifdef CONFIG_VDEV_SM
4773 tSirSmeDeauthReq sme_deauth_req;
4774 tpPESession session;
4775 uint8_t session_id;
4776 QDF_STATUS status;
4777
4778 qdf_mem_copy(&sme_deauth_req, msg->bodyptr, sizeof(tSirSmeDeauthReq));
4779
4780 session = pe_find_session_by_bssid(mac_ctx,
4781 sme_deauth_req.bssid.bytes,
4782 &session_id);
4783 if (LIM_IS_STA_ROLE(session)) {
4784 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4785 WLAN_VDEV_SM_EV_DOWN,
4786 sizeof(*msg),
4787 msg);
4788 } else {
4789 __lim_process_sme_deauth_req(mac_ctx,
4790 (uint32_t *)msg->bodyptr);
4791 }
4792#else
4793 __lim_process_sme_deauth_req(mac_ctx, (uint32_t *)msg->bodyptr);
4794#endif
4795}
4796
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304797/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004798 * lim_process_sme_req_messages()
4799 *
4800 ***FUNCTION:
4801 * This function is called by limProcessMessageQueue(). This
4802 * function processes SME request messages from HDD or upper layer
4803 * application.
4804 *
4805 ***LOGIC:
4806 *
4807 ***ASSUMPTIONS:
4808 *
4809 ***NOTE:
4810 *
4811 * @param pMac Pointer to Global MAC structure
4812 * @param msgType Indicates the SME message type
4813 * @param *pMsgBuf A pointer to the SME message buffer
4814 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4815 * false - if pMsgBuf is not to be freed.
4816 */
4817
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004818bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4819 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004820{
Jeff Johnson33142e62018-05-06 17:58:36 -07004821 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 -08004822 uint32_t *pMsgBuf = pMsg->bodyptr;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004823
4824 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004825 lim_msg_str(pMsg->type), pMsg->type,
4826 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4827 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004828
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004829 /* If no insert NOA required then execute the code below */
4830
4831 switch (pMsg->type) {
4832 case eWNI_SME_SYS_READY_IND:
4833 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4834 break;
4835
4836 case eWNI_SME_START_BSS_REQ:
4837 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4838 break;
4839
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004840 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4841 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4842 break;
4843 case eWNI_SME_JOIN_REQ:
4844 __lim_process_sme_join_req(pMac, pMsgBuf);
4845 break;
4846
4847 case eWNI_SME_REASSOC_REQ:
4848 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4849 break;
4850
4851 case eWNI_SME_DISASSOC_REQ:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004852 lim_process_sme_disassoc_req(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004853 break;
4854
4855 case eWNI_SME_DISASSOC_CNF:
4856 case eWNI_SME_DEAUTH_CNF:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004857 lim_process_sme_disassoc_cnf(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004858 break;
4859
4860 case eWNI_SME_DEAUTH_REQ:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004861 lim_process_sme_deauth_req(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004862 break;
4863
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304864 case eWNI_SME_SEND_DISASSOC_FRAME:
4865 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4866 break;
4867
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004868 case eWNI_SME_SETCONTEXT_REQ:
4869 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4870 break;
4871
4872 case eWNI_SME_STOP_BSS_REQ:
4873 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4874 break;
4875
4876 case eWNI_SME_ASSOC_CNF:
4877 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004878 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004879 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4880 pMsgBuf);
4881 break;
4882
4883 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004884 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004885 __lim_process_sme_addts_req(pMac, pMsgBuf);
4886 break;
4887
4888 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004889 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004890 __lim_process_sme_delts_req(pMac, pMsgBuf);
4891 break;
4892
4893 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004894 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004895 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4896 break;
4897
4898 case eWNI_SME_GET_STATISTICS_REQ:
4899 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4900 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4901 bufConsumed = false;
4902 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004903#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004904 case eWNI_SME_GET_TSM_STATS_REQ:
4905 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4906 bufConsumed = false;
4907 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004908#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004909 case eWNI_SME_GET_ASSOC_STAS_REQ:
4910 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4911 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304912 case eWNI_SME_SESSION_UPDATE_PARAM:
4913 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004914 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304915 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4916 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4917 bufConsumed = false;
4918 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004919 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4920 /* Update the beaconInterval */
4921 __lim_process_sme_change_bi(pMac, pMsgBuf);
4922 break;
4923
4924#ifdef QCA_HT_2040_COEX
4925 case eWNI_SME_SET_HT_2040_MODE:
4926 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4927 break;
4928#endif
4929
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004930 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4931 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4932 __lim_process_report_message(pMac, pMsg);
4933 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004934
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004935 case eWNI_SME_FT_PRE_AUTH_REQ:
4936 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4937 break;
4938 case eWNI_SME_FT_UPDATE_KEY:
4939 lim_process_ft_update_key(pMac, pMsgBuf);
4940 break;
4941
4942 case eWNI_SME_FT_AGGR_QOS_REQ:
4943 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4944 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004945
4946 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4947 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4948 break;
4949#ifdef FEATURE_WLAN_TDLS
4950 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4951 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4952 break;
4953 case eWNI_SME_TDLS_ADD_STA_REQ:
4954 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4955 break;
4956 case eWNI_SME_TDLS_DEL_STA_REQ:
4957 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4958 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004959#endif
4960 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4961 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4962 break;
4963
4964 case eWNI_SME_CHANNEL_CHANGE_REQ:
4965 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4966 break;
4967
4968 case eWNI_SME_START_BEACON_REQ:
4969 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4970 break;
4971
4972 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4973 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4974 break;
4975
4976 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4977 lim_process_update_add_ies(pMac, pMsgBuf);
4978 break;
4979
4980 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4981 lim_process_modify_add_ies(pMac, pMsgBuf);
4982 break;
4983 case eWNI_SME_SET_HW_MODE_REQ:
4984 lim_process_set_hw_mode(pMac, pMsgBuf);
4985 break;
4986 case eWNI_SME_NSS_UPDATE_REQ:
4987 lim_process_nss_update_request(pMac, pMsgBuf);
4988 break;
4989 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4990 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4991 break;
4992 case eWNI_SME_SET_IE_REQ:
4993 lim_process_set_ie_req(pMac, pMsgBuf);
4994 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304995 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4996 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
4997 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304998 case eWNI_SME_EXT_CHANGE_CHANNEL:
4999 lim_process_ext_change_channel(pMac, pMsgBuf);
5000 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005001 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5002 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5003 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005004 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5005 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005006 break;
5007 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5008 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5009 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305010 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5011 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5012 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07005013 case eWNI_SME_UPDATE_CONFIG:
5014 lim_process_sme_update_config(pMac,
5015 (struct update_config *)pMsgBuf);
5016 break;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08005017 case eWNI_SME_SET_ADDBA_ACCEPT:
5018 lim_process_sme_set_addba_accept(pMac,
5019 (struct sme_addba_accept *)pMsgBuf);
5020 break;
Arif Hussaineb8ba362018-03-07 19:15:13 -08005021 case eWNI_SME_UPDATE_EDCA_PROFILE:
5022 lim_process_sme_update_edca_params(pMac, pMsg->bodyval);
5023 break;
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07005024 case WNI_SME_UPDATE_MU_EDCA_PARAMS:
5025 lim_process_sme_update_mu_edca_params(pMac, pMsg->bodyval);
5026 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005027 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305028 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005029 pMsg->bodyptr = NULL;
5030 break;
5031 } /* switch (msgType) */
5032
5033 return bufConsumed;
5034} /*** end lim_process_sme_req_messages() ***/
5035
5036/**
5037 * lim_process_sme_start_beacon_req()
5038 *
5039 ***FUNCTION:
5040 * This function is called by limProcessMessageQueue(). This
5041 * function processes SME request messages from HDD or upper layer
5042 * application.
5043 *
5044 ***LOGIC:
5045 *
5046 ***ASSUMPTIONS:
5047 *
5048 ***NOTE:
5049 *
5050 * @param pMac Pointer to Global MAC structure
5051 * @param msgType Indicates the SME message type
5052 * @param *pMsgBuf A pointer to the SME message buffer
5053 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5054 * false - if pMsgBuf is not to be freed.
5055 */
5056static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5057{
5058 tpSirStartBeaconIndication pBeaconStartInd;
5059 tpPESession psessionEntry;
5060 uint8_t sessionId; /* PE sessionID */
5061
5062 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005063 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005064 return;
5065 }
5066
5067 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5068 psessionEntry = pe_find_session_by_bssid(pMac,
5069 pBeaconStartInd->bssid,
5070 &sessionId);
5071 if (psessionEntry == NULL) {
5072 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005073 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005074 return;
5075 }
5076
5077 if (pBeaconStartInd->beaconStartStatus == true) {
5078 /*
5079 * Currently this Indication comes from SAP
5080 * to start Beacon Tx on a DFS channel
5081 * since beaconing has to be done on DFS
5082 * channel only after CAC WAIT is completed.
5083 * On a DFS Channel LIM does not start beacon
5084 * Tx right after the WMA_ADD_BSS_RSP.
5085 */
5086 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05305087 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005088 FL("Start Beacon with ssid %s Ch %d"),
5089 psessionEntry->ssId.ssId,
5090 psessionEntry->currentOperChannel);
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05305091 lim_send_beacon(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08005092 lim_enable_obss_detection_config(pMac, psessionEntry);
Arif Hussain05fb4872018-01-03 16:02:55 -08005093 lim_send_obss_color_collision_cfg(pMac, psessionEntry,
5094 OBSS_COLOR_COLLISION_DETECTION);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005095 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005096 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005097 return;
5098 }
5099}
5100
5101/**
5102 * lim_process_sme_channel_change_request() - process sme ch change req
5103 *
5104 * @mac_ctx: Pointer to Global MAC structure
5105 * @msg_buf: pointer to the SME message buffer
5106 *
5107 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5108 *
5109 * Return: None
5110 */
5111static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5112 uint32_t *msg_buf)
5113{
5114 tpSirChanChangeRequest ch_change_req;
5115 tpPESession session_entry;
5116 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005117 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005118 uint32_t val = 0;
5119
5120 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005121 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005122 return;
5123 }
5124 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5125
5126 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5127 ch_change_req->targetChannel);
5128
5129 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5130 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005131 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005132 return;
5133 }
5134
5135 session_entry = pe_find_session_by_bssid(mac_ctx,
5136 ch_change_req->bssid, &session_id);
5137 if (session_entry == NULL) {
5138 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005139 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005140 return;
5141 }
5142
Manjunathappa Prakash34fda792018-02-07 18:23:42 -08005143 if ((session_entry->currentOperChannel ==
5144 ch_change_req->targetChannel) &&
5145 (session_entry->ch_width == ch_change_req->ch_width)) {
5146 pe_err("Target channel and mode is same as current channel and mode channel %d and mode %d",
5147 session_entry->currentOperChannel, session_entry->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005148 return;
5149 }
5150
5151 if (LIM_IS_AP_ROLE(session_entry))
5152 session_entry->channelChangeReasonCode =
5153 LIM_SWITCH_CHANNEL_SAP_DFS;
5154 else
5155 session_entry->channelChangeReasonCode =
5156 LIM_SWITCH_CHANNEL_OPERATION;
5157
Bala Venkateshb39ed152017-12-26 19:35:27 +05305158 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d, nw_type %d, dot11mode %d",
5159 session_entry->currentOperChannel,
5160 ch_change_req->targetChannel,
5161 ch_change_req->ch_width,
5162 ch_change_req->nw_type,
5163 ch_change_req->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005164
5165 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005166 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005167 session_entry->ch_center_freq_seg0 =
5168 ch_change_req->center_freq_seg_0;
5169 session_entry->ch_center_freq_seg1 =
5170 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005171 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005172 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005173 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005174 session_entry->htRecommendedTxWidthSet =
5175 session_entry->htSupportedChannelWidthSet;
5176 session_entry->currentOperChannel =
5177 ch_change_req->targetChannel;
5178 session_entry->limRFBand =
5179 lim_get_rf_band(session_entry->currentOperChannel);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305180 session_entry->cac_duration_ms = ch_change_req->cac_duration_ms;
5181 session_entry->dfs_regdomain = ch_change_req->dfs_regdomain;
5182 session_entry->maxTxPower = max_tx_pwr;
Vignesh Viswanathan153ae932018-04-11 14:24:13 +05305183
5184 /* Update the global beacon filter */
5185 lim_update_bcn_probe_filter(mac_ctx, session_entry);
5186
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005187 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08005188 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005189 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005190 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005191 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005192 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005193 }
5194
5195 session_entry->lim11hEnable = val;
5196 session_entry->dot11mode = ch_change_req->dot11mode;
Bala Venkateshb39ed152017-12-26 19:35:27 +05305197 session_entry->nwType = ch_change_req->nw_type;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305198 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005199 &ch_change_req->operational_rateset,
5200 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305201 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005202 &ch_change_req->extended_rateset,
5203 sizeof(session_entry->extRateSet));
Abhishek Singh20a8e442018-09-12 15:50:44 +05305204
5205#ifdef CONFIG_VDEV_SM
Abhishek Singha063f1c2018-09-19 11:37:51 +05305206 mlme_set_chan_switch_in_progress(session_entry->vdev, true);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305207 if (wlan_vdev_mlme_get_state(session_entry->vdev) ==
5208 WLAN_VDEV_S_DFS_CAC_WAIT)
5209 wlan_vdev_mlme_sm_deliver_evt(session_entry->vdev,
5210 WLAN_VDEV_SM_EV_RADAR_DETECTED,
5211 sizeof(*session_entry),
5212 session_entry);
5213 else
5214 wlan_vdev_mlme_sm_deliver_evt(session_entry->vdev,
5215 WLAN_VDEV_SM_EV_CSA_COMPLETE,
5216 sizeof(*session_entry),
5217 session_entry);
5218
5219
5220#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005221 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5222 session_entry->ch_center_freq_seg0,
5223 session_entry->ch_center_freq_seg1,
5224 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07005225 max_tx_pwr, session_entry->peSessionId,
5226 ch_change_req->cac_duration_ms,
5227 ch_change_req->dfs_regdomain);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305228#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005229}
5230
5231/******************************************************************************
5232* lim_start_bss_update_add_ie_buffer()
5233*
5234***FUNCTION:
5235* This function checks the src buffer and its length and then malloc for
5236* dst buffer update the same
5237*
5238***LOGIC:
5239*
5240***ASSUMPTIONS:
5241*
5242***NOTE:
5243*
5244* @param pMac Pointer to Global MAC structure
5245* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5246* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5247* @param *pSrcData_buff A pointer of uint8_t src buffer
5248* @param srcDataLen src buffer length
5249******************************************************************************/
5250
5251static void
5252lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5253 uint8_t **pDstData_buff,
5254 uint16_t *pDstDataLen,
5255 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5256{
5257
5258 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5259 *pDstDataLen = srcDataLen;
5260
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305261 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005262
5263 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005264 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005265 return;
5266 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305267 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005268 } else {
5269 *pDstData_buff = NULL;
5270 *pDstDataLen = 0;
5271 }
5272}
5273
5274/******************************************************************************
5275* lim_update_add_ie_buffer()
5276*
5277***FUNCTION:
5278* This function checks the src buffer and length if src buffer length more
5279* than dst buffer length then free the dst buffer and malloc for the new src
5280* length, and update the dst buffer and length. But if dst buffer is bigger
5281* than src buffer length then it just update the dst buffer and length
5282*
5283***LOGIC:
5284*
5285***ASSUMPTIONS:
5286*
5287***NOTE:
5288*
5289* @param pMac Pointer to Global MAC structure
5290* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5291* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5292* @param *pSrcData_buff A pointer of uint8_t src buffer
5293* @param srcDataLen src buffer length
5294******************************************************************************/
5295
5296static void
5297lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5298 uint8_t **pDstData_buff,
5299 uint16_t *pDstDataLen,
5300 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5301{
5302
5303 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005304 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005305 return;
5306 }
5307
5308 if (srcDataLen > *pDstDataLen) {
5309 *pDstDataLen = srcDataLen;
5310 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305311 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005312 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305313 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005314
5315 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005316 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005317 *pDstDataLen = 0;
5318 return;
5319 }
5320 }
5321
5322 /* copy the content of buffer into dst buffer
5323 */
5324 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305325 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005326
5327}
5328
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005329/**
5330 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5331 * @pMac : Pointer to Global MAC structure
5332 * @pDstData_buff : A pointer to pointer of dst buffer
5333 * @pDstDataLen : A pointer to pointer of dst buffer length
5334 * @pModifyIE : A pointer to tSirModifyIE
5335 *
5336 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5337 *
5338 * Return:
5339 * True or false depending upon whether IE is updated or not
5340 */
5341static bool
5342lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5343 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5344{
Hong Shi1553d692016-09-28 12:16:19 +08005345 int32_t oui_length;
5346 uint8_t *ibss_ie = NULL;
5347 uint8_t *vendor_ie;
5348#define MAC_VENDOR_OUI "\x00\x16\x32"
5349#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005350
5351 ibss_ie = pModifyIE->pIEBuffer;
5352 oui_length = pModifyIE->oui_length;
5353
5354 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005355 pe_err("Invalid set IBSS vendor IE command length %d",
5356 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005357 return false;
5358 }
5359
Hong Shi1553d692016-09-28 12:16:19 +08005360 /*
5361 * Why replace only beacon OUI data here:
5362 * 1. other ie (such as wpa) shall not be overwritten here.
5363 * 2. per spec, beacon oui ie might be set twice and original one
5364 * shall be updated.
5365 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005366 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005367 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5368 if (vendor_ie) {
5369 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5370 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5371 pModifyIE->ieBufferlength);
5372 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005373 uint16_t new_length;
5374 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005375
Naveen Rawat668dee32017-09-29 14:39:40 -07005376 /*
5377 * check for uint16 overflow before using sum of two numbers as
5378 * length of size to malloc
5379 */
5380 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5381 pe_err("U16 overflow due to %d + %d",
5382 pModifyIE->ieBufferlength, *pDstDataLen);
5383 return false;
5384 }
5385
5386 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5387 new_ptr = qdf_mem_malloc(new_length);
Hong Shi1553d692016-09-28 12:16:19 +08005388 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005389 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005390 return false;
5391 }
5392 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5393 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5394 pModifyIE->ieBufferlength);
5395 qdf_mem_free(*pDstData_buff);
5396 *pDstDataLen = new_length;
5397 *pDstData_buff = new_ptr;
5398 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005399 return true;
5400}
5401
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005402/*
5403* lim_process_modify_add_ies() - process modify additional IE req.
5404*
5405* @mac_ctx: Pointer to Global MAC structure
5406* @msg_buf: pointer to the SME message buffer
5407*
5408* This function update the PE buffers for additional IEs.
5409*
5410* Return: None
5411*/
5412static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5413 uint32_t *msg_buf)
5414{
5415 tpSirModifyIEsInd modify_add_ies;
5416 tpPESession session_entry;
5417 uint8_t session_id;
5418 bool ret = false;
5419 tSirAddIeParams *add_ie_params;
5420
5421 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005422 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005423 return;
5424 }
5425
5426 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5427 /* Incoming message has smeSession, use BSSID to find PE session */
5428 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005429 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005430
5431 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005432 pe_err("Session not found for given bssid"
5433 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005434 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005435 goto end;
5436 }
5437 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5438 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5439 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005440 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005441 modify_add_ies->modifyIE.pIEBuffer,
5442 modify_add_ies->modifyIE.ieBufferlength,
5443 modify_add_ies->modifyIE.ieID,
5444 modify_add_ies->modifyIE.ieIDLen,
5445 modify_add_ies->updateType);
5446 goto end;
5447 }
5448 add_ie_params = &session_entry->addIeParams;
5449 switch (modify_add_ies->updateType) {
5450 case eUPDATE_IE_PROBE_RESP:
5451 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005452 if (LIM_IS_IBSS_ROLE(session_entry)) {
5453 lim_update_ibss_prop_add_ies(mac_ctx,
5454 &add_ie_params->probeRespData_buff,
5455 &add_ie_params->probeRespDataLen,
5456 &modify_add_ies->modifyIE);
5457 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005458 break;
5459 case eUPDATE_IE_ASSOC_RESP:
5460 /* assoc resp IE */
5461 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305462 QDF_TRACE(QDF_MODULE_ID_PE,
5463 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005464 "assoc resp add ie not present %d"),
5465 add_ie_params->assocRespDataLen);
5466 }
5467 /* search through the buffer and modify the IE */
5468 break;
5469 case eUPDATE_IE_PROBE_BCN:
5470 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005471 if (LIM_IS_IBSS_ROLE(session_entry)) {
5472 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5473 &add_ie_params->probeRespBCNData_buff,
5474 &add_ie_params->probeRespBCNDataLen,
5475 &modify_add_ies->modifyIE);
5476 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005477 if (ret == true && modify_add_ies->modifyIE.notify) {
5478 lim_handle_param_update(mac_ctx,
5479 modify_add_ies->updateType);
5480 }
5481 break;
5482 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005483 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005484 modify_add_ies->updateType);
5485 break;
5486 }
5487end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305488 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005489 modify_add_ies->modifyIE.pIEBuffer = NULL;
5490}
5491
5492/*
5493* lim_process_update_add_ies() - process additional IE update req
5494*
5495* @mac_ctx: Pointer to Global MAC structure
5496* @msg_buf: pointer to the SME message buffer
5497*
5498* This function update the PE buffers for additional IEs.
5499*
5500* Return: None
5501*/
5502static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5503 uint32_t *msg_buf)
5504{
5505 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5506 uint8_t session_id;
5507 tpPESession session_entry;
5508 tSirAddIeParams *addn_ie;
5509 uint16_t new_length = 0;
5510 uint8_t *new_ptr = NULL;
5511 tSirUpdateIE *update_ie;
5512
5513 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005514 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005515 return;
5516 }
5517 update_ie = &update_add_ies->updateIE;
5518 /* incoming message has smeSession, use BSSID to find PE session */
5519 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005520 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005521
5522 if (NULL == session_entry) {
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05305523 pe_debug("Session not found for given bssid"
5524 MAC_ADDRESS_STR,
5525 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005526 goto end;
5527 }
5528 addn_ie = &session_entry->addIeParams;
5529 /* if len is 0, upper layer requested freeing of buffer */
5530 if (0 == update_ie->ieBufferlength) {
5531 switch (update_add_ies->updateType) {
5532 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305533 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005534 addn_ie->probeRespData_buff = NULL;
5535 addn_ie->probeRespDataLen = 0;
5536 break;
5537 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305538 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005539 addn_ie->assocRespData_buff = NULL;
5540 addn_ie->assocRespDataLen = 0;
5541 break;
5542 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305543 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005544 addn_ie->probeRespBCNData_buff = NULL;
5545 addn_ie->probeRespBCNDataLen = 0;
5546
5547 if (update_ie->notify)
5548 lim_handle_param_update(mac_ctx,
5549 update_add_ies->updateType);
5550 break;
5551 default:
5552 break;
5553 }
5554 return;
5555 }
5556 switch (update_add_ies->updateType) {
5557 case eUPDATE_IE_PROBE_RESP:
5558 if (update_ie->append) {
5559 /*
5560 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005561 * with combined length.
5562 * Multiple back to back append commands
5563 * can lead to a huge length.So, check
5564 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005565 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005566 if (addn_ie->probeRespDataLen >
5567 (USHRT_MAX - update_ie->ieBufferlength)) {
5568 pe_err("IE Length overflow, curr:%d, new:%d",
5569 addn_ie->probeRespDataLen,
5570 update_ie->ieBufferlength);
5571 goto end;
5572 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005573 new_length = update_ie->ieBufferlength +
5574 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305575 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005576 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005577 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005578 goto end;
5579 }
5580 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305581 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005582 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305583 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005584 update_ie->pAdditionIEBuffer,
5585 update_ie->ieBufferlength);
5586 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305587 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005588 /* adjust length accordingly */
5589 addn_ie->probeRespDataLen = new_length;
5590 /* save refernece of local buffer in PE session */
5591 addn_ie->probeRespData_buff = new_ptr;
5592 goto end;
5593 }
5594 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5595 &addn_ie->probeRespDataLen,
5596 update_ie->pAdditionIEBuffer,
5597 update_ie->ieBufferlength);
5598 break;
5599 case eUPDATE_IE_ASSOC_RESP:
5600 /* assoc resp IE */
5601 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5602 &addn_ie->assocRespDataLen,
5603 update_ie->pAdditionIEBuffer,
5604 update_ie->ieBufferlength);
5605 break;
5606 case eUPDATE_IE_PROBE_BCN:
5607 /* probe resp Bcn IE */
5608 lim_update_add_ie_buffer(mac_ctx,
5609 &addn_ie->probeRespBCNData_buff,
5610 &addn_ie->probeRespBCNDataLen,
5611 update_ie->pAdditionIEBuffer,
5612 update_ie->ieBufferlength);
5613 if (update_ie->notify)
5614 lim_handle_param_update(mac_ctx,
5615 update_add_ies->updateType);
5616 break;
5617 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005618 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005619 break;
5620 }
5621end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305622 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005623 update_ie->pAdditionIEBuffer = NULL;
5624}
5625
5626/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305627 * send_extended_chan_switch_action_frame()- function to send ECSA
5628 * action frame for each sta connected to SAP/GO and AP in case of
5629 * STA .
5630 * @mac_ctx: pointer to global mac structure
5631 * @new_channel: new channel to switch to.
5632 * @ch_bandwidth: BW of channel to calculate op_class
5633 * @session_entry: pe session
5634 *
5635 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5636 *
5637 * Return: void
5638 */
5639
5640static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5641 uint16_t new_channel, uint8_t ch_bandwidth,
5642 tpPESession session_entry)
5643{
5644 uint16_t op_class;
5645 uint8_t switch_mode = 0, i;
5646 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005647 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305648
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005649 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305650 mac_ctx->scan.countryCodeCurrent,
5651 new_channel,
5652 ch_bandwidth);
5653
5654 if (LIM_IS_AP_ROLE(session_entry) &&
5655 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005656 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305657
gaoleze2920bd2017-03-21 17:38:42 +08005658 switch_count = session_entry->gLimChannelSwitch.switchCount;
5659
Abhishek Singh518323d2015-10-19 17:42:01 +05305660 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005661 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305662 psta =
5663 session_entry->dph.dphHashTable.pDphNodeArray + i;
5664 if (psta && psta->added)
5665 lim_send_extended_chan_switch_action_frame(
5666 mac_ctx,
5667 psta->staAddr,
5668 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005669 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305670 }
5671 } else if (LIM_IS_STA_ROLE(session_entry)) {
5672 lim_send_extended_chan_switch_action_frame(mac_ctx,
5673 session_entry->bssId,
5674 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005675 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305676 }
5677
5678}
5679
gaolez76d2a162017-03-21 19:23:58 +08005680void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5681 uint16_t new_channel,
5682 uint8_t ch_bandwidth,
5683 tpPESession session_entry)
5684{
5685 uint16_t op_class;
5686 uint8_t switch_mode = 0, i;
5687 uint8_t switch_count;
5688 tpDphHashNode psta;
5689 tpDphHashNode dph_node_array_ptr;
5690
5691 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5692
5693 op_class = wlan_reg_dmn_get_opclass_from_channel(
5694 mac_ctx->scan.countryCodeCurrent,
5695 new_channel, ch_bandwidth);
5696
5697 if (LIM_IS_AP_ROLE(session_entry) &&
5698 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5699 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5700
5701 switch_count = session_entry->gLimChannelSwitch.switchCount;
5702
5703 if (LIM_IS_AP_ROLE(session_entry)) {
5704 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5705 psta = dph_node_array_ptr + i;
5706 if (!(psta && psta->added))
5707 continue;
5708 if (session_entry->lim_non_ecsa_cap_num == 0)
5709 lim_send_extended_chan_switch_action_frame
5710 (mac_ctx, psta->staAddr, switch_mode,
5711 op_class, new_channel, switch_count,
5712 session_entry);
5713 else
5714 lim_send_channel_switch_mgmt_frame
5715 (mac_ctx, psta->staAddr, switch_mode,
5716 new_channel, switch_count,
5717 session_entry);
5718 }
5719 } else if (LIM_IS_STA_ROLE(session_entry)) {
5720 lim_send_extended_chan_switch_action_frame
5721 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5722 new_channel, switch_count, session_entry);
5723 }
5724}
5725
5726/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005727 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5728 *
5729 * @mac_ctx: Pointer to Global MAC structure
5730 * @msg_buf: pointer to the SME message buffer
5731 *
5732 * This function processes SME request messages from HDD or upper layer
5733 * application.
5734 *
5735 * Return: None
5736 */
5737static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5738 uint32_t *msg_buf)
5739{
5740 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5741 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005742 uint8_t session_id;
5743 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005744 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005745
5746 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005747 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005748 return;
5749 }
5750
5751 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5752 session_entry = pe_find_session_by_bssid(mac_ctx,
5753 dfs_csa_ie_req->bssid, &session_id);
5754 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005755 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005756 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5757 return;
5758 }
5759
5760 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005761 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005762 GET_LIM_SYSTEM_ROLE(session_entry));
5763 return;
5764 }
5765
5766 /* target channel */
5767 session_entry->gLimChannelSwitch.primaryChannel =
5768 dfs_csa_ie_req->targetChannel;
5769
5770 /* Channel switch announcement needs to be included in beacon */
5771 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005772 session_entry->gLimChannelSwitch.switchCount =
5773 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005774 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005775 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305776 session_entry->gLimChannelSwitch.sec_ch_offset =
5777 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005778 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005779 session_entry->gLimChannelSwitch.switchMode =
5780 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005781
5782 /*
5783 * Validate if SAP is operating HT or VHT mode and set the Channel
5784 * Switch Wrapper element with the Wide Band Switch subelement.
5785 */
5786 if (true != session_entry->vhtCapability)
5787 goto skip_vht;
5788
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005789 /* Now encode the Wider Ch BW element depending on the ch width */
5790 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005791 switch (dfs_csa_ie_req->ch_params.ch_width) {
5792 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005793 /*
5794 * Wide channel BW sublement in channel wrapper element is not
5795 * required in case of 20 Mhz operation. Currently It is set
5796 * only set in case of 40/80 Mhz Operation.
5797 */
5798 session_entry->dfsIncludeChanWrapperIe = false;
5799 wider_bw_ch_switch->newChanWidth =
5800 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5801 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005802 case CH_WIDTH_40MHZ:
5803 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005804 wider_bw_ch_switch->newChanWidth =
5805 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5806 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005807 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005808 session_entry->dfsIncludeChanWrapperIe = true;
5809 wider_bw_ch_switch->newChanWidth =
5810 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5811 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005812 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005813 session_entry->dfsIncludeChanWrapperIe = true;
5814 wider_bw_ch_switch->newChanWidth =
5815 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5816 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005817 case CH_WIDTH_80P80MHZ:
5818 session_entry->dfsIncludeChanWrapperIe = true;
5819 wider_bw_ch_switch->newChanWidth =
5820 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005821 /*
5822 * This is not applicable for 20/40/80 Mhz.
5823 * Only used when we support 80+80 Mhz operation.
5824 * In case of 80+80 Mhz, this parameter indicates
5825 * center channel frequency index of 80 Mhz channel of
5826 * frequency segment 1.
5827 */
5828 wider_bw_ch_switch->newCenterChanFreq1 =
5829 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005830 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005831 default:
5832 session_entry->dfsIncludeChanWrapperIe = false;
5833 /*
5834 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5835 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5836 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005837 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005838 break;
5839 }
5840 /* Fetch the center channel based on the channel width */
5841 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005842 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005843skip_vht:
5844 /* Send CSA IE request from here */
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05305845 lim_send_dfs_chan_sw_ie_update(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305846
5847 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5848 ch_offset = BW80;
5849 else
5850 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5851
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005852 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305853 session_entry->gLimChannelSwitch.switchCount,
5854 session_entry->gLimChannelSwitch.primaryChannel,
5855 session_entry->gLimChannelSwitch.ch_width,
5856 session_entry->dfsIncludeChanWrapperIe,
5857 ch_offset);
5858
gaolez76d2a162017-03-21 19:23:58 +08005859 /* Send ECSA/CSA Action frame after updating the beacon */
5860 if (CHAN_HOP_ALL_BANDS_ENABLE)
5861 lim_send_chan_switch_action_frame(mac_ctx,
5862 session_entry->gLimChannelSwitch.primaryChannel,
5863 ch_offset, session_entry);
5864 else
5865 send_extended_chan_switch_action_frame(mac_ctx,
5866 session_entry->gLimChannelSwitch.primaryChannel,
5867 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005868}
5869
5870/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305871 * lim_process_ext_change_channel()- function to send ECSA
5872 * action frame for STA/CLI .
5873 * @mac_ctx: pointer to global mac structure
5874 * @msg: params from sme for new channel.
5875 *
5876 * This function is called to send ECSA frame for STA/CLI.
5877 *
5878 * Return: void
5879 */
5880
5881static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5882 uint32_t *msg)
5883{
5884 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5885 (struct sir_sme_ext_cng_chan_req *) msg;
5886 tpPESession session_entry = NULL;
5887
5888 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005889 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305890 return;
5891 }
5892 session_entry =
5893 pe_find_session_by_sme_session_id(mac_ctx,
5894 ext_chng_channel->session_id);
5895 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005896 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305897 ext_chng_channel->session_id);
5898 return;
5899 }
5900 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005901 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305902 return;
5903 }
5904 send_extended_chan_switch_action_frame(mac_ctx,
5905 ext_chng_channel->new_channel,
5906 0, session_entry);
5907}
5908
5909/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005910 * lim_process_nss_update_request() - process sme nss update req
5911 *
5912 * @mac_ctx: Pointer to Global MAC structure
5913 * @msg_buf: pointer to the SME message buffer
5914 *
5915 * This function processes SME request messages from HDD or upper layer
5916 * application.
5917 *
5918 * Return: None
5919 */
5920static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5921 uint32_t *msg_buf)
5922{
5923 struct sir_nss_update_request *nss_update_req_ptr;
5924 tpPESession session_entry = NULL;
5925
5926 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005927 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005928 return;
5929 }
5930
5931 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305932 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005933 nss_update_req_ptr->vdev_id);
5934 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005935 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005936 nss_update_req_ptr->vdev_id);
5937 return;
5938 }
5939
5940 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005941 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005942 GET_LIM_SYSTEM_ROLE(session_entry));
5943 return;
5944 }
5945
5946 /* populate nss field in the beacon */
5947 session_entry->gLimOperatingMode.present = 1;
5948 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05305949 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
5950
5951 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
5952 (session_entry->ch_width > CH_WIDTH_80MHZ))
5953 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
5954
5955 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
5956
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005957 /* Send nss update request from here */
5958 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005959 QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005960 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005961 return;
5962 }
5963
5964 lim_send_beacon_ind(mac_ctx, session_entry);
5965}
5966
5967/**
5968 * lim_process_set_ie_req() - process sme set IE request
5969 *
5970 * @mac_ctx: Pointer to Global MAC structure
5971 * @msg_buf: pointer to the SME message buffer
5972 *
5973 * This function processes SME request messages from HDD or upper layer
5974 * application.
5975 *
5976 * Return: None
5977 */
5978static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5979{
5980 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305981 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005982
5983 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005984 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005985 return;
5986 }
5987
5988 msg = (struct send_extcap_ie *)msg_buf;
5989 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305990 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005991 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005992
5993}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005994
5995#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Arif Hussain05fb4872018-01-03 16:02:55 -08005996
5997/**
5998 * obss_color_collision_process_color_disable() - Disable bss color
5999 * @mac_ctx: Pointer to Global MAC structure
6000 * @session: pointer to session
6001 *
6002 * This function will disbale bss color.
6003 *
6004 * Return: None
6005 */
6006static void obss_color_collision_process_color_disable(tpAniSirGlobal mac_ctx,
6007 tpPESession session)
6008{
6009 tUpdateBeaconParams beacon_params;
6010
6011 if (!session) {
6012 pe_err("Invalid session");
6013 return;
6014 }
6015
6016 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6017 pe_err("Invalid SystemRole %d",
6018 GET_LIM_SYSTEM_ROLE(session));
6019 return;
6020 }
6021
6022 if (session->bss_color_changing == 1) {
6023 pe_warn("%d: color change in progress", session->smeSessionId);
6024 /* Continue color collision detection */
6025 lim_send_obss_color_collision_cfg(mac_ctx, session,
6026 OBSS_COLOR_COLLISION_DETECTION);
6027 return;
6028 }
6029
6030 if (session->he_op.bss_col_disabled == 1) {
6031 pe_warn("%d: bss color already disabled",
6032 session->smeSessionId);
6033 /* Continue free color detection */
6034 lim_send_obss_color_collision_cfg(mac_ctx, session,
6035 OBSS_COLOR_FREE_SLOT_AVAILABLE);
6036 return;
6037 }
6038
6039 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
6040 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
6041 session->he_op.bss_col_disabled = 1;
Arif Hussain05fb4872018-01-03 16:02:55 -08006042 beacon_params.bss_color_disabled = 1;
Arif Hussain2f2d3512018-03-06 12:37:03 -08006043 beacon_params.bss_color = session->he_op.bss_color;
Arif Hussain05fb4872018-01-03 16:02:55 -08006044
6045 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006046 QDF_STATUS_SUCCESS) {
Arif Hussain05fb4872018-01-03 16:02:55 -08006047 pe_err("Unable to set op mode IE in beacon");
6048 return;
6049 }
6050
6051 lim_send_beacon_params(mac_ctx, &beacon_params, session);
6052 lim_send_obss_color_collision_cfg(mac_ctx, session,
6053 OBSS_COLOR_FREE_SLOT_AVAILABLE);
6054}
6055
6056/**
6057 * obss_color_collision_process_color_change() - Process bss color change
6058 * @mac_ctx: Pointer to Global MAC structure
6059 * @session: pointer to session
6060 * @obss_color_info: obss color collision/free slot indication info
6061 *
6062 * This function selects new color ib case of bss color collision.
6063 *
6064 * Return: None
6065 */
6066static void obss_color_collision_process_color_change(tpAniSirGlobal mac_ctx,
6067 tpPESession session,
6068 struct wmi_obss_color_collision_info *obss_color_info)
6069{
6070 int i, num_bss_color = 0;
6071 uint32_t bss_color_bitmap;
6072 uint8_t bss_color_index_array[MAX_BSS_COLOR_VALUE];
6073 uint32_t rand_byte = 0;
6074 struct sir_set_he_bss_color he_bss_color;
6075 bool is_color_collision = false;
6076
6077
6078 if (session->bss_color_changing == 1) {
6079 pe_err("%d: color change in progress", session->smeSessionId);
6080 return;
6081 }
6082
6083 if (!session->he_op.bss_col_disabled) {
6084 if (session->he_op.bss_color < 32)
6085 is_color_collision = (obss_color_info->
6086 obss_color_bitmap_bit0to31 >>
6087 session->he_op.bss_color) & 0x01;
6088 else
6089 is_color_collision = (obss_color_info->
6090 obss_color_bitmap_bit32to63 >>
6091 (session->he_op.bss_color -
Arif Hussain9e8c5612018-04-12 16:35:48 -07006092 32)) & 0x01;
Arif Hussain05fb4872018-01-03 16:02:55 -08006093 if (!is_color_collision) {
6094 pe_err("%d: color collision not found, curr_color: %d",
6095 session->smeSessionId,
6096 session->he_op.bss_color);
6097 return;
6098 }
6099 }
6100
6101 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit0to31;
6102
6103 /* Skip color zero */
6104 bss_color_bitmap = bss_color_bitmap >> 1;
6105 for (i = 0; (i < 31) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
6106 if (!(bss_color_bitmap & 0x01)) {
6107 bss_color_index_array[num_bss_color] = i + 1;
6108 num_bss_color++;
6109 }
6110 bss_color_bitmap = bss_color_bitmap >> 1;
6111 }
6112
6113 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit32to63;
6114 for (i = 0; (i < 32) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
6115 if (!(bss_color_bitmap & 0x01)) {
6116 bss_color_index_array[num_bss_color] = i + 32;
6117 num_bss_color++;
6118 }
6119 bss_color_bitmap = bss_color_bitmap >> 1;
6120 }
6121
6122 if (num_bss_color) {
6123 qdf_get_random_bytes((void *) &rand_byte, 1);
6124 i = (rand_byte + qdf_mc_timer_get_system_ticks()) %
6125 num_bss_color;
6126 pe_debug("New bss color = %d", bss_color_index_array[i]);
6127 he_bss_color.session_id = obss_color_info->vdev_id;
6128 he_bss_color.bss_color = bss_color_index_array[i];
6129 lim_process_set_he_bss_color(mac_ctx,
6130 (uint32_t *)&he_bss_color);
6131 } else {
6132 pe_err("Unable to find bss color from bitmasp");
6133 if (obss_color_info->evt_type ==
6134 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY &&
6135 session->obss_color_collision_dec_evt ==
6136 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6137 /* In dot11BSSColorCollisionAPPeriod and
6138 * timer expired, time to disable bss color.
6139 */
6140 obss_color_collision_process_color_disable(mac_ctx,
6141 session);
6142 else
6143 /*
6144 * Enter dot11BSSColorCollisionAPPeriod period.
6145 */
6146 lim_send_obss_color_collision_cfg(mac_ctx, session,
6147 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY);
6148 }
6149}
6150
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006151void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6152{
6153 struct sir_set_he_bss_color *bss_color;
6154 tpPESession session_entry = NULL;
6155 tUpdateBeaconParams beacon_params;
6156
6157 if (!msg_buf) {
6158 pe_err("Buffer is Pointing to NULL");
6159 return;
6160 }
6161
6162 bss_color = (struct sir_set_he_bss_color *)msg_buf;
6163 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
6164 bss_color->session_id);
6165 if (!session_entry) {
6166 pe_err("Session not found for given session_id %d",
6167 bss_color->session_id);
6168 return;
6169 }
6170
6171 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6172 pe_err("Invalid SystemRole %d",
6173 GET_LIM_SYSTEM_ROLE(session_entry));
6174 return;
6175 }
6176
6177 if (bss_color->bss_color == session_entry->he_op.bss_color) {
6178 pe_err("No change in BSS color, current BSS color %d",
6179 bss_color->bss_color);
6180 return;
6181 }
6182 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
6183 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
6184 session_entry->he_op.bss_col_disabled = 1;
6185 session_entry->he_bss_color_change.countdown =
6186 BSS_COLOR_SWITCH_COUNTDOWN;
6187 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08006188 beacon_params.bss_color_disabled = 1;
6189 beacon_params.bss_color = session_entry->he_op.bss_color;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006190 session_entry->bss_color_changing = 1;
6191
6192 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006193 QDF_STATUS_SUCCESS) {
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006194 pe_err("Unable to set op mode IE in beacon");
6195 return;
6196 }
6197
6198 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
Arif Hussain05fb4872018-01-03 16:02:55 -08006199 lim_send_obss_color_collision_cfg(mac_ctx, session_entry,
6200 OBSS_COLOR_COLLISION_DETECTION_DISABLE);
6201}
6202
6203void lim_send_obss_color_collision_cfg(tpAniSirGlobal mac_ctx,
6204 tpPESession session,
6205 enum wmi_obss_color_collision_evt_type
6206 event_type)
6207{
6208 struct wmi_obss_color_collision_cfg_param *cfg_param;
6209 struct scheduler_msg msg = {0};
6210
6211 if (!session) {
6212 pe_err("Invalid session");
6213 return;
6214 }
6215
6216 if (!session->he_capable ||
6217 !session->is_session_obss_color_collision_det_enabled) {
6218 pe_debug("%d: obss color det not enabled, he_cap:%d, sup:%d:%d",
6219 session->smeSessionId, session->he_capable,
6220 session->is_session_obss_color_collision_det_enabled,
6221 mac_ctx->lim.global_obss_color_collision_det_offload);
6222 return;
6223 }
6224
6225 cfg_param = qdf_mem_malloc(sizeof(*cfg_param));
6226 if (!cfg_param) {
6227 pe_err("Failed to allocate memory");
6228 return;
6229 }
6230
6231 pe_debug("%d: sending event:%d", session->smeSessionId, event_type);
6232 qdf_mem_zero(cfg_param, sizeof(*cfg_param));
6233 cfg_param->vdev_id = session->smeSessionId;
6234 cfg_param->evt_type = event_type;
6235 if (LIM_IS_AP_ROLE(session))
6236 cfg_param->detection_period_ms =
6237 OBSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS;
6238 else
6239 cfg_param->detection_period_ms =
6240 OBSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS;
6241
6242 cfg_param->scan_period_ms = OBSS_COLOR_COLLISION_SCAN_PERIOD_MS;
6243 if (event_type == OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6244 cfg_param->free_slot_expiry_time_ms =
6245 OBSS_COLOR_COLLISION_FREE_SLOT_EXPIRY_MS;
6246
6247 msg.type = WMA_OBSS_COLOR_COLLISION_REQ;
6248 msg.bodyptr = cfg_param;
6249 msg.reserved = 0;
6250
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05306251 if (QDF_IS_STATUS_ERROR(scheduler_post_message(QDF_MODULE_ID_PE,
6252 QDF_MODULE_ID_WMA,
6253 QDF_MODULE_ID_WMA,
6254 &msg))) {
Arif Hussain05fb4872018-01-03 16:02:55 -08006255 pe_err("Failed to post WMA_OBSS_COLOR_COLLISION_REQ to WMA");
6256 qdf_mem_free(cfg_param);
6257 } else {
6258 session->obss_color_collision_dec_evt = event_type;
6259 }
6260}
6261
6262void lim_process_obss_color_collision_info(tpAniSirGlobal mac_ctx,
6263 uint32_t *msg_buf)
6264{
6265 struct wmi_obss_color_collision_info *obss_color_info;
6266 tpPESession session;
6267
6268 if (!msg_buf) {
6269 pe_err("Buffer is Pointing to NULL");
6270 return;
6271 }
6272
6273 obss_color_info = (struct wmi_obss_color_collision_info *)msg_buf;
6274 session = pe_find_session_by_sme_session_id(mac_ctx,
6275 obss_color_info->vdev_id);
6276 if (!session) {
6277 pe_err("Session not found for given session_id %d",
6278 obss_color_info->vdev_id);
6279 return;
6280 }
6281
6282 pe_debug("vdev_id:%d, evt:%d:%d, 0to31:0x%x, 32to63:0x%x, cap:%d:%d:%d",
6283 obss_color_info->vdev_id,
6284 obss_color_info->evt_type,
6285 session->obss_color_collision_dec_evt,
6286 obss_color_info->obss_color_bitmap_bit0to31,
6287 obss_color_info->obss_color_bitmap_bit32to63,
6288 session->he_capable,
6289 session->is_session_obss_color_collision_det_enabled,
6290 mac_ctx->lim.global_obss_color_collision_det_offload);
6291
6292 if (!session->he_capable ||
6293 !session->is_session_obss_color_collision_det_enabled) {
6294 return;
6295 }
6296
6297 switch (obss_color_info->evt_type) {
6298 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
6299 pe_err("%d: FW disabled obss color det. he_cap:%d, sup:%d:%d",
6300 session->smeSessionId, session->he_capable,
6301 session->is_session_obss_color_collision_det_enabled,
6302 mac_ctx->lim.global_obss_color_collision_det_offload);
6303 session->is_session_obss_color_collision_det_enabled = false;
6304 return;
6305 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
6306 case OBSS_COLOR_COLLISION_DETECTION:
6307 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
6308 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6309 pe_debug("Invalid System Role %d",
6310 GET_LIM_SYSTEM_ROLE(session));
6311 return;
6312 }
6313
6314 if (session->obss_color_collision_dec_evt !=
6315 obss_color_info->evt_type) {
6316 pe_debug("%d: Wrong event: %d, skiping",
6317 obss_color_info->vdev_id,
6318 obss_color_info->evt_type);
6319 return;
6320 }
6321 obss_color_collision_process_color_change(mac_ctx, session,
6322 obss_color_info);
6323 break;
6324 default:
6325 pe_err("%d: Invalid event type %d",
6326 obss_color_info->vdev_id, obss_color_info->evt_type);
6327 return;
6328 }
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006329}
6330#endif
Abhishek Singh20a8e442018-09-12 15:50:44 +05306331
6332#ifdef CONFIG_VDEV_SM
6333void lim_send_csa_restart_req(tpAniSirGlobal mac_ctx, uint8_t vdev_id)
6334{
6335 tpPESession session;
6336
6337 session = pe_find_session_by_sme_session_id(mac_ctx, vdev_id);
6338
6339 if (!session) {
6340 pe_err("session not found for vdev id %d", vdev_id);
6341 return;
6342 }
6343
6344 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
6345 WLAN_VDEV_SM_EV_CSA_RESTART,
6346 sizeof(*session), session);
6347}
6348#endif