blob: f3e86207f3f0431fc2927d0a415fa4eae5ceaa1a [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Jingxiang Ge4168a232018-01-03 18:47:15 +08002 * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
19/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020 * This file lim_process_sme_req_messages.cc contains the code
21 * for processing SME request messages.
22 * Author: Chandra Modumudi
23 * Date: 02/11/02
24 * History:-
25 * Date Modified by Modification Information
26 * --------------------------------------------------------------------
27 *
28 */
29
30#include "cds_api.h"
31#include "wni_api.h"
32#include "wni_cfg.h"
33#include "cfg_api.h"
34#include "sir_api.h"
35#include "sch_api.h"
36#include "utils_api.h"
37#include "lim_types.h"
38#include "lim_utils.h"
39#include "lim_assoc_utils.h"
40#include "lim_security_utils.h"
41#include "lim_ser_des_utils.h"
42#include "lim_sme_req_utils.h"
43#include "lim_ibss_peer_mgmt.h"
44#include "lim_admit_control.h"
45#include "dph_hash_table.h"
46#include "lim_send_messages.h"
47#include "lim_api.h"
48#include "wmm_apsd.h"
49#include "sir_mac_prot_def.h"
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -080050#include "rrm_api.h"
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070051#include "nan_datapath.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080052#include "sap_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080053#include <lim_ft.h>
Naveen Rawat3b6068c2016-04-14 19:01:06 -070054#include "cds_regdomain.h"
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053055#include "lim_process_fils.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070056#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080057
58/*
59 * This overhead is time for sending NOA start to host in case of GO/sending
60 * NULL data & receiving ACK in case of P2P Client and starting actual scanning
61 * with init scan req/rsp plus in case of concurrency, taking care of sending
62 * null data and receiving ACK to/from AP/Also SetChannel with calibration
63 * is taking around 7ms .
64 */
65#define SCAN_MESSAGING_OVERHEAD 20 /* in msecs */
66#define JOIN_NOA_DURATION 2000 /* in msecs */
67#define OEM_DATA_NOA_DURATION 60 /* in msecs */
68#define DEFAULT_PASSIVE_MAX_CHANNEL_TIME 110 /* in msecs */
69
70#define CONV_MS_TO_US 1024 /* conversion factor from ms to us */
71
Paul Zhangd2315472017-02-22 10:02:50 +080072#define BEACON_INTERVAL_THRESHOLD 50 /* in msecs */
73#define STA_BURST_SCAN_DURATION 120 /* in msecs */
74
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080075/* SME REQ processing function templates */
76static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080077static bool __lim_process_sme_start_bss_req(tpAniSirGlobal,
78 struct scheduler_msg *pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080079static void __lim_process_sme_join_req(tpAniSirGlobal, uint32_t *);
80static void __lim_process_sme_reassoc_req(tpAniSirGlobal, uint32_t *);
81static void __lim_process_sme_disassoc_req(tpAniSirGlobal, uint32_t *);
82static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal, uint32_t *);
83static void __lim_process_sme_deauth_req(tpAniSirGlobal, uint32_t *);
84static void __lim_process_sme_set_context_req(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080085static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal,
86 struct scheduler_msg *pMsg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053087static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
88 uint32_t *msg_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080089static void lim_process_sme_channel_change_request(tpAniSirGlobal pMac,
90 uint32_t *pMsg);
91static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg);
92static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal pMac, uint32_t *pMsg);
93static void lim_process_nss_update_request(tpAniSirGlobal pMac, uint32_t *pMsg);
94static void lim_process_set_ie_req(tpAniSirGlobal pMac, uint32_t *pMsg);
95
96static void lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
97 uint8_t **pDstData_buff,
98 uint16_t *pDstDataLen,
99 uint8_t *pSrcData_buff,
100 uint16_t srcDataLen);
101
102static void lim_update_add_ie_buffer(tpAniSirGlobal pMac,
103 uint8_t **pDstData_buff,
104 uint16_t *pDstDataLen,
105 uint8_t *pSrcData_buff, uint16_t srcDataLen);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800106static bool lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac,
107 uint8_t **pDstData_buff,
108 uint16_t *pDstDataLen,
109 tSirModifyIE *pModifyIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800110static void lim_process_modify_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
111
112static void lim_process_update_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
113
Abhishek Singh518323d2015-10-19 17:42:01 +0530114static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
115 uint32_t *msg);
116
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800117/**
118 * lim_process_set_hw_mode() - Send set HW mode command to WMA
119 * @mac: Globacl MAC pointer
120 * @msg: Message containing the hw mode index
121 *
122 * Send the set HW mode command to WMA
123 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530124 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800125 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530126static QDF_STATUS lim_process_set_hw_mode(tpAniSirGlobal mac, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800127{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530128 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700129 struct scheduler_msg message = {0};
Tushnim Bhattacharyya66348bd2017-03-09 15:02:10 -0800130 struct policy_mgr_hw_mode *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800131 uint32_t len;
132 struct s_sir_set_hw_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700133 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800134 struct sir_set_hw_mode_resp *param;
135
136 buf = (struct s_sir_set_hw_mode *) msg;
137 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700138 pe_err("Set HW mode param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800139 /* To free the active command list */
140 goto fail;
141 }
142
143 len = sizeof(*req_msg);
144
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530145 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800146 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700147 pe_err("qdf_mem_malloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800148 /* Free the active command list
149 * Probably the malloc is going to fail there as well?!
150 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530151 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152 }
153
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800154 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530155 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800156 /* Other parameters are not needed for WMA */
157
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800158 message.bodyptr = req_msg;
159 message.type = SIR_HAL_PDEV_SET_HW_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800160
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700161 pe_debug("Posting SIR_HAL_SOC_SET_HW_MOD to WMA");
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530162 status = scheduler_post_message(QDF_MODULE_ID_PE,
163 QDF_MODULE_ID_WMA,
164 QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530165 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700166 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800167 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530168 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800169 goto fail;
170 }
171 return status;
172fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530173 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800174 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700175 pe_err("HW mode resp failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530176 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800177 }
178 param->status = SET_HW_MODE_STATUS_ECANCELED;
179 param->cfgd_hw_mode_index = 0;
180 param->num_vdev_mac_entries = 0;
181 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
182 resp_msg.bodyptr = param;
183 resp_msg.bodyval = 0;
184 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530185 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800186}
187
188/**
189 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
190 * @mac: Global MAC pointer
191 * @msg: Message containing the dual mac config parameter
192 *
193 * Send the set dual mac config command to WMA
194 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530195 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800196 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530197static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800198 uint32_t *msg)
199{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530200 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700201 struct scheduler_msg message = {0};
Srinivas Girigowdaeb6ecf32018-02-15 17:04:22 -0800202 struct policy_mgr_dual_mac_config *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203 uint32_t len;
204 struct sir_set_dual_mac_cfg *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700205 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800206 struct sir_dual_mac_config_resp *param;
207
208 buf = (struct sir_set_dual_mac_cfg *) msg;
209 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700210 pe_err("Set Dual mac config is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800211 /* To free the active command list */
212 goto fail;
213 }
214
215 len = sizeof(*req_msg);
216
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530217 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800218 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700219 pe_err("qdf_mem_malloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800220 /* Free the active command list
221 * Probably the malloc is going to fail there as well?!
222 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530223 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800224 }
225
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800226 req_msg->scan_config = buf->set_dual_mac.scan_config;
227 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
228 /* Other parameters are not needed for WMA */
229
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800230 message.bodyptr = req_msg;
231 message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800232
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700233 pe_debug("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800234 req_msg->scan_config, req_msg->fw_mode_config);
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530235 status = scheduler_post_message(QDF_MODULE_ID_PE,
236 QDF_MODULE_ID_WMA,
237 QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530238 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700239 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800240 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530241 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800242 goto fail;
243 }
244 return status;
245fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530246 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800247 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700248 pe_err("Dual mac config resp failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530249 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800250 }
251 param->status = SET_HW_MODE_STATUS_ECANCELED;
252 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
253 resp_msg.bodyptr = param;
254 resp_msg.bodyval = 0;
255 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530256 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800257}
258
259/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800260 * lim_process_set_antenna_mode_req() - Set antenna mode command
261 * to WMA
262 * @mac: Global MAC pointer
263 * @msg: Message containing the antenna mode parameter
264 *
265 * Send the set antenna mode command to WMA
266 *
267 * Return: QDF_STATUS_SUCCESS if message posting is successful
268 */
269static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
270 uint32_t *msg)
271{
272 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700273 struct scheduler_msg message = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800274 struct sir_antenna_mode_param *req_msg;
275 struct sir_set_antenna_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700276 struct scheduler_msg resp_msg = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800277 struct sir_antenna_mode_resp *param;
278
279 buf = (struct sir_set_antenna_mode *) msg;
280 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700281 pe_err("Set antenna mode is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800282 /* To free the active command list */
283 goto fail;
284 }
285
286 req_msg = qdf_mem_malloc(sizeof(*req_msg));
287 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700288 pe_err("qdf_mem_malloc failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800289 return QDF_STATUS_E_NOMEM;
290 }
291
292 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
293 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
294
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800295 message.bodyptr = req_msg;
296 message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800297
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700298 pe_debug("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800299 req_msg->num_rx_chains,
300 req_msg->num_tx_chains);
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530301 status = scheduler_post_message(QDF_MODULE_ID_PE,
302 QDF_MODULE_ID_WMA,
303 QDF_MODULE_ID_WMA, &message);
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800304 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700305 pe_err("scheduler_post_msg failed!(err=%d)",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800306 status);
307 qdf_mem_free(req_msg);
308 goto fail;
309 }
310 return status;
311fail:
312 param = qdf_mem_malloc(sizeof(*param));
313 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700314 pe_err("antenna mode resp failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800315 return QDF_STATUS_E_NOMEM;
316 }
317 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
318 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
319 resp_msg.bodyptr = param;
320 resp_msg.bodyval = 0;
321 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
322 return QDF_STATUS_SUCCESS;
323}
324
325/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800326 * __lim_is_sme_assoc_cnf_valid()
327 *
328 ***FUNCTION:
329 * This function is called by __lim_process_sme_assoc_cnf_new() upon
330 * receiving SME_ASSOC_CNF.
331 *
332 ***LOGIC:
333 * Message validity checks are performed in this function
334 *
335 ***ASSUMPTIONS:
336 *
337 ***NOTE:
338 *
339 * @param pMeasReq Pointer to Received ASSOC_CNF message
340 * @return true When received SME_ASSOC_CNF is formatted
341 * correctly
342 * false otherwise
343 */
344
345static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
346{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530347 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800348 return false;
349 else
350 return true;
351} /*** end __lim_is_sme_assoc_cnf_valid() ***/
352
353/**
354 * __lim_get_sme_join_req_size_for_alloc()
355 *
356 ***FUNCTION:
357 * This function is called in various places to get IE length
358 * from tSirBssDescription structure
359 * number being scanned.
360 *
361 ***PARAMS:
362 *
363 ***LOGIC:
364 *
365 ***ASSUMPTIONS:
366 * NA
367 *
368 ***NOTE:
369 * NA
370 *
371 * @param pBssDescr
372 * @return Total IE length
373 */
374
375static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
376{
377 uint16_t len = 0;
378
379 if (!pBuf)
380 return len;
381
382 pBuf += sizeof(uint16_t);
383 len = lim_get_u16(pBuf);
Arif Hussainc9651922017-04-16 14:08:23 -0700384 return len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800385}
386
387/**
388 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
389 * @pMac: Global MAC context
390 * @pMsg: Pointer to message posted from SME to LIM.
391 *
392 * Has role only if 11h is enabled. Not used on STA side.
393 * Defers the message if SME is in learn state and brings
394 * the LIM back to normal mode.
395 *
396 * Return: true - If defered false - Otherwise
397 */
398
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800399static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac,
400 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800401{
402 if (lim_is_system_in_scan_state(pMac)) {
403 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700404 pe_err("Could not defer Msg: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800405 return false;
406 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700407 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800408 pMsg->type);
409 return true;
410 }
411 return false;
412}
413
414/**
415 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
416 * @mac_ctx: Pointer to Global MAC structure
417 * @message: Pointer to message posted from SME to LIM.
418 *
419 * Has role only if 11h is enabled. Not used on STA side.
420 * Defers the message if radar is detected.
421 *
422 * Return: true, if defered otherwise return false.
423 */
424static bool
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800425__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx,
426 struct scheduler_msg *message)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427{
428 /*
429 * fRadarDetCurOperChan will be set only if we
430 * detect radar in current operating channel and
431 * System Role == AP ROLE
432 *
433 * TODO: Need to take care radar detection.
434 *
435 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
436 */
437 if (0) {
438 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700439 pe_err("Could not defer Msg: %d", message->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800440 return false;
441 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700442 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800443 message->type);
444 return true;
445 }
446 return false;
447}
448
449/**
450 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
451 * @pMac: Global MAC context
452 * @pMsgBuf: Message from WMA
453 *
454 * handles the notification from HDD. PE just forwards this message to HAL.
455 *
456 * Return: true-Posting to HAL failed, so PE will consume the buffer.
457 * false-Posting to HAL successful, so HAL will consume the buffer.
458 */
459
460static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
461{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700462 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800463 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
464
465 msg.type = WMA_SYS_READY_IND;
466 msg.reserved = 0;
467 msg.bodyptr = pMsgBuf;
468 msg.bodyval = 0;
469
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700470 if (ANI_DRIVER_TYPE(pMac) != QDF_DRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800471 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +0530472 pe_register_mgmt_rx_frm_callback(pMac);
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700473 pe_register_callbacks_with_wma(pMac, ready_req);
Sandeep Puligilla1426d612017-04-12 18:22:06 -0700474 pMac->lim.sme_msg_callback = ready_req->sme_msg_cb;
Vignesh Viswanathan3d478032018-08-02 20:18:53 +0530475 pMac->lim.stop_roaming_callback = ready_req->stop_roaming_cb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800476 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700477
478 pe_debug("sending WMA_SYS_READY_IND msg to HAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800479 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
480
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700481 if (QDF_STATUS_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700482 pe_err("wma_post_ctrl_msg failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800483 return true;
484 }
485 return false;
486}
487
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800488/**
489 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
490 *@mac_ctx: Pointer to Global MAC structure
491 *@session: A pointer to session entry
492 *@sme_start_bss_req: Start BSS Request from upper layers.
493 *
494 * This function is used to configure the start bss parameters
495 * in to the session.
496 *
497 * Return: None.
498 */
499static void
500lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
501 tpSirSmeStartBssReq sme_start_bss_req)
502{
503 session->limSystemRole = eLIM_AP_ROLE;
504 session->privacy = sme_start_bss_req->privacy;
505 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
506 session->authType = sme_start_bss_req->authType;
507 /* Store the DTIM period */
508 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
509 /* Enable/disable UAPSD */
510 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530511 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800512 session->proxyProbeRspEn = 0;
513 } else {
514 /*
515 * To detect PBC overlap in SAP WPS mode,
516 * Host handles Probe Requests.
517 */
518 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
519 session->proxyProbeRspEn = 1;
520 else
521 session->proxyProbeRspEn = 0;
522 }
523 session->ssidHidden = sme_start_bss_req->ssidHidden;
524 session->wps_state = sme_start_bss_req->wps_state;
525 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530526 session->vendor_vht_sap =
527 sme_start_bss_req->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800528 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
529 &session->shortSlotTimeSupported);
530 session->isCoalesingInIBSSAllowed =
531 sme_start_bss_req->isCoalesingInIBSSAllowed;
532
Jiachao Wu712d4fd2017-08-23 16:52:34 +0800533 session->beacon_tx_rate = sme_start_bss_req->beacon_tx_rate;
534
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800535}
536
537/**
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530538 * lim_send_start_vdev_req() - send vdev start request
539 *@session: pe session
540 *@mlm_start_req: vdev start req
541 *
542 * Return: QDF_STATUS
543 */
Abhishek Singh3d30a3b2018-09-12 15:49:18 +0530544#ifdef CONFIG_VDEV_SM
545static QDF_STATUS
546lim_send_start_vdev_req(tpPESession session, tLimMlmStartReq *mlm_start_req)
547{
548 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
549 WLAN_VDEV_SM_EV_START,
550 sizeof(*mlm_start_req),
551 mlm_start_req);
552}
553#else
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530554static QDF_STATUS
555lim_send_start_vdev_req(tpPESession session, tLimMlmStartReq *mlm_start_req)
556{
557 lim_process_mlm_start_req(session->mac_ctx, mlm_start_req);
558
559 return QDF_STATUS_SUCCESS;
560}
Abhishek Singh3d30a3b2018-09-12 15:49:18 +0530561#endif
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530562
563/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800564 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
565 *@mac_ctx: Pointer to Global MAC structure
566 *@msg_buf: A pointer to the SME message buffer
567 *
568 * This function is called to process SME_START_BSS_REQ message
569 * from HDD or upper layer application.
570 *
571 * Return: None
572 */
573static void
574__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
575{
576 uint16_t size;
577 uint32_t val = 0;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700578 QDF_STATUS ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800579 tSirMacChanNum channel_number;
580 tLimMlmStartReq *mlm_start_req = NULL;
581 tpSirSmeStartBssReq sme_start_bss_req = NULL;
582 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
583 /* Flag Used in case of IBSS to Auto generate BSSID. */
584 uint32_t auto_gen_bssid = false;
585 uint8_t session_id;
586 tpPESession session = NULL;
Krunal Sonib37bb352016-12-20 14:12:21 -0800587 uint8_t sme_session_id = 0xFF;
588 uint16_t sme_transaction_id = 0xFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800589 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700590 struct vdev_type_nss *vdev_type_nss;
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530591 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
gaurank kathpaliad88ef882018-08-14 15:20:11 +0530592 struct policy_mgr_hw_mode_params hw_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800593
594/* FEATURE_WLAN_DIAG_SUPPORT */
595#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
596 /*
597 * Since the session is not created yet, sending NULL.
598 * The response should have the correct state.
599 */
600 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
601 NULL, 0, 0);
602#endif /* FEATURE_WLAN_DIAG_SUPPORT */
603
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700604 pe_debug("Received START_BSS_REQ");
Krunal Sonib37bb352016-12-20 14:12:21 -0800605 size = sizeof(tSirSmeStartBssReq);
606 sme_start_bss_req = qdf_mem_malloc(size);
607 if (NULL == sme_start_bss_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700608 pe_err("Allocate Memory fail for LimStartBssReq");
Krunal Sonib37bb352016-12-20 14:12:21 -0800609 /* Send failure response to host */
610 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
611 goto free;
612 }
613 qdf_mem_copy(sme_start_bss_req, msg_buf, sizeof(tSirSmeStartBssReq));
614 sme_session_id = sme_start_bss_req->sessionId;
615 sme_transaction_id = sme_start_bss_req->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800616
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800617 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
618 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800619 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
620 sme_start_bss_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700621 pe_warn("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800622 ret_code = eSIR_SME_INVALID_PARAMETERS;
623 goto free;
624 }
625
626 /*
627 * This is the place where PE is going to create a session.
628 * If session is not existed, then create a new session
629 */
630 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800631 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800632 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700633 pe_warn("Session Already exists for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800634 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
635 session = NULL;
636 goto free;
637 } else {
638 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800639 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800640 &session_id, mac_ctx->lim.maxStation,
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +0530641 sme_start_bss_req->bssType,
642 sme_start_bss_req->sessionId);
643 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700644 pe_warn("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800645 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
646 goto free;
647 }
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +0530648
649 /* Update the beacon/probe filter in mac_ctx */
650 lim_set_bcn_probe_filter(mac_ctx, session,
651 &sme_start_bss_req->ssId,
652 sme_start_bss_req->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800653 }
654
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700655 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
656 /* Probe resp add ie */
657 lim_start_bss_update_add_ie_buffer(mac_ctx,
658 &session->addIeParams.probeRespData_buff,
659 &session->addIeParams.probeRespDataLen,
660 sme_start_bss_req->addIeParams.
661 probeRespData_buff,
662 sme_start_bss_req->addIeParams.
663 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800664
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700665 /* Probe Beacon add ie */
666 lim_start_bss_update_add_ie_buffer(mac_ctx,
667 &session->addIeParams.probeRespBCNData_buff,
668 &session->addIeParams.probeRespBCNDataLen,
669 sme_start_bss_req->addIeParams.
670 probeRespBCNData_buff,
671 sme_start_bss_req->addIeParams.
672 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800673
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700674 /* Assoc resp IE */
675 lim_start_bss_update_add_ie_buffer(mac_ctx,
676 &session->addIeParams.assocRespData_buff,
677 &session->addIeParams.assocRespDataLen,
678 sme_start_bss_req->addIeParams.
679 assocRespData_buff,
680 sme_start_bss_req->addIeParams.
681 assocRespDataLen);
682 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800683 /* Store the session related params in newly created session */
684 session->pLimStartBssReq = sme_start_bss_req;
685
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800686 session->transactionId = sme_start_bss_req->transactionId;
687
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530688 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800689 &(sme_start_bss_req->htConfig),
690 sizeof(session->htConfig));
691
Sandeep Puligilla98917432016-06-10 13:50:28 -0700692 qdf_mem_copy(&(session->vht_config),
693 &(sme_start_bss_req->vht_config),
694 sizeof(session->vht_config));
695
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800696 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800697 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800698
699 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530700 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800701 (uint8_t *) &sme_start_bss_req->ssId,
702 (sme_start_bss_req->ssId.length + 1));
703
704 session->bssType = sme_start_bss_req->bssType;
705
706 session->nwType = sme_start_bss_req->nwType;
707
708 session->beaconParams.beaconInterval =
709 sme_start_bss_req->beaconInterval;
710
711 /* Store the channel number in session Table */
712 session->currentOperChannel =
713 sme_start_bss_req->channelId;
714
715 /* Store Persona */
716 session->pePersona = sme_start_bss_req->bssPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +0530717 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800718 FL("PE PERSONA=%d"), session->pePersona);
719
720 /* Update the phymode */
721 session->gLimPhyMode = sme_start_bss_req->nwType;
722
723 session->maxTxPower =
724 cfg_get_regulatory_max_transmit_power(mac_ctx,
725 session->currentOperChannel);
726 /* Store the dot 11 mode in to the session Table */
727 session->dot11mode = sme_start_bss_req->dot11mode;
728#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
729 session->cc_switch_mode =
730 sme_start_bss_req->cc_switch_mode;
731#endif
732 session->htCapability =
733 IS_DOT11_MODE_HT(session->dot11mode);
734 session->vhtCapability =
735 IS_DOT11_MODE_VHT(session->dot11mode);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800736
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700737 pe_debug("HT[%d], VHT[%d]",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800738 session->htCapability, session->vhtCapability);
739
740 if (IS_DOT11_MODE_HE(session->dot11mode)) {
741 lim_update_session_he_capable(mac_ctx, session);
742 lim_copy_bss_he_cap(session, sme_start_bss_req);
743 }
744
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800745 session->txLdpcIniFeatureEnabled =
746 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800747#ifdef WLAN_FEATURE_11W
748 session->limRmfEnabled =
749 sme_start_bss_req->pmfCapable ? 1 : 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700750 pe_debug("Session RMF enabled: %d", session->limRmfEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800751#endif
752
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530753 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800754 (void *)&sme_start_bss_req->operationalRateSet,
755 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530756 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800757 (void *)&sme_start_bss_req->extendedRateSet,
758 sizeof(tSirMacRateSet));
759
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700760 if (IS_5G_CH(session->currentOperChannel))
761 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
762 else
763 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
764
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800765 switch (sme_start_bss_req->bssType) {
766 case eSIR_INFRA_AP_MODE:
767 lim_configure_ap_start_bss_session(mac_ctx, session,
768 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700769 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700770 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700771 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700772 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800773 break;
774 case eSIR_IBSS_MODE:
775 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
776 lim_get_short_slot_from_phy_mode(mac_ctx, session,
777 session->gLimPhyMode,
778 &session->shortSlotTimeSupported);
779
780 /*
781 * initialize to "OPEN".
782 * will be updated upon key installation
783 */
784 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700785 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800786
787 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700788 case eSIR_NDI_MODE:
789 session->limSystemRole = eLIM_NDI_ROLE;
790 break;
791
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800792
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800793 /*
794 * There is one more mode called auto mode.
795 * which is used no where
796 */
797
798 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
799
800 default:
801 /* not used anywhere...used in scan function */
802 break;
803 }
804
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700805 pe_debug("persona - %d, nss - %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700806 session->pePersona, session->vdev_nss);
807 session->nss = session->vdev_nss;
Kiran Kumar Lokerebc6fb2f2018-05-09 19:04:11 -0700808 if (!mac_ctx->roam.configParam.enable2x2)
809 session->nss = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800810 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700811 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800812 * parsed (Re)Assoc request structure
813 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700814 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530816 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700817 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800818 if (NULL == session->parsedAssocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700819 pe_warn("AllocateMemory() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800820 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
821 goto free;
822 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800823 }
824
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700825 if (!sme_start_bss_req->channelId &&
826 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700827 pe_err("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800828 ret_code = eSIR_SME_INVALID_PARAMETERS;
829 goto free;
830 }
831 channel_number = sme_start_bss_req->channelId;
832#ifdef QCA_HT_2040_COEX
833 if (sme_start_bss_req->obssEnabled)
834 session->htSupportedChannelWidthSet =
835 session->htCapability;
836 else
837#endif
838 session->htSupportedChannelWidthSet =
839 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
840 session->htSecondaryChannelOffset =
841 sme_start_bss_req->sec_ch_offset;
842 session->htRecommendedTxWidthSet =
843 (session->htSecondaryChannelOffset) ? 1 : 0;
Abhishek Singh4294f802017-08-10 16:37:07 +0530844 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800845 FL("cbMode %u"), sme_start_bss_req->cbMode);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800846 if (lim_is_session_he_capable(session) ||
847 session->vhtCapability || session->htCapability) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848 chanwidth = sme_start_bss_req->vht_channel_width;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700849 pe_debug("vht_channel_width %u htSupportedChannelWidthSet %d",
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800850 sme_start_bss_req->vht_channel_width,
851 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800852 session->ch_width = chanwidth;
853 if (session->htSupportedChannelWidthSet) {
854 session->ch_center_freq_seg0 =
855 sme_start_bss_req->center_freq_seg0;
856 session->ch_center_freq_seg1 =
857 sme_start_bss_req->center_freq_seg1;
858 } else {
859 session->ch_center_freq_seg0 = 0;
860 session->ch_center_freq_seg1 = 0;
861 }
862 }
gaurank kathpaliad88ef882018-08-14 15:20:11 +0530863 if (policy_mgr_is_hw_dbs_capable(mac_ctx->psoc) &&
864 (policy_mgr_get_current_hw_mode(mac_ctx->psoc, &hw_mode) ==
865 QDF_STATUS_SUCCESS) &&
866 hw_mode.dbs_cap) {
867 session->nss = 1;
868 pe_debug("HW is in DBS mode. Nss set to [%d]",
869 session->nss);
870 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800871 if (session->vhtCapability &&
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800872 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873 session->nss = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700874 pe_debug("nss set to [%d]", session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800875 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700876 pe_debug("vht su tx bformer %d",
Krunal Soni53993f72016-07-08 18:20:03 -0700877 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800878
879 /* Delete pre-auth list if any */
880 lim_delete_pre_auth_list(mac_ctx);
881
882 /*
883 * keep the RSN/WPA IE information in PE Session Entry
884 * later will be using this to check when received (Re)Assoc req
885 */
886 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
887 &sme_start_bss_req->rsnIE, session);
888
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700889 if (LIM_IS_AP_ROLE(session) ||
890 LIM_IS_IBSS_ROLE(session) ||
891 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800892 session->gLimProtectionControl =
893 sme_start_bss_req->protEnabled;
894 /*
895 * each byte will have the following info
896 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
897 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
898 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530899 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800900 (void *)&sme_start_bss_req->ht_capab,
901 sizeof(uint16_t));
902 /* Initialize WPS PBC session link list */
903 session->pAPWPSPBCSession = NULL;
904 }
905 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530906 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800907 if (NULL == mlm_start_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700908 pe_err("Allocate Memory failed for mlmStartReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800909 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
910 goto free;
911 }
912
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800913 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530914 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800915 (uint8_t *) &sme_start_bss_req->ssId,
916 sme_start_bss_req->ssId.length + 1);
917 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
918 mlm_start_req->obssProtEnabled =
919 sme_start_bss_req->obssProtEnabled;
920
921 mlm_start_req->bssType = session->bssType;
922
923 /* Fill PE session Id from the session Table */
924 mlm_start_req->sessionId = session->peSessionId;
925
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700926 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
927 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800928 /*
929 * Copy the BSSId from sessionTable to
930 * mlmStartReq struct
931 */
932 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
933 } else {
934 /* ibss mode */
935 mac_ctx->lim.gLimIbssCoalescingHappened = false;
936
937 ret_status = wlan_cfg_get_int(mac_ctx,
938 WNI_CFG_IBSS_AUTO_BSSID,
939 &auto_gen_bssid);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700940 if (ret_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700941 pe_err("Get Auto Gen BSSID fail,Status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800942 ret_status);
Abhishek Singh4294f802017-08-10 16:37:07 +0530943 ret_code = eSIR_LOGE_EXCEPTION;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800944 goto free;
945 }
946
947 if (!auto_gen_bssid) {
948 /*
949 * We're not auto generating BSSID.
950 * Instead, get it from session entry
951 */
952 sir_copy_mac_addr(mlm_start_req->bssId,
953 session->bssId);
954 /*
955 * Start IBSS group BSSID
956 * Auto Generating BSSID.
957 */
958 auto_gen_bssid = ((mlm_start_req->bssId[0] &
959 0x01) ? true : false);
960 }
961
962 if (auto_gen_bssid) {
963 /*
964 * if BSSID is not any uc id.
965 * then use locally generated BSSID.
966 * Autogenerate the BSSID
967 */
968 lim_get_random_bssid(mac_ctx,
969 mlm_start_req->bssId);
970 mlm_start_req->bssId[0] = 0x02;
971
972 /*
973 * Copy randomly generated BSSID
974 * to the session Table
975 */
976 sir_copy_mac_addr(session->bssId,
977 mlm_start_req->bssId);
978 }
979 }
980 /* store the channel num in mlmstart req structure */
981 mlm_start_req->channelNumber = session->currentOperChannel;
982 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
983 mlm_start_req->beaconPeriod =
984 session->beaconParams.beaconInterval;
Arif Hussain671a1902017-03-17 09:08:32 -0700985 mlm_start_req->cac_duration_ms =
986 sme_start_bss_req->cac_duration_ms;
987 mlm_start_req->dfs_regdomain =
988 sme_start_bss_req->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800989 if (LIM_IS_AP_ROLE(session)) {
990 mlm_start_req->dtimPeriod = session->dtimPeriod;
991 mlm_start_req->wps_state = session->wps_state;
992
993 } else {
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530994 val = mac_ctx->mlme_cfg->sap_cfg.dtim_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995 mlm_start_req->dtimPeriod = (uint8_t) val;
996 }
997
Karthik Kantamneni22dd0f62018-08-07 14:53:50 +0530998 mlm_start_req->cfParamSet.cfpPeriod =
999 mac_ctx->mlme_cfg->rates.cfp_period;
1000 mlm_start_req->cfParamSet.cfpMaxDuration =
1001 mac_ctx->mlme_cfg->rates.cfp_max_duration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001002
1003 /*
1004 * this may not be needed anymore now,
1005 * as rateSet is now included in the
1006 * session entry and MLM has session context.
1007 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301008 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001009 (void *)&session->rateSet,
1010 sizeof(tSirMacRateSet));
1011
1012 /* Now populate the 11n related parameters */
1013 mlm_start_req->nwType = session->nwType;
1014 mlm_start_req->htCapable = session->htCapability;
1015
1016 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1017 /* Unused */
1018 mlm_start_req->dualCTSProtection =
1019 mac_ctx->lim.gHTDualCTSProtection;
1020 mlm_start_req->txChannelWidthSet =
1021 session->htRecommendedTxWidthSet;
1022
1023 session->limRFBand = lim_get_rf_band(channel_number);
1024
1025 /* Initialize 11h Enable Flag */
1026 session->lim11hEnable = 0;
gaolez76d2a162017-03-21 19:23:58 +08001027 if (mlm_start_req->bssType != eSIR_IBSS_MODE &&
1028 (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001029 BAND_5G == session->limRFBand)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001030 if (wlan_cfg_get_int(mac_ctx,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001031 WNI_CFG_11H_ENABLED, &val) != QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001032 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001033 else
1034 session->lim11hEnable = val;
1035
1036 if (session->lim11hEnable &&
1037 (eSIR_INFRA_AP_MODE ==
1038 mlm_start_req->bssType)) {
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;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001068 return;
1069 } else {
1070
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001071 pe_err("Received unexpected START_BSS_REQ, in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001072 mac_ctx->lim.gLimSmeState);
1073 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001074 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001075 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1076
1077free:
1078 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001079 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001080 session->pLimStartBssReq = NULL;
1081 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001082 if (NULL != sme_start_bss_req)
1083 qdf_mem_free(sme_start_bss_req);
1084 if (NULL != mlm_start_req)
1085 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001086 if (NULL != session) {
1087 pe_delete_session(mac_ctx, session);
1088 session = NULL;
1089 }
1090 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1091 session, sme_session_id, sme_transaction_id);
1092}
1093
1094/**
1095 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1096 *
1097 * @pMac: Global MAC context
1098 * @pMsg: Message pointer
1099 *
1100 * Wrapper for the function __lim_handle_sme_start_bss_request
1101 * This message will be defered until softmac come out of
1102 * scan mode or if we have detected radar on the current
1103 * operating channel.
1104 *
1105 * return true - If we consumed the buffer
1106 * false - If have defered the message.
1107 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001108static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1109 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001110{
1111 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1112 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1113 /**
1114 * If message defered, buffer is not consumed yet.
1115 * So return false
1116 */
1117 return false;
1118 }
1119
1120 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1121 return true;
1122}
1123
1124/**
1125 * lim_get_random_bssid()
1126 *
1127 * FUNCTION:This function is called to process generate the random number for bssid
1128 * This function is called to process SME_SCAN_REQ message
1129 * from HDD or upper layer application.
1130 *
1131 * LOGIC:
1132 *
1133 * ASSUMPTIONS:
1134 *
1135 * NOTE:
1136 * 1. geneartes the unique random number for bssid in ibss
1137 *
1138 * @param pMac Pointer to Global MAC structure
1139 * @param *data Pointer to bssid buffer
1140 * @return None
1141 */
1142void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1143{
1144 uint32_t random[2];
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001145
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001146 random[0] = tx_time_get();
1147 random[0] |= (random[0] << 15);
1148 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301149 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001150}
1151
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001152/**
1153 * __lim_process_clear_dfs_channel_list()
1154 *
1155 ***FUNCTION:
Jeff Johnsonc00ae5b2018-05-06 16:06:35 -07001156 ***Clear DFS channel list when country is changed/acquired.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001157 .*This message is sent from SME.
1158 *
1159 ***LOGIC:
1160 *
1161 ***ASSUMPTIONS:
1162 *
1163 ***NOTE:
1164 *
1165 * @param pMac Pointer to Global MAC structure
1166 * @param *pMsgBuf A pointer to the SME message buffer
1167 * @return None
1168 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001169static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1170 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001171{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301172 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001173}
1174
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301175#ifdef WLAN_FEATURE_SAE
1176
1177/**
1178 * lim_update_sae_config()- This API update SAE session info to csr config
1179 * from join request.
1180 * @session: PE session
1181 * @sme_join_req: pointer to join request
1182 *
1183 * Return: None
1184 */
1185static void lim_update_sae_config(tpPESession session,
1186 tpSirSmeJoinReq sme_join_req)
1187{
1188 session->sae_pmk_cached = sme_join_req->sae_pmk_cached;
1189
1190 pe_debug("pmk_cached %d for BSSID=" MAC_ADDRESS_STR,
1191 session->sae_pmk_cached,
1192 MAC_ADDR_ARRAY(sme_join_req->bssDescription.bssId));
1193}
1194#else
1195static inline void lim_update_sae_config(tpPESession session,
1196 tpSirSmeJoinReq sme_join_req)
1197{}
1198#endif
1199
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001200/**
1201 * lim_send_join_req() - send vdev start request
1202 *@session: pe session
1203 *@mlm_join_req: join req
1204 *
1205 * Return: QDF_STATUS
1206 */
1207
1208#ifdef CONFIG_VDEV_SM
1209static QDF_STATUS lim_send_join_req(tpPESession session,
1210 tLimMlmJoinReq *mlm_join_req)
1211{
1212 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
1213 WLAN_VDEV_SM_EV_START,
1214 sizeof(*mlm_join_req),
1215 mlm_join_req);
1216}
1217#else
1218static QDF_STATUS lim_send_join_req(tpPESession session,
1219 tLimMlmJoinReq *mlm_join_req)
1220{
1221 lim_process_mlm_join_req(session->mac_ctx, mlm_join_req);
1222
1223 return QDF_STATUS_SUCCESS;
1224}
1225#endif
1226
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301227
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001228/**
1229 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1230 * @mac_ctx: Pointer to Global MAC structure
1231 * @msg_buf: A pointer to the SME message buffer
1232 *
1233 * This function is called to process SME_JOIN_REQ message
1234 * from HDD or upper layer application.
1235 *
1236 * Return: None
1237 */
1238static void
1239__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1240{
1241 tpSirSmeJoinReq sme_join_req = NULL;
1242 tLimMlmJoinReq *mlm_join_req;
1243 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1244 uint32_t val = 0;
1245 uint16_t n_size;
1246 uint8_t session_id;
1247 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301248 uint8_t sme_session_id = 0;
1249 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001250 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001251 uint16_t ie_len;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001252 const uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001253 tSirBssDescription *bss_desc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001254
Arif Hussain995fcaf2016-07-18 11:28:22 -07001255 if (!mac_ctx || !msg_buf) {
1256 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1257 FL("JOIN REQ with invalid data"));
1258 return;
1259 }
1260
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001261/* FEATURE_WLAN_DIAG_SUPPORT */
1262#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1263 /*
1264 * Not sending any session, since it is not created yet.
1265 * The response whould have correct state.
1266 */
1267 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1268#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1269
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001270 /*
1271 * Expect Join request in idle state.
1272 * Reassociate request is expected in link established state.
1273 */
1274
1275 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1276 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1277 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1278 msg_buf);
1279
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301280 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001281 if (NULL == sme_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001282 pe_err("AllocateMemory failed for sme_join_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001283 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301284 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001285 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301286 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001287 n_size);
1288
1289 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1290 /* Received invalid eWNI_SME_JOIN_REQ */
1291 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001292 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293 sme_join_req->sessionId);
1294 ret_code = eSIR_SME_INVALID_PARAMETERS;
1295 goto end;
1296 }
1297
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001298 /*
1299 * Update the capability here itself as this is used in
1300 * lim_extract_ap_capability() below. If not updated issues
1301 * like not honoring power constraint on 1st association after
1302 * driver loading might occur.
1303 */
1304 lim_update_rrm_capability(mac_ctx, sme_join_req);
1305
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001306 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001307 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001308 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001309 &session_id);
1310
1311 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001312 pe_err("Session(%d) Already exists for BSSID: "
1313 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001314 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001315 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001316 session->limSmeState);
1317
1318 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1319 session->smeSessionId == sme_join_req->sessionId) {
1320 /*
1321 * Received eWNI_SME_JOIN_REQ for same
1322 * BSS as currently associated.
1323 * Log the event and send success
1324 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001325 pe_warn("SessionId: %d", session_id);
1326 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001327 /* Send Join success response to host */
1328 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1329 session = NULL;
1330 goto end;
1331 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001332 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001333 ret_code = eSIR_SME_REFUSED;
1334 session = NULL;
1335 goto end;
1336 }
1337 } else {
1338 /*
1339 * Session Entry does not exist for given BSSId
1340 * Try to Create a new session
1341 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001342 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001343 &session_id, mac_ctx->lim.maxStation,
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +05301344 eSIR_INFRASTRUCTURE_MODE,
1345 sme_join_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001346 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001347 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001348 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1349 goto end;
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301350 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001351 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001352 session_id);
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301353 }
1354
1355 /* Update the beacon/probe filter in mac_ctx */
1356 lim_set_bcn_probe_filter(mac_ctx, session,
1357 &sme_join_req->ssId,
1358 bss_desc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001359 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001360 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Arif Hussain6686c0b2018-08-21 18:21:05 -07001361 session->enable_session_twt_support =
1362 sme_join_req->enable_session_twt_support;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001363 /*
1364 * Store Session related parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001365 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001366
1367 /* store the smejoin req handle in session table */
1368 session->pLimJoinReq = sme_join_req;
1369
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001370 /* Store SME transaction Id in session Table */
1371 session->transactionId = sme_join_req->transactionId;
1372
1373 /* Store beaconInterval */
1374 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001375 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001376
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301377 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001378 sizeof(session->htConfig));
1379
Sandeep Puligilla98917432016-06-10 13:50:28 -07001380 qdf_mem_copy(&(session->vht_config),
1381 &(sme_join_req->vht_config),
1382 sizeof(session->vht_config));
1383
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001384 /* Copying of bssId is already done, while creating session */
1385 sir_copy_mac_addr(session->selfMacAddr,
1386 sme_join_req->selfMacAddr);
1387 session->bssType = sme_join_req->bsstype;
1388
1389 session->statypeForBss = STA_ENTRY_PEER;
1390 session->limWmeEnabled = sme_join_req->isWMEenabled;
1391 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301392 session->wps_registration = sme_join_req->wps_registration;
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001393 session->he_with_wep_tkip = sme_join_req->he_with_wep_tkip;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001394
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301395 session->enable_bcast_probe_rsp =
1396 sme_join_req->enable_bcast_probe_rsp;
1397
Jeff Johnson179fd8a2018-05-11 14:20:05 -07001398 /* Store vendor specific IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001399 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001400 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1401
Naveen Rawat08db88f2017-09-08 15:07:48 -07001402 vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001403 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001404 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001405
1406 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001407 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001408 session->isCiscoVendorAP = true;
1409 } else {
1410 session->isCiscoVendorAP = false;
1411 }
1412
1413 /* Copy the dot 11 mode in to the session table */
1414
1415 session->dot11mode = sme_join_req->dot11mode;
1416#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1417 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1418#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001419 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001420 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1421 session->enableHtSmps = sme_join_req->enableHtSmps;
1422 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001423 session->send_smps_action =
1424 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001425 /*
1426 * By default supported NSS 1x1 is set to true
1427 * and later on updated while determining session
1428 * supported rates which is the intersection of
1429 * self and peer rates
1430 */
1431 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301432 /*Store Persona */
1433 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001434 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 -08001435 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001436 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001437 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301438 session->supported_nss_1x1,
1439 session->pePersona,
1440 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001441
1442 /*Store Persona */
1443 session->pePersona = sme_join_req->staPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +05301444 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301445 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d force_24ghz_in_ht20 %d"),
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001446 session->pePersona, sme_join_req->cbMode,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301447 session->nwType, session->dot11mode,
1448 sme_join_req->force_24ghz_in_ht20);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001449
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001450 /* Copy The channel Id to the session Table */
1451 session->currentOperChannel = bss_desc->channelId;
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301452
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001453 session->vhtCapability =
1454 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001455 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301456 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001457 session->vht_config.su_beam_formee =
1458 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001459 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001460 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001461 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001462 session->enableVhtpAid =
1463 sme_join_req->enableVhtpAid;
1464 session->enableVhtGid =
1465 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001466 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001467 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001468 }
Krunal Soni53993f72016-07-08 18:20:03 -07001469
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001470 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301471 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001472 session->vht_config.su_beam_formee,
1473 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001474 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001475 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001476 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001477 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301478 session->force_24ghz_in_ht20 =
1479 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001480 /* cbMode is already merged value of peer and self -
1481 * done by csr in csr_get_cb_mode_from_ies */
1482 session->htSupportedChannelWidthSet =
1483 (sme_join_req->cbMode) ? 1 : 0;
1484 session->htRecommendedTxWidthSet =
1485 session->htSupportedChannelWidthSet;
1486 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1487
1488 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1489 session->ch_center_freq_seg0 =
1490 session->currentOperChannel - 2;
1491 session->ch_width = CH_WIDTH_40MHZ;
1492 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1493 sme_join_req->cbMode) {
1494 session->ch_center_freq_seg0 =
1495 session->currentOperChannel + 2;
1496 session->ch_width = CH_WIDTH_40MHZ;
1497 } else {
1498 session->ch_center_freq_seg0 = 0;
1499 session->ch_width = CH_WIDTH_20MHZ;
1500 }
1501
Naveen Rawataeca1b92017-10-16 16:55:31 -07001502 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1503 lim_update_session_he_capable(mac_ctx, session);
1504 lim_copy_join_req_he_cap(session, sme_join_req);
1505 }
1506
1507
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001508 /* Record if management frames need to be protected */
1509#ifdef WLAN_FEATURE_11W
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +05301510 if ((eSIR_ED_AES_128_CMAC ==
1511 sme_join_req->MgmtEncryptionType) ||
1512 (eSIR_ED_AES_GMAC_128 == sme_join_req->MgmtEncryptionType) ||
1513 (eSIR_ED_AES_GMAC_256 == sme_join_req->MgmtEncryptionType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001514 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001515 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001516 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001517#endif
1518
1519#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001520 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521#endif
1522
1523 /* Copy the SSID from smejoinreq to session entry */
1524 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301525 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526 session->ssId.length);
1527
1528 /*
1529 * Determin 11r or ESE connection based on input from SME
1530 * which inturn is dependent on the profile the user wants
1531 * to connect to, So input is coming from supplicant
1532 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001533 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001534#ifdef FEATURE_WLAN_ESE
1535 session->isESEconnection = sme_join_req->isESEconnection;
1536#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001537 session->isFastTransitionEnabled =
1538 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001539
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001540 session->isFastRoamIniFeatureEnabled =
1541 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001542 session->txLdpcIniFeatureEnabled =
1543 sme_join_req->txLdpcIniFeatureEnabled;
1544
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301545 lim_update_fils_config(session, sme_join_req);
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301546 lim_update_sae_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001547 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1548 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001549 } else {
1550 /*
1551 * Throw an error and return and make
1552 * sure to delete the session.
1553 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001554 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001555 session->bssType);
1556 ret_code = eSIR_SME_INVALID_PARAMETERS;
1557 goto end;
1558 }
1559
1560 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301561 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001562 &sme_join_req->addIEScan, sizeof(tSirAddie));
1563
1564 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301565 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001566 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1567
1568 val = sizeof(tLimMlmJoinReq) +
1569 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301570 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001571 if (NULL == mlm_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001572 pe_err("AllocateMemory failed for mlmJoinReq");
Nitesh Shah0102cac2016-07-13 14:38:30 +05301573 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1574 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001575 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001576
1577 /* PE SessionId is stored as a part of JoinReq */
1578 mlm_join_req->sessionId = session->peSessionId;
1579
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001580 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301581 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582 (void *)&sme_join_req->operationalRateSet,
1583 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301584 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001585 (void *)&sme_join_req->extendedRateSet,
1586 sizeof(tSirMacRateSet));
1587 /*
1588 * this may not be needed anymore now, as rateSet is now
1589 * included in the session entry and MLM has session context.
1590 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301591 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001592 (void *)&session->rateSet,
1593 sizeof(tSirMacRateSet));
1594
1595 session->encryptType = sme_join_req->UCEncryptionType;
1596
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301597 session->supported_nss_1x1 = sme_join_req->supported_nss_1x1;
1598 session->vdev_nss = sme_join_req->vdev_nss;
1599 session->nss = sme_join_req->nss;
1600 session->nss_forced_1x1 = sme_join_req->nss_forced_1x1;
1601
1602 pe_debug("nss %d, vdev_nss %d, supported_nss_1x1 %d",
1603 session->nss,
1604 session->vdev_nss,
1605 session->supported_nss_1x1);
1606
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001607 mlm_join_req->bssDescription.length =
1608 session->pLimJoinReq->bssDescription.length;
1609
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301610 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001611 (uint8_t *)
1612 &session->pLimJoinReq->bssDescription.bssId,
1613 session->pLimJoinReq->bssDescription.length + 2);
1614
1615 session->limCurrentBssCaps =
1616 session->pLimJoinReq->bssDescription.capabilityInfo;
1617
1618 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1619 session->currentOperChannel);
1620 local_power_constraint = reg_max;
1621
1622 lim_extract_ap_capability(mac_ctx,
1623 (uint8_t *)
1624 session->pLimJoinReq->bssDescription.ieFields,
1625 lim_get_ielen_from_bss_description(
1626 &session->pLimJoinReq->bssDescription),
1627 &session->limCurrentBssQosCaps,
1628 &session->limCurrentBssPropCap,
1629 &session->gLimCurrentBssUapsd,
1630 &local_power_constraint, session);
1631
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001632 session->maxTxPower = lim_get_max_tx_power(reg_max,
1633 local_power_constraint,
1634 mac_ctx->roam.configParam.nTxPowerCap);
Abhinav Kumard528d192018-03-09 17:31:12 +05301635 session->def_max_tx_pwr = session->maxTxPower;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301636
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001637 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301638 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001639
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301640 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1641 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1642 pe_debug("Update MaxTxPower in join Req to %d",
1643 sme_join_req->powerCap.maxTxPower);
1644 }
1645
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001646 if (session->gLimCurrentBssUapsd) {
1647 session->gUapsdPerAcBitmask =
1648 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001649 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001650 session->gUapsdPerAcBitmask);
1651
1652 /* resetting the dynamic uapsd mask */
1653 session->gUapsdPerAcDeliveryEnableMask = 0;
1654 session->gUapsdPerAcTriggerEnableMask = 0;
1655 }
1656
1657 session->limRFBand =
1658 lim_get_rf_band(session->currentOperChannel);
1659
1660 /* Initialize 11h Enable Flag */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001661 if (BAND_5G == session->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001662 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001663 &val) != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001664 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001665 session->lim11hEnable =
1666 WNI_CFG_11H_ENABLED_STADEF;
1667 } else {
1668 session->lim11hEnable = val;
1669 }
1670 } else {
1671 session->lim11hEnable = 0;
1672 }
1673
1674 /*
1675 * To care of the scenario when STA transitions from
1676 * IBSS to Infrastructure mode.
1677 */
1678 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1679
1680 session->limPrevSmeState = session->limSmeState;
1681 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1682 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1683 session->peSessionId,
1684 session->limSmeState));
1685
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001686 /* Indicate whether spectrum management is enabled */
1687 session->spectrumMgtEnabled =
1688 sme_join_req->spectrumMgtIndicator;
1689
1690 /* Enable the spectrum management if this is a DFS channel */
1691 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001692 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001693 session->currentOperChannel))
1694 session->spectrumMgtEnabled = true;
1695
1696 session->isOSENConnection = sme_join_req->isOSENConnection;
1697
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001698 /* Issue LIM_MLM_JOIN_REQ to MLM */
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001699 lim_send_join_req(session, mlm_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001700 return;
1701
1702 } else {
1703 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001704 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001705 mac_ctx->lim.gLimSmeState);
1706 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1707 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1708 session = NULL;
1709 goto end;
1710 }
1711
1712end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301713 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1714 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001715
1716 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301717 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718 sme_join_req = NULL;
1719 if (NULL != session)
1720 session->pLimJoinReq = NULL;
1721 }
1722 if (ret_code != eSIR_SME_SUCCESS) {
1723 if (NULL != session) {
1724 pe_delete_session(mac_ctx, session);
1725 session = NULL;
1726 }
1727 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001728 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001729 sme_session_id, ret_code);
1730 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1731 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1732 sme_transaction_id);
1733}
1734
Amar Singhala297bfa2015-10-15 15:07:29 -07001735uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001736 uint8_t iniTxPower)
1737{
1738 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301739 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001740
Anurag Chouhan6d760662016-02-20 16:05:43 +05301741 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001742 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1743 maxTxPower = txPower;
1744 else if (txPower < MIN_TX_PWR_CAP)
1745 maxTxPower = MIN_TX_PWR_CAP;
1746 else
1747 maxTxPower = MAX_TX_PWR_CAP;
1748
1749 return maxTxPower;
1750}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001751
1752/**
1753 * __lim_process_sme_reassoc_req() - process reassoc req
1754 *
1755 * @mac_ctx: Pointer to Global MAC structure
1756 * @msg_buf: pointer to the SME message buffer
1757 *
1758 * This function is called to process SME_REASSOC_REQ message
1759 * from HDD or upper layer application.
1760 *
1761 * Return: None
1762 */
1763
1764static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
1765 uint32_t *msg_buf)
1766{
1767 uint16_t caps;
1768 uint32_t val;
1769 tpSirSmeJoinReq reassoc_req = NULL;
1770 tLimMlmReassocReq *mlm_reassoc_req;
1771 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1772 tpPESession session_entry = NULL;
1773 uint8_t session_id;
1774 uint8_t sme_session_id;
1775 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001776 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001777 uint32_t tele_bcn_en = 0;
1778 uint16_t size;
1779
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001780 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301781 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001782 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001783 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784
1785 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1786 goto end;
1787 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301788 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001789
1790 if (!lim_is_sme_join_req_valid(mac_ctx,
1791 (tpSirSmeJoinReq)reassoc_req)) {
1792 /*
1793 * Received invalid eWNI_SME_REASSOC_REQ
1794 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001795 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796
1797 ret_code = eSIR_SME_INVALID_PARAMETERS;
1798 goto end;
1799 }
1800
1801 session_entry = pe_find_session_by_bssid(mac_ctx,
1802 reassoc_req->bssDescription.bssId,
1803 &session_id);
1804 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001805 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001806 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
1807 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001808 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001809 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
1810 &sme_session_id, &transaction_id);
1811 session_entry =
1812 pe_find_session_by_sme_session_id(mac_ctx,
1813 sme_session_id);
1814 if (session_entry != NULL)
1815 lim_handle_sme_join_result(mac_ctx,
1816 eSIR_SME_INVALID_PARAMETERS,
1817 eSIR_MAC_UNSPEC_FAILURE_STATUS,
1818 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001819 goto end;
1820 }
1821#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
1822 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001823 session_entry, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001824#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1825 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
1826
1827 /* Store the reassoc handle in the session Table */
1828 session_entry->pLimReAssocReq = reassoc_req;
1829
1830 session_entry->dot11mode = reassoc_req->dot11mode;
1831 session_entry->vhtCapability =
1832 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001833
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301834 if (session_entry->vhtCapability) {
1835 if (session_entry->pePersona == QDF_STA_MODE) {
1836 session_entry->vht_config.su_beam_formee =
1837 reassoc_req->vht_config.su_beam_formee;
1838 } else {
1839 reassoc_req->vht_config.su_beam_formee = 0;
1840 }
1841 session_entry->enableVhtpAid =
1842 reassoc_req->enableVhtpAid;
1843 session_entry->enableVhtGid =
1844 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001845 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301846 }
1847
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301848 session_entry->supported_nss_1x1 = reassoc_req->supported_nss_1x1;
1849 session_entry->vdev_nss = reassoc_req->vdev_nss;
1850 session_entry->nss = reassoc_req->nss;
1851 session_entry->nss_forced_1x1 = reassoc_req->nss_forced_1x1;
1852
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001853 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301854 session_entry->vhtCapability,
1855 session_entry->vht_config.su_beam_formee,
1856 session_entry->vht_config.su_beam_former);
1857
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001858 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
1859 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001860 session_entry->send_smps_action =
1861 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001862 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001863 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001864 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001865 session_entry->send_smps_action,
1866 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001867 /*
1868 * Reassociate request is expected
1869 * in link established state only.
1870 */
1871
1872 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001873 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
1874 /*
1875 * May be from 11r FT pre-auth. So lets check it
1876 * before we bail out
1877 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001878 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001879 session_entry->peSessionId);
1880
1881 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301882 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001883 session_entry->limReAssocbssId,
1884 6)) {
1885 lim_print_mac_addr(mac_ctx,
1886 reassoc_req->bssDescription.
1887 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001888 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001889 ret_code = eSIR_SME_INVALID_PARAMETERS;
1890 goto end;
1891 }
1892
1893 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
1894 session_entry);
1895 return;
1896 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001897 /*
1898 * Should not have received eWNI_SME_REASSOC_REQ
1899 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001900 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001901 session_entry->limSmeState);
1902 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
1903
1904 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1905 goto end;
1906 }
1907
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301908 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001909 session_entry->pLimReAssocReq->bssDescription.bssId,
1910 sizeof(tSirMacAddr));
1911
1912 session_entry->limReassocChannelId =
1913 session_entry->pLimReAssocReq->bssDescription.channelId;
1914
1915 session_entry->reAssocHtSupportedChannelWidthSet =
1916 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
1917 session_entry->reAssocHtRecommendedTxWidthSet =
1918 session_entry->reAssocHtSupportedChannelWidthSet;
1919 session_entry->reAssocHtSecondaryChannelOffset =
1920 session_entry->pLimReAssocReq->cbMode;
1921
1922 session_entry->limReassocBssCaps =
1923 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
1924 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1925 session_entry->currentOperChannel);
1926 local_pwr_constraint = reg_max;
1927
1928 lim_extract_ap_capability(mac_ctx,
1929 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
1930 lim_get_ielen_from_bss_description(
1931 &session_entry->pLimReAssocReq->bssDescription),
1932 &session_entry->limReassocBssQosCaps,
1933 &session_entry->limReassocBssPropCap,
1934 &session_entry->gLimCurrentBssUapsd,
1935 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05301936 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001937 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301938 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001939 /* Copy the SSID from session entry to local variable */
1940 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301941 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001942 reassoc_req->ssId.ssId,
1943 session_entry->limReassocSSID.length);
1944 if (session_entry->gLimCurrentBssUapsd) {
1945 session_entry->gUapsdPerAcBitmask =
1946 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001947 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001948 session_entry->gUapsdPerAcBitmask);
1949 }
1950
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301951 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001952 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001953 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001954
1955 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1956 goto end;
1957 }
1958
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301959 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001960 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
1961
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001962 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001963 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001964 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301965
1966 lim_update_caps_info_for_bss(mac_ctx, &caps,
1967 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001968 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301969
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970 mlm_reassoc_req->capabilityInfo = caps;
1971
1972 /* Update PE session_id */
1973 mlm_reassoc_req->sessionId = session_id;
1974
1975 /*
1976 * If telescopic beaconing is enabled, set listen interval to
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05301977 * CFG_TELE_BCN_MAX_LI
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001978 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001979
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05301980 tele_bcn_en = mac_ctx->mlme_cfg->sap_cfg.tele_bcn_wakeup_en;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001981
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05301982 if (tele_bcn_en)
1983 val = mac_ctx->mlme_cfg->sap_cfg.tele_bcn_max_li;
1984 else
1985 val = mac_ctx->mlme_cfg->sap_cfg.listen_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001986
1987 mlm_reassoc_req->listenInterval = (uint16_t) val;
1988
1989 /* Indicate whether spectrum management is enabled */
1990 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
1991
1992 /* Enable the spectrum management if this is a DFS channel */
1993 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001994 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995 session_entry->currentOperChannel))
1996 session_entry->spectrumMgtEnabled = true;
1997
1998 session_entry->limPrevSmeState = session_entry->limSmeState;
1999 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2000
2001 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2002 session_entry->peSessionId,
2003 session_entry->limSmeState));
2004
2005 lim_post_mlm_message(mac_ctx,
2006 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2007 return;
2008end:
2009 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302010 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002011 if (session_entry)
2012 session_entry->pLimReAssocReq = NULL;
2013 }
2014
2015 if (session_entry) {
2016 /*
2017 * error occurred after we determined the session so extract
2018 * session and transaction info from there
2019 */
2020 sme_session_id = session_entry->smeSessionId;
2021 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002022 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002023 /*
2024 * error occurred before or during the time we determined
2025 * the session so extract the session and transaction info
2026 * from the message
2027 */
2028 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2029 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002030 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031 /*
2032 * Send Reassoc failure response to host
2033 * (note session_entry may be NULL, but that's OK)
2034 */
2035 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2036 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2037 session_entry, sme_session_id,
2038 transaction_id);
2039}
2040
2041bool send_disassoc_frame = 1;
2042/**
2043 * __lim_process_sme_disassoc_req()
2044 *
2045 ***FUNCTION:
2046 * This function is called to process SME_DISASSOC_REQ message
2047 * from HDD or upper layer application.
2048 *
2049 ***LOGIC:
2050 *
2051 ***ASSUMPTIONS:
2052 *
2053 ***NOTE:
2054 *
2055 * @param pMac Pointer to Global MAC structure
2056 * @param *pMsgBuf A pointer to the SME message buffer
2057 * @return None
2058 */
2059
2060static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2061{
2062 uint16_t disassocTrigger, reasonCode;
2063 tLimMlmDisassocReq *pMlmDisassocReq;
2064 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2065 tSirSmeDisassocReq smeDisassocReq;
2066 tpPESession psessionEntry = NULL;
2067 uint8_t sessionId;
2068 uint8_t smesessionId;
2069 uint16_t smetransactionId;
2070
2071 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002072 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002073 return;
2074 }
2075
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302076 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002077 smesessionId = smeDisassocReq.sessionId;
2078 smetransactionId = smeDisassocReq.transactionId;
2079 if (!lim_is_sme_disassoc_req_valid(pMac,
2080 &smeDisassocReq,
2081 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002082 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002083 if (pMac->lim.gLimRspReqd) {
2084 pMac->lim.gLimRspReqd = false;
2085
2086 retCode = eSIR_SME_INVALID_PARAMETERS;
2087 disassocTrigger = eLIM_HOST_DISASSOC;
2088 goto sendDisassoc;
2089 }
2090
2091 return;
2092 }
2093
2094 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002095 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002096 &sessionId);
2097 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002098 pe_err("session does not exist for given bssId "
2099 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002100 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002101 retCode = eSIR_SME_INVALID_PARAMETERS;
2102 disassocTrigger = eLIM_HOST_DISASSOC;
2103 goto sendDisassoc;
2104 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002105 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2106 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002107 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2108 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002109 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002110
2111#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2112 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2113 0, smeDisassocReq.reasonCode);
2114#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2115
2116 /* Update SME session Id and SME transaction ID */
2117
2118 psessionEntry->smeSessionId = smesessionId;
2119 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002120 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002121 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002122
2123 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2124 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002125 switch (psessionEntry->limSmeState) {
2126 case eLIM_SME_ASSOCIATED_STATE:
2127 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002128 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002129 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002130 psessionEntry->limPrevSmeState =
2131 psessionEntry->limSmeState;
2132 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002133 /* Delete all TDLS peers connected before leaving BSS */
2134 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002135 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2136 psessionEntry->peSessionId,
2137 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002138 break;
2139
2140 case eLIM_SME_WT_DEAUTH_STATE:
2141 /* PE shall still process the DISASSOC_REQ and proceed with
2142 * link tear down even if it had already sent a DEAUTH_IND to
2143 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2144 * its been set when PE entered WT_DEAUTH_STATE.
2145 */
2146 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2147 MTRACE(mac_trace
2148 (pMac, TRACE_CODE_SME_STATE,
2149 psessionEntry->peSessionId,
2150 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002151 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002152 break;
2153
2154 case eLIM_SME_WT_DISASSOC_STATE:
Jeff Johnson47d75242018-05-12 15:58:53 -07002155 /* PE Received a Disassoc frame. Normally it gets DISASSOC_CNF but it
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002156 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2157 * PE can continue processing DISASSOC_REQ and send the response instead
2158 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2159 * for disassoc frame.
2160 *
2161 * It will send a disassoc, which is ok. However, we can use the global flag
2162 * sendDisassoc to not send disassoc frame.
2163 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002164 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002165 break;
2166
2167 case eLIM_SME_JOIN_FAILURE_STATE: {
2168 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002169 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002170 if (pMac->lim.gLimRspReqd) {
2171 retCode = eSIR_SME_SUCCESS;
2172 disassocTrigger = eLIM_HOST_DISASSOC;
2173 goto sendDisassoc;
2174 }
2175 }
2176 break;
2177 default:
2178 /**
2179 * STA is not currently associated.
2180 * Log error and send response to host
2181 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002182 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002183 psessionEntry->limSmeState);
2184 lim_print_sme_state(pMac, LOGE,
2185 psessionEntry->limSmeState);
2186
2187 if (pMac->lim.gLimRspReqd) {
2188 if (psessionEntry->limSmeState !=
2189 eLIM_SME_WT_ASSOC_STATE)
2190 pMac->lim.gLimRspReqd = false;
2191
2192 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2193 disassocTrigger = eLIM_HOST_DISASSOC;
2194 goto sendDisassoc;
2195 }
2196
2197 return;
2198 }
2199
2200 break;
2201
2202 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002203 /* Fall through */
2204 break;
2205
2206 case eLIM_STA_IN_IBSS_ROLE:
2207 default:
2208 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002209 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002210 GET_LIM_SYSTEM_ROLE(psessionEntry));
2211
2212 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2213 disassocTrigger = eLIM_HOST_DISASSOC;
2214 goto sendDisassoc;
2215 } /* end switch (pMac->lim.gLimSystemRole) */
2216
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302217 disassocTrigger = eLIM_HOST_DISASSOC;
2218 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002219
2220 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002221 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002222 send_disassoc_frame = 0;
2223 }
2224 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002225 pe_debug("Sending Disasscoc with disassoc Trigger"
2226 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002227 disassocTrigger, reasonCode);
2228
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302229 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002230 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002231 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002232 return;
2233 }
2234
Anurag Chouhanc5548422016-02-24 18:33:27 +05302235 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002236 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002237
2238 pMlmDisassocReq->reasonCode = reasonCode;
2239 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2240
2241 /* Update PE session ID */
2242 pMlmDisassocReq->sessionId = sessionId;
2243
2244 lim_post_mlm_message(pMac,
2245 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2246 return;
2247
2248sendDisassoc:
2249 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002250 lim_send_sme_disassoc_ntf(pMac,
2251 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002252 retCode,
2253 disassocTrigger,
2254 1, smesessionId, smetransactionId,
2255 psessionEntry);
2256 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002257 lim_send_sme_disassoc_ntf(pMac,
2258 smeDisassocReq.peer_macaddr.bytes,
2259 retCode, disassocTrigger, 1,
2260 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002261
2262} /*** end __lim_process_sme_disassoc_req() ***/
2263
2264/** -----------------------------------------------------------------
2265 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2266
2267 This function is called to process SME_DISASSOC_CNF message
2268 from HDD or upper layer application.
2269
2270 \param pMac - global mac structure
2271 \param pStaDs - station dph hash node
2272 \return none
2273 \sa
2274 ----------------------------------------------------------------- */
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002275void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002276{
2277 tSirSmeDisassocCnf smeDisassocCnf;
2278 uint16_t aid;
2279 tpDphHashNode pStaDs;
2280 tpPESession psessionEntry;
2281 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302282 uint32_t *msg = NULL;
2283 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002284
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302285 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002286 sizeof(struct sSirSmeDisassocCnf));
2287
2288 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002289 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002290 &sessionId);
2291 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002292 pe_err("session does not exist for given bssId");
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302293 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302294 smeDisassocCnf.sme_session_id,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302295 eSIR_SME_INVALID_SESSION,
2296 NULL);
2297 if (QDF_IS_STATUS_SUCCESS(status))
2298 lim_send_sme_disassoc_deauth_ntf(pMac,
2299 QDF_STATUS_SUCCESS,
2300 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002301 return;
2302 }
2303
2304 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002305 pe_err("received invalid SME_DISASSOC_CNF message");
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302306 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2307 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302308 eSIR_SME_INVALID_PARAMETERS,
2309 &smeDisassocCnf.bssid.bytes[0]);
2310 if (QDF_IS_STATUS_SUCCESS(status))
2311 lim_send_sme_disassoc_deauth_ntf(pMac,
2312 QDF_STATUS_SUCCESS,
2313 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002314 return;
2315 }
2316#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2317 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2318 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2319 psessionEntry,
2320 (uint16_t) smeDisassocCnf.statusCode, 0);
2321 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2322 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2323 psessionEntry,
2324 (uint16_t) smeDisassocCnf.statusCode, 0);
2325#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2326
2327 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2328 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002329 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2330 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2331 && (psessionEntry->limSmeState !=
2332 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002333 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002334 psessionEntry->limSmeState);
2335 lim_print_sme_state(pMac, LOGE,
2336 psessionEntry->limSmeState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302337 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302338 psessionEntry->smeSessionId,
2339 eSIR_SME_INVALID_STATE,
2340 &smeDisassocCnf.bssid.bytes[0]);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302341 if (QDF_IS_STATUS_SUCCESS(status))
2342 lim_send_sme_disassoc_deauth_ntf(pMac,
2343 QDF_STATUS_SUCCESS,
2344 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002345 return;
2346 }
2347 break;
2348
2349 case eLIM_AP_ROLE:
2350 /* Fall through */
2351 break;
2352
2353 case eLIM_STA_IN_IBSS_ROLE:
2354 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002355 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002356 GET_LIM_SYSTEM_ROLE(psessionEntry));
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302357 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2358 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302359 eSIR_SME_INVALID_STATE,
2360 &smeDisassocCnf.bssid.bytes[0]);
2361 if (QDF_IS_STATUS_SUCCESS(status))
2362 lim_send_sme_disassoc_deauth_ntf(pMac,
2363 QDF_STATUS_SUCCESS,
2364 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002365 return;
2366 }
2367
2368 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2369 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2370 LIM_IS_AP_ROLE(psessionEntry)) {
2371 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002372 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002373 &psessionEntry->dph.dphHashTable);
2374 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002375 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2376 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002377 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302378 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302379 psessionEntry->smeSessionId,
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05302380 eSIR_SME_INVALID_PARAMETERS,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302381 &smeDisassocCnf.bssid.bytes[0]);
2382 if (QDF_IS_STATUS_SUCCESS(status))
2383 lim_send_sme_disassoc_deauth_ntf(pMac,
2384 QDF_STATUS_SUCCESS,
2385 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002386 return;
2387 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302388
2389 if ((pStaDs->mlmStaContext.mlmState ==
2390 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2391 (pStaDs->mlmStaContext.mlmState ==
Arif Hussain5fa13782018-05-10 11:29:52 -07002392 eLIM_MLM_WT_DEL_BSS_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002393 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002394 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302395 pStaDs->mlmStaContext.mlmState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302396 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302397 psessionEntry->smeSessionId,
2398 eSIR_SME_SUCCESS,
2399 NULL);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302400 if (QDF_IS_STATUS_SUCCESS(status))
2401 lim_send_sme_disassoc_deauth_ntf(pMac,
2402 QDF_STATUS_SUCCESS,
2403 (uint32_t *)msg);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302404 return;
2405 }
2406
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002407 /* Delete FT session if there exists one */
2408 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002409 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2410
2411 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002412 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002413 }
2414
2415 return;
2416}
2417
2418/**
2419 * __lim_process_sme_deauth_req() - process sme deauth req
2420 * @mac_ctx: Pointer to Global MAC structure
2421 * @msg_buf: pointer to the SME message buffer
2422 *
2423 * This function is called to process SME_DEAUTH_REQ message
2424 * from HDD or upper layer application.
2425 *
2426 * Return: None
2427 */
2428
2429static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2430 uint32_t *msg_buf)
2431{
2432 uint16_t deauth_trigger, reason_code;
2433 tLimMlmDeauthReq *mlm_deauth_req;
2434 tSirSmeDeauthReq sme_deauth_req;
2435 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2436 tpPESession session_entry;
2437 uint8_t session_id; /* PE sessionId */
2438 uint8_t sme_session_id;
2439 uint16_t sme_transaction_id;
2440
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302441 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002442 sme_session_id = sme_deauth_req.sessionId;
2443 sme_transaction_id = sme_deauth_req.transactionId;
2444
2445 /*
2446 * We need to get a session first but we don't even know
2447 * if the message is correct.
2448 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002449 session_entry = pe_find_session_by_bssid(mac_ctx,
2450 sme_deauth_req.bssid.bytes,
2451 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002452 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002453 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002454 ret_code = eSIR_SME_INVALID_PARAMETERS;
2455 deauth_trigger = eLIM_HOST_DEAUTH;
2456 goto send_deauth;
2457 }
2458
2459 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2460 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002461 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002462 mac_ctx->lim.gLimRspReqd = false;
2463
2464 ret_code = eSIR_SME_INVALID_PARAMETERS;
2465 deauth_trigger = eLIM_HOST_DEAUTH;
2466 goto send_deauth;
2467 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002468 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2469 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002470 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2471 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002472 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002473#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2474 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2475 session_entry, 0, sme_deauth_req.reasonCode);
2476#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2477
2478 /* Update SME session ID and Transaction ID */
2479 session_entry->smeSessionId = sme_session_id;
2480 session_entry->transactionId = sme_transaction_id;
2481
2482 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2483 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002484 switch (session_entry->limSmeState) {
2485 case eLIM_SME_ASSOCIATED_STATE:
2486 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302487 /* Delete all TDLS peers connected before leaving BSS */
2488 lim_delete_tdls_peers(mac_ctx, session_entry);
Abhinav Kumarac12c762018-05-02 13:51:02 +05302489 /* fallthrough */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002490 case eLIM_SME_WT_ASSOC_STATE:
2491 case eLIM_SME_JOIN_FAILURE_STATE:
2492 case eLIM_SME_IDLE_STATE:
2493 session_entry->limPrevSmeState =
2494 session_entry->limSmeState;
2495 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2496 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2497 session_entry->peSessionId,
2498 session_entry->limSmeState));
2499 /* Send Deauthentication request to MLM below */
2500 break;
2501 case eLIM_SME_WT_DEAUTH_STATE:
2502 case eLIM_SME_WT_DISASSOC_STATE:
2503 /*
Jeff Johnson47d75242018-05-12 15:58:53 -07002504 * PE Received a Deauth/Disassoc frame. Normally it get
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002505 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2506 * Which means host is also trying to disconnect.
2507 * PE can continue processing DEAUTH_REQ and send
2508 * the response instead of failing the request.
2509 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2510 * was sent for deauth/disassoc frame.
2511 */
2512 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002513 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002514 break;
2515 default:
2516 /*
2517 * STA is not in a state to deauthenticate with
2518 * peer. Log error and send response to host.
2519 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002520 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002521 session_entry->limSmeState);
2522 lim_print_sme_state(mac_ctx, LOGE,
2523 session_entry->limSmeState);
2524
2525 if (mac_ctx->lim.gLimRspReqd) {
2526 mac_ctx->lim.gLimRspReqd = false;
2527
2528 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2529 deauth_trigger = eLIM_HOST_DEAUTH;
2530
wadesong42968e92017-06-08 14:11:21 +08002531 /*
2532 * here we received deauth request from AP so
2533 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2534 * have ISSUED delSta then mlm state should be
2535 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2536 * delBSS rsp then mlm state should be
2537 * eLIM_MLM_IDLE_STATE so the below condition
2538 * captures the state where delSta not done
2539 * and firmware still in connected state.
2540 */
2541 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002542 eLIM_SME_WT_DEAUTH_STATE &&
2543 session_entry->limMlmState !=
2544 eLIM_MLM_IDLE_STATE &&
2545 session_entry->limMlmState !=
2546 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002547 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002548 goto send_deauth;
2549 }
2550 return;
2551 }
2552 break;
2553
2554 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002555 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002556 if (mac_ctx->lim.gLimRspReqd) {
2557 mac_ctx->lim.gLimRspReqd = false;
2558 ret_code = eSIR_SME_INVALID_PARAMETERS;
2559 deauth_trigger = eLIM_HOST_DEAUTH;
2560 goto send_deauth;
2561 }
2562 return;
2563 case eLIM_AP_ROLE:
2564 break;
2565 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002566 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002567 GET_LIM_SYSTEM_ROLE(session_entry));
2568 if (mac_ctx->lim.gLimRspReqd) {
2569 mac_ctx->lim.gLimRspReqd = false;
2570 ret_code = eSIR_SME_INVALID_PARAMETERS;
2571 deauth_trigger = eLIM_HOST_DEAUTH;
2572 goto send_deauth;
2573 }
2574 return;
2575 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2576
2577 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2578 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002579 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002580 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2581 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2582 } else {
2583 deauth_trigger = eLIM_HOST_DEAUTH;
2584 reason_code = sme_deauth_req.reasonCode;
2585 }
2586
2587 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302588 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002589 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002590 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002591 if (mac_ctx->lim.gLimRspReqd) {
2592 mac_ctx->lim.gLimRspReqd = false;
2593 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2594 deauth_trigger = eLIM_HOST_DEAUTH;
2595 goto send_deauth;
2596 }
2597 return;
2598 }
2599
Anurag Chouhanc5548422016-02-24 18:33:27 +05302600 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002601 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002602
2603 mlm_deauth_req->reasonCode = reason_code;
2604 mlm_deauth_req->deauthTrigger = deauth_trigger;
2605
2606 /* Update PE session Id */
2607 mlm_deauth_req->sessionId = session_id;
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002608 lim_process_mlm_deauth_req(mac_ctx, (uint32_t *)mlm_deauth_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002609
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002610 return;
2611
2612send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002613 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2614 ret_code, deauth_trigger, 1,
2615 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002616}
2617
2618/**
2619 * __lim_process_sme_set_context_req()
2620 *
2621 * @mac_ctx: Pointer to Global MAC structure
2622 * @msg_buf: pointer to the SME message buffer
2623 *
2624 * This function is called to process SME_SETCONTEXT_REQ message
2625 * from HDD or upper layer application.
2626 *
2627 * Return: None
2628 */
2629
2630static void
2631__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2632{
2633 tpSirSmeSetContextReq set_context_req;
2634 tLimMlmSetKeysReq *mlm_set_key_req;
2635 tpPESession session_entry;
2636 uint8_t session_id; /* PE sessionID */
2637 uint8_t sme_session_id;
2638 uint16_t sme_transaction_id;
2639
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002640 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002641 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002642 return;
2643 }
2644
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302645 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002646 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002647 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002648 return;
2649 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302650 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002651 sizeof(struct sSirSmeSetContextReq));
2652 sme_session_id = set_context_req->sessionId;
2653 sme_transaction_id = set_context_req->transactionId;
2654
2655 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002656 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002657 goto end;
2658 }
2659
2660 if (set_context_req->keyMaterial.numKeys >
2661 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002662 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002663 set_context_req->keyMaterial.numKeys);
2664 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002665 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002666 eSIR_SME_INVALID_PARAMETERS, NULL,
2667 sme_session_id, sme_transaction_id);
2668 goto end;
2669 }
2670
2671 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002672 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002673 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002674 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002675 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002676 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002677 eSIR_SME_INVALID_PARAMETERS, NULL,
2678 sme_session_id, sme_transaction_id);
2679 goto end;
2680 }
2681#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2682 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2683 session_entry, 0, 0);
2684#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2685
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002686 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002687 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2688 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002689 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002690 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2691 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302692 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002693 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002694 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002695 goto end;
2696 }
2697 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2698 mlm_set_key_req->numKeys =
2699 set_context_req->keyMaterial.numKeys;
2700 if (mlm_set_key_req->numKeys >
2701 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002702 pe_err("no.of keys exceeded max num of default keys limit");
Jingxiang Ge4168a232018-01-03 18:47:15 +08002703 qdf_mem_free(mlm_set_key_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002704 goto end;
2705 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302706 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002707 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002708
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302709 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002710 (uint8_t *) &set_context_req->keyMaterial.key,
2711 sizeof(tSirKeys) *
2712 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2713 numKeys : 1));
2714
2715 mlm_set_key_req->sessionId = session_id;
2716 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002717 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002718 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002719
2720 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2721 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2722 LIM_IS_AP_ROLE(session_entry)) {
2723 if (set_context_req->keyMaterial.key[0].keyLength) {
2724 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002725
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002726 key_id =
2727 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302728 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002729 &session_entry->WEPKeyMaterial[key_id],
2730 (uint8_t *) &set_context_req->keyMaterial,
2731 sizeof(tSirKeyMaterial));
2732 } else {
2733 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002734
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002735 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2736 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302737 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002738 &mlm_set_key_req->key[i],
2739 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2740 sizeof(tSirKeys));
2741 }
2742 }
2743 }
2744 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2745 (uint32_t *) mlm_set_key_req);
2746 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002747 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002748 GET_LIM_SYSTEM_ROLE(session_entry),
2749 session_entry->limSmeState);
2750 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2751
2752 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002753 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002754 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2755 session_entry, sme_session_id,
2756 sme_transaction_id);
2757 }
2758end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302759 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002760 return;
2761}
2762
2763/**
2764 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2765 *
2766 * @mac_ctx: Pointer to Global MAC structure
2767 * @msg_buf: pointer to the SME message buffer
2768 *
2769 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2770 * from HDD or upper layer application.
2771 *
2772 * Return: None
2773 */
2774
Jeff Johnson801f1532016-10-07 07:54:50 -07002775static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2776 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002777{
2778 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2779 tpDphHashNode sta_ds = NULL;
2780 tpPESession session_entry = NULL;
2781 tSap_Event sap_event;
2782 tpWLAN_SAPEventCB sap_event_cb = NULL;
2783 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2784 uint8_t session_id = CSR_SESSION_ID_INVALID;
2785 uint8_t assoc_id = 0;
2786 uint8_t sta_cnt = 0;
2787
2788 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002789 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002790 return;
2791 }
2792
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302793 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002794 sizeof(struct sSirSmeGetAssocSTAsReq));
2795 /*
2796 * Get Associated stations from PE.
2797 * Find PE session Entry
2798 */
2799 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08002800 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002801 &session_id);
2802 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002803 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002804 goto lim_assoc_sta_end;
2805 }
2806
2807 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002808 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002809 session_entry->limSmeState,
2810 GET_LIM_SYSTEM_ROLE(session_entry));
2811 goto lim_assoc_sta_end;
2812 }
2813 /* Retrieve values obtained in the request message */
2814 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
2815 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2816
2817 if (NULL == assoc_sta_tmp)
2818 goto lim_assoc_sta_end;
2819 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
2820 assoc_id++) {
2821 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
2822 &session_entry->dph.dphHashTable);
2823 if (NULL == sta_ds)
2824 continue;
2825 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302826 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002827 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302828 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002829 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
2830 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
2831
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302832 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002833 (uint8_t *)&sta_ds->supportedRates,
2834 sizeof(tSirSupportedRates));
2835 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
2836 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
2837 assoc_sta_tmp->Support40Mhz =
2838 sta_ds->htDsssCckRate40MHzSupport;
2839
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002840 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002841 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002842 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002843 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002844 pe_debug("Association Id: %d Station Index: %d",
2845 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002846 assoc_sta_tmp++;
2847 sta_cnt++;
2848 }
2849 }
2850lim_assoc_sta_end:
2851 /*
2852 * Call hdd callback with sap event to send the list of
2853 * associated stations from PE
2854 */
2855 if (sap_event_cb != NULL) {
2856 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
2857 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302858 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002859 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
2860 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
2861 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2862 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
2863 }
2864}
2865
2866/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002867 * __lim_counter_measures()
2868 *
2869 * FUNCTION:
2870 * This function is called to "implement" MIC counter measure
2871 * and is *temporary* only
2872 *
2873 * LOGIC: on AP, disassoc all STA associated thru TKIP,
2874 * we don't do the proper STA disassoc sequence since the
Jeff Johnsond460e842018-05-11 13:25:53 -07002875 * BSS will be stopped anyway
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002876 *
2877 ***ASSUMPTIONS:
2878 *
2879 ***NOTE:
2880 *
2881 * @param pMac Pointer to Global MAC structure
2882 * @return None
2883 */
2884
2885static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
2886{
2887 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002888
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002889 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002890 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
2891 mac, psessionEntry, false);
2892};
2893
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302894/**
2895 * lim_send_stop_bss_failure_resp() -send failure delete bss resp to sme
2896 * @mac_ctx: mac ctx
2897 * @session: session pointer
2898 *
2899 * Return None
2900 */
2901static void lim_send_stop_bss_failure_resp(tpAniSirGlobal mac_ctx,
2902 tpPESession session)
2903{
2904 session->limSmeState = session->limPrevSmeState;
2905
2906 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE, session->peSessionId,
2907 session->limSmeState));
2908
2909 lim_send_sme_rsp(mac_ctx, eWNI_SME_STOP_BSS_RSP,
2910 eSIR_SME_STOP_BSS_FAILURE, session->smeSessionId,
2911 session->transactionId);
2912}
2913
2914void lim_delete_all_peers(tpPESession session)
2915{
2916 uint8_t i = 0;
2917 tpAniSirGlobal mac_ctx = session->mac_ctx;
2918 tpDphHashNode sta_ds = NULL;
2919 QDF_STATUS status;
2920
2921 for (i = 1; i < session->dph.dphHashTable.size; i++) {
2922 sta_ds = dph_get_hash_entry(mac_ctx, i,
2923 &session->dph.dphHashTable);
2924 if (!sta_ds)
2925 continue;
2926 status = lim_del_sta(mac_ctx, sta_ds, false, session);
2927 if (QDF_STATUS_SUCCESS == status) {
2928 lim_delete_dph_hash_entry(mac_ctx, sta_ds->staAddr,
2929 sta_ds->assocId, session);
2930 lim_release_peer_idx(mac_ctx, sta_ds->assocId, session);
2931 } else {
2932 pe_err("lim_del_sta failed with Status: %d", status);
2933 QDF_ASSERT(0);
2934 }
2935 }
Abhishek Singhcaa61852018-09-12 15:50:04 +05302936
2937#ifdef CONFIG_VDEV_SM
2938 status =
2939 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
2940 WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE,
2941 sizeof(*session), session);
2942 if (QDF_IS_STATUS_ERROR(status)) {
2943 pe_err("failed to post WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE for vdevid %d",
2944 session->smeSessionId);
2945 lim_send_stop_bss_failure_resp(mac_ctx, session);
2946 }
2947#endif
2948
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302949}
2950
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002951QDF_STATUS lim_sta_send_del_bss(tpPESession session)
2952{
2953 tpAniSirGlobal mac_ctx = session->mac_ctx;
2954 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2955 tpDphHashNode sta_ds = NULL;
2956
2957 sta_ds = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
2958 &session->dph.dphHashTable);
2959 if (!sta_ds) {
2960 pe_err("DPH Entry for STA is missing, failed to send delbss");
2961 goto end;
2962 }
2963
2964 status = lim_del_bss(mac_ctx, sta_ds, 0, session);
2965 if (QDF_IS_STATUS_ERROR(status))
2966 pe_err("delBss failed for bss %d", session->bssIdx);
2967
2968end:
2969 return status;
2970}
2971
Abhishek Singhcaa61852018-09-12 15:50:04 +05302972QDF_STATUS lim_send_vdev_stop(tpPESession session)
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302973{
2974 tpAniSirGlobal mac_ctx = session->mac_ctx;
2975 QDF_STATUS status;
2976
2977 status = lim_del_bss(mac_ctx, NULL, session->bssIdx, session);
2978
2979 if (QDF_IS_STATUS_ERROR(status)) {
2980 pe_err("delBss failed for bss %d", session->bssIdx);
2981 lim_send_stop_bss_failure_resp(mac_ctx, session);
2982 }
Abhishek Singhcaa61852018-09-12 15:50:04 +05302983
2984 return status;
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302985}
2986
2987/**
2988 * lim_delete_peers_and_send_vdev_stop() -delete peers and send vdev stop
2989 * @session: session pointer
2990 *
2991 * Return None
2992 */
Abhishek Singhcaa61852018-09-12 15:50:04 +05302993#ifdef CONFIG_VDEV_SM
2994static void lim_delete_peers_and_send_vdev_stop(tpPESession session)
2995{
2996 tpAniSirGlobal mac_ctx = session->mac_ctx;
2997 QDF_STATUS status;
2998
Abhishek Singhc5a54082018-09-12 16:08:03 +05302999 if (wlan_vdev_mlme_get_substate(session->vdev) ==
3000 WLAN_VDEV_SS_START_RESTART_PROGRESS)
3001 status =
3002 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3003 WLAN_VDEV_SM_EV_RESTART_REQ_FAIL,
Abhishek Singhcaa61852018-09-12 15:50:04 +05303004 sizeof(*session), session);
Abhishek Singhc5a54082018-09-12 16:08:03 +05303005 else
3006 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3007 WLAN_VDEV_SM_EV_DOWN,
3008 sizeof(*session),
3009 session);
Abhishek Singhcaa61852018-09-12 15:50:04 +05303010 if (QDF_IS_STATUS_ERROR(status)) {
3011 pe_err("failed to post WLAN_VDEV_SM_EV_DOWN for vdevid %d",
3012 session->smeSessionId);
3013 lim_send_stop_bss_failure_resp(mac_ctx, session);
3014 }
3015}
3016#else
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303017static void lim_delete_peers_and_send_vdev_stop(tpPESession session)
3018{
3019 lim_delete_all_peers(session);
3020 /* send a delBss to HAL and wait for a response */
3021 lim_send_vdev_stop(session);
3022}
Abhishek Singhcaa61852018-09-12 15:50:04 +05303023#endif
3024
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003025static void
3026__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3027{
3028 tSirSmeStopBssReq stopBssReq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003029 tLimSmeStates prevState;
3030 tpPESession psessionEntry;
3031 uint8_t smesessionId;
3032 uint8_t sessionId;
3033 uint16_t smetransactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003034
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303035 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003036 smesessionId = stopBssReq.sessionId;
3037 smetransactionId = stopBssReq.transactionId;
3038
3039 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003040 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003041 /* Send Stop BSS response to host */
3042 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3043 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3044 smetransactionId);
3045 return;
3046 }
3047
3048 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003049 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003050 &sessionId);
3051 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003052 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003053 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3054 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3055 smetransactionId);
3056 return;
3057 }
3058#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3059 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3060 0, 0);
3061#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3062
3063 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3064 LIM_IS_STA_ROLE(psessionEntry)) {
3065 /**
3066 * Should not have received STOP_BSS_REQ in states
3067 * other than 'normal' state or on STA in Infrastructure
3068 * mode. Log error and return response to host.
3069 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003070 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003071 psessionEntry->limSmeState,
3072 GET_LIM_SYSTEM_ROLE(psessionEntry));
3073 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3074 /* / Send Stop BSS response to host */
3075 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3076 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3077 smetransactionId);
3078 return;
3079 }
3080
3081 if (LIM_IS_AP_ROLE(psessionEntry))
3082 lim_wpspbc_close(pMac, psessionEntry);
3083
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003084 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003085 stopBssReq.reasonCode);
3086
3087 prevState = psessionEntry->limSmeState;
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303088 psessionEntry->limPrevSmeState = prevState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003089
3090 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3091 MTRACE(mac_trace
3092 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3093 psessionEntry->limSmeState));
3094
3095 /* Update SME session Id and Transaction Id */
3096 psessionEntry->smeSessionId = smesessionId;
3097 psessionEntry->transactionId = smetransactionId;
3098
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003099 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3100 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3101 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003102 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003103
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003104 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3105 /* Send disassoc all stations associated thru TKIP */
3106 __lim_counter_measures(pMac, psessionEntry);
3107 else
3108 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003109 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3110 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003111 }
3112
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003113 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3114 /* Free the buffer allocated in START_BSS_REQ */
3115 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3116 psessionEntry->addIeParams.probeRespDataLen = 0;
3117 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003118
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003119 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3120 psessionEntry->addIeParams.assocRespDataLen = 0;
3121 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003122
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003123 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3124 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3125 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003126
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003127 /*
3128 * lim_del_bss is also called as part of coalescing,
3129 * when we send DEL BSS followed by Add Bss msg.
3130 */
3131 pMac->lim.gLimIbssCoalescingHappened = false;
3132 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003133
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303134 lim_delete_peers_and_send_vdev_stop(psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003135
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003136}
3137
3138/**
3139 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3140 * @pMac: Global MAC context
3141 * @pMsg: Message from SME
3142 *
3143 * Wrapper for the function __lim_handle_sme_stop_bss_request
3144 * This message will be defered until softmac come out of
3145 * scan mode. Message should be handled even if we have
3146 * detected radar in the current operating channel.
3147 *
3148 * Return: true - If we consumed the buffer
3149 * false - If have defered the message.
3150 */
3151
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003152static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3153 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003154{
3155 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3156 /**
3157 * If message defered, buffer is not consumed yet.
3158 * So return false
3159 */
3160 return false;
3161 }
3162 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3163 return true;
3164} /*** end __lim_process_sme_stop_bss_req() ***/
3165
3166void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3167 uint32_t body, tpPESession psessionEntry)
3168{
3169
3170 (void)body;
3171 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3172 lim_ibss_delete(pMac, psessionEntry);
3173 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3174 lim_delete_pre_auth_list(pMac);
3175 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3176 psessionEntry->smeSessionId,
3177 psessionEntry->transactionId);
3178 return;
3179}
3180
3181/**
3182 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3183 *
3184 * @mac_ctx: pointer to mac context
3185 * @msg_type: message type
3186 * @msg_buf: pointer to the SME message buffer
3187 *
3188 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3189 * in BTAMP AP.
3190 *
3191 * Return: None
3192 */
3193
3194void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3195 uint32_t *msg_buf)
3196{
3197 tSirSmeAssocCnf assoc_cnf;
3198 tpDphHashNode sta_ds = NULL;
3199 tpPESession session_entry = NULL;
3200 uint8_t session_id;
3201 tpSirAssocReq assoc_req;
3202
3203 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003204 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003205 goto end;
3206 }
3207
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303208 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003209 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003210 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003211 goto end;
3212 }
3213
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003214 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003215 &session_id);
3216 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003217 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218 goto end;
3219 }
3220
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003221 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003222 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3223 (session_entry->limSmeState !=
3224 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003225 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226 msg_type, session_entry->limSmeState,
3227 GET_LIM_SYSTEM_ROLE(session_entry));
3228 goto end;
3229 }
3230 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3231 &session_entry->dph.dphHashTable);
3232 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003233 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003234 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303235 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003236
3237 /*
3238 * send a DISASSOC_IND message to WSM to make sure
3239 * the state in WSM and LIM is the same
3240 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003241 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003242 eSIR_SME_STA_NOT_ASSOCIATED,
3243 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3244 session_entry->smeSessionId,
3245 session_entry->transactionId,
3246 session_entry);
3247 goto end;
3248 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303249 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003250 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303251 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003252 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303254 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003255 goto end;
3256 }
3257
3258 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3259 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3260 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3261 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3262 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003263 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3264 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003265 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303266 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003267 goto end;
3268 }
3269 /*
3270 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3271 * has been received
3272 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003273 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003274 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3275 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3276
3277 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3278 /*
3279 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3280 * when it had received Assoc Request frame. Now, PE just needs
3281 * to send association rsp frame to the requesting BTAMP-STA.
3282 */
3283 sta_ds->mlmStaContext.mlmState =
3284 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003285 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003286 sta_ds->assocId);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003287 lim_send_assoc_rsp_mgmt_frame(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003288 sta_ds->assocId, sta_ds->staAddr,
3289 sta_ds->mlmStaContext.subType, sta_ds,
3290 session_entry);
3291 goto end;
3292 } else {
3293 /*
3294 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3295 * to be associated since the HAL sta entry is created for
3296 * denied STA we need to remove this HAL entry.
3297 * So to do that set updateContext to 1
3298 */
3299 if (!sta_ds->mlmStaContext.updateContext)
3300 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003301 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003302 assoc_cnf.statusCode, sta_ds->assocId);
3303 lim_reject_association(mac_ctx, sta_ds->staAddr,
3304 sta_ds->mlmStaContext.subType,
3305 true, sta_ds->mlmStaContext.authType,
3306 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003307 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003308 session_entry);
3309 }
3310end:
3311 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3312 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3313 assoc_req = (tpSirAssocReq)
3314 session_entry->parsedAssocReq[sta_ds->assocId];
3315 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303316 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003317 assoc_req->assocReqFrame = NULL;
3318 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303319 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003320 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3321 }
3322}
3323
3324static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3325{
3326 tpDphHashNode pStaDs;
3327 tSirMacAddr peerMac;
3328 tpSirAddtsReq pSirAddts;
3329 uint32_t timeout;
3330 tpPESession psessionEntry;
3331 uint8_t sessionId; /* PE sessionId */
3332 uint8_t smesessionId;
3333 uint16_t smetransactionId;
3334
3335 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003336 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003337 return;
3338 }
3339
3340 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3341 &smetransactionId);
3342
3343 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3344
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003345 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3346 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003347 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003348 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003349 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303350 NULL, pSirAddts->req.tspec,
3351 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003352 return;
3353 }
3354#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3355 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3356 0);
3357#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3358
3359 /* if sta
3360 * - verify assoc state
3361 * - send addts request to ap
3362 * - wait for addts response from ap
3363 * if ap, just ignore with error log
3364 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003365 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3366 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3367 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003368
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003369 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003370 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303371 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003372 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003373
3374 pStaDs =
3375 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3376 &psessionEntry->dph.dphHashTable);
3377
3378 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003379 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303380 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003381 }
3382
3383 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3384 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003385 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303386 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003387 }
3388
3389 pSirAddts->req.wsmTspecPresent = 0;
3390 pSirAddts->req.wmeTspecPresent = 0;
3391 pSirAddts->req.lleTspecPresent = 0;
3392
3393 if ((pStaDs->wsmEnabled) &&
3394 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3395 SIR_MAC_ACCESSPOLICY_EDCA))
3396 pSirAddts->req.wsmTspecPresent = 1;
3397 else if (pStaDs->wmeEnabled)
3398 pSirAddts->req.wmeTspecPresent = 1;
3399 else if (pStaDs->lleEnabled)
3400 pSirAddts->req.lleTspecPresent = 1;
3401 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003402 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303403 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003404 }
3405
3406 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3407 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003408 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003409 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303410 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003411 }
3412
3413 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003414 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003415 pMac->lim.gLimAddtsReq.req.dialogToken,
3416 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3417 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3418 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303419 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003420 }
3421
3422 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3423
3424 /* save the addts request */
3425 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303426 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003427 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3428
3429 /* ship out the message now */
3430 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3431 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303432 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003433 /* start a timer to wait for the response */
3434 if (pSirAddts->timeout)
3435 timeout = pSirAddts->timeout;
Arif Hussain43e09712018-09-18 19:31:57 -07003436 else
3437 timeout = pMac->mlme_cfg->timeouts.addts_rsp_timeout;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003438
3439 timeout = SYS_MS_TO_TICKS(timeout);
3440 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3441 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003442 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303443 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003444 }
3445 pMac->lim.gLimAddtsRspTimerCount++;
3446 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3447 pMac->lim.gLimAddtsRspTimerCount) !=
3448 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003449 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303450 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003451 }
3452 MTRACE(mac_trace
3453 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3454 eLIM_ADDTS_RSP_TIMER));
3455
3456 /* add the sessionId to the timer object */
3457 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3458 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3459 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003460 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303461 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462 }
3463 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303464
3465send_failure_addts_rsp:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003466 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303467 psessionEntry, pSirAddts->req.tspec,
3468 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003469}
3470
3471static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3472{
3473 tSirMacAddr peerMacAddr;
3474 uint8_t ac;
3475 tSirMacTSInfo *pTsinfo;
3476 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3477 tpDphHashNode pStaDs = NULL;
3478 tpPESession psessionEntry;
3479 uint8_t sessionId;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003480 uint32_t status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003481 uint8_t smesessionId;
3482 uint16_t smetransactionId;
3483
3484 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3485 &smetransactionId);
3486
3487 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003488 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003489 &sessionId);
3490 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003491 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003492 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003493 goto end;
3494 }
3495#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3496 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3497 0);
3498#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3499
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003500 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003501 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003502 pe_err("lim_validate_delts_req failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003503 status = QDF_STATUS_E_FAILURE;
3504 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_E_FAILURE, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003505 smesessionId, smetransactionId);
3506 return;
3507 }
3508
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003509 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3510 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003511 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3512
3513 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3514 pDeltsReq->req.wmeTspecPresent,
3515 &pDeltsReq->req.tsinfo,
3516 &pDeltsReq->req.tspec, psessionEntry);
3517
3518 pTsinfo =
3519 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3520 tsinfo : &pDeltsReq->req.tsinfo;
3521
3522 /* We've successfully send DELTS frame to AP. Update the
3523 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3524 * is no longer trigger enabled or delivery enabled
3525 */
3526 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3527 pTsinfo, CLEAR_UAPSD_MASK);
3528
3529 /* We're deleting the TSPEC, so this particular AC is no longer
3530 * admitted. PE needs to downgrade the EDCA
3531 * parameters(for the AC for which TS is being deleted) to the
3532 * next best AC for which ACM is not enabled, and send the
3533 * updated values to HAL.
3534 */
3535 ac = upToAc(pTsinfo->traffic.userPrio);
3536
3537 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3538 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3539 ~(1 << ac);
3540 } else if (pTsinfo->traffic.direction ==
3541 SIR_MAC_DIRECTION_DNLINK) {
3542 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3543 ~(1 << ac);
3544 } else if (pTsinfo->traffic.direction ==
3545 SIR_MAC_DIRECTION_BIDIR) {
3546 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3547 ~(1 << ac);
3548 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3549 ~(1 << ac);
3550 }
3551
3552 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3553 psessionEntry);
3554
3555 pStaDs =
3556 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3557 &psessionEntry->dph.dphHashTable);
3558 if (pStaDs != NULL) {
3559 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003560 pStaDs->bssId, false);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003561 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003562 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003563 pe_err("Self entry missing in Hash Table");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003564 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003565 }
3566#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003567 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003568#endif
3569
3570 /* send an sme response back */
3571end:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003572 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_SUCCESS, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003573 smesessionId, smetransactionId);
3574}
3575
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303576void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003577{
3578 /* fetch the sessionEntry based on the sessionId */
3579 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003580
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003581 psessionEntry = pe_find_session_by_session_id(pMac,
3582 pMac->lim.limTimers.gLimAddtsRspTimer.
3583 sessionId);
3584 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003585 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586 return;
3587 }
3588
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003589 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003590 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003591 GET_LIM_SYSTEM_ROLE(psessionEntry));
3592 pMac->lim.gLimAddtsSent = false;
3593 return;
3594 }
3595
3596 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003597 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598 return;
3599 }
3600
3601 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003602 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003603 pMac->lim.gLimAddtsRspTimerCount);
3604 return;
3605 }
3606 /* this a real response timeout */
3607 pMac->lim.gLimAddtsSent = false;
3608 pMac->lim.gLimAddtsRspTimerCount++;
3609
3610 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3611 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3612 psessionEntry->smeSessionId,
3613 psessionEntry->transactionId);
3614}
3615
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003616#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003617/**
3618 * __lim_process_sme_get_statistics_request()
3619 *
3620 ***FUNCTION:
3621 *
3622 *
3623 ***NOTE:
3624 *
3625 * @param pMac Pointer to Global MAC structure
3626 * @param *pMsgBuf A pointer to the SME message buffer
3627 * @return None
3628 */
3629static void
3630__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3631{
3632 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003633 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003634
3635 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3636
3637 msgQ.type = WMA_GET_STATISTICS_REQ;
3638
3639 msgQ.reserved = 0;
3640 msgQ.bodyptr = pMsgBuf;
3641 msgQ.bodyval = 0;
3642 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3643
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003644 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303645 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003646 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003647 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003648 return;
3649 }
3650
3651 return;
3652}
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003653#else
3654static void __lim_process_sme_get_statistics_request(
3655 struct sAniSirGlobal *mac_ctx, uint32_t *pMsgBuf) {}
3656#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003657
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003658#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003659/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003660 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003661 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003662 * @pMac: Pointer to Global MAC structure
3663 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003664 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003665 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666 */
3667static void
3668__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3669{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003670 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003671
3672 msgQ.type = WMA_TSM_STATS_REQ;
3673 msgQ.reserved = 0;
3674 msgQ.bodyptr = pMsgBuf;
3675 msgQ.bodyval = 0;
3676 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3677
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003678 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303679 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003680 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003681 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003682 return;
3683 }
3684}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003685#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003686
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08003687static void lim_process_sme_set_addba_accept(tpAniSirGlobal mac_ctx,
3688 struct sme_addba_accept *msg)
3689{
3690 if (!msg) {
3691 pe_err("Msg Buffer is NULL");
3692 return;
3693 }
3694 if (!msg->addba_accept)
3695 mac_ctx->reject_addba_req = 1;
3696 else
3697 mac_ctx->reject_addba_req = 0;
3698}
3699
Arif Hussaineb8ba362018-03-07 19:15:13 -08003700static void lim_process_sme_update_edca_params(tpAniSirGlobal mac_ctx,
3701 uint32_t sme_session_id)
3702{
3703 tpPESession pe_session;
3704 tpDphHashNode sta_ds_ptr;
3705
3706 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3707 if (!pe_session) {
3708 pe_err("Session does not exist: sme_id %d", sme_session_id);
3709 return;
3710 }
3711 pe_session->gLimEdcaParamsActive[EDCA_AC_BE].no_ack =
3712 mac_ctx->no_ack_policy_cfg[EDCA_AC_BE];
3713 pe_session->gLimEdcaParamsActive[EDCA_AC_BK].no_ack =
3714 mac_ctx->no_ack_policy_cfg[EDCA_AC_BK];
3715 pe_session->gLimEdcaParamsActive[EDCA_AC_VI].no_ack =
3716 mac_ctx->no_ack_policy_cfg[EDCA_AC_VI];
3717 pe_session->gLimEdcaParamsActive[EDCA_AC_VO].no_ack =
3718 mac_ctx->no_ack_policy_cfg[EDCA_AC_VO];
3719 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3720 &pe_session->dph.dphHashTable);
3721 if (sta_ds_ptr)
3722 lim_send_edca_params(mac_ctx,
3723 pe_session->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003724 sta_ds_ptr->bssId, false);
Arif Hussaineb8ba362018-03-07 19:15:13 -08003725 else
3726 pe_err("Self entry missing in Hash Table");
3727}
3728
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07003729static void lim_process_sme_update_mu_edca_params(tpAniSirGlobal mac_ctx,
3730 uint32_t sme_session_id)
3731{
3732 tpPESession pe_session;
3733 tpDphHashNode sta_ds_ptr;
3734
3735 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3736 if (!pe_session) {
3737 pe_err("Session does not exist: sme_id %d", sme_session_id);
3738 return;
3739 }
3740 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3741 &pe_session->dph.dphHashTable);
3742 if (sta_ds_ptr)
3743 lim_send_edca_params(mac_ctx, mac_ctx->usr_mu_edca_params,
3744 sta_ds_ptr->bssId, true);
3745 else
3746 pe_err("Self entry missing in Hash Table");
3747}
3748
Naveen Rawat8029a402017-06-01 10:54:19 -07003749static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3750 struct update_config *msg)
3751{
3752 tpPESession pe_session;
3753
3754 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3755 if (msg == NULL) {
3756 pe_err("Buffer is Pointing to NULL");
3757 return;
3758 }
3759
3760 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3761 msg->sme_session_id);
3762 if (pe_session == NULL) {
3763 pe_warn("Session does not exist for given BSSID");
3764 return;
3765 }
3766
3767 switch (msg->capab) {
3768 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3769 pe_session->htConfig.ht_rx_ldpc = msg->value;
3770 break;
3771 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3772 pe_session->htConfig.ht_tx_stbc = msg->value;
3773 break;
3774 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3775 pe_session->htConfig.ht_rx_stbc = msg->value;
3776 break;
3777 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3778 pe_session->htConfig.ht_sgi20 = msg->value;
3779 break;
3780 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3781 pe_session->htConfig.ht_sgi40 = msg->value;
3782 break;
3783 }
3784
3785 if (LIM_IS_AP_ROLE(pe_session)) {
3786 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3787 lim_send_beacon_ind(mac_ctx, pe_session);
3788 }
3789}
3790
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003791void
3792lim_send_vdev_restart(tpAniSirGlobal pMac,
3793 tpPESession psessionEntry, uint8_t sessionId)
3794{
3795 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003796 struct scheduler_msg msgQ = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003797 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003798
3799 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003800 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003801 return;
3802 }
3803
3804 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303805 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003806 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003807 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003808 return;
3809 }
3810
3811 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3812 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003813 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003814
3815 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3816 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3817 msgQ.bodyval = 0;
3818
3819 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003820 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003821 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303822 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003823 }
3824}
3825
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303826/**
3827 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3828 * @mac_ctx: Pointer to Global MAC structure
3829 * @msg_buf: Pointer to SME message buffer
3830 *
3831 * Return: None
3832 */
3833static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3834 uint32_t *msg_buf)
3835{
3836 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003837 struct scheduler_msg wma_msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003838 QDF_STATUS status;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303839 tSirRoamOffloadScanReq *req_buffer;
3840 uint16_t local_ie_len;
3841 uint8_t *local_ie_buf;
3842
3843 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3844 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3845 req_buffer->sessionId);
3846
3847 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3848 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003849 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303850 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303851 return;
3852 }
3853
3854 local_ie_len = req_buffer->assoc_ie.length;
3855 /* Update ext cap IE if present */
3856 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003857 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3858 local_ie_buf, &local_ie_len)) {
3859 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003860 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3861 req_buffer->assoc_ie.length = local_ie_len;
3862 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3863 local_ie_buf, local_ie_len);
3864 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303865 }
3866 qdf_mem_free(local_ie_buf);
3867
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303868 if (pe_session)
3869 lim_update_fils_rik(pe_session, req_buffer);
3870
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303871 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3872 wma_msg.bodyptr = req_buffer;
3873
3874 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003875 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003876 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303877 qdf_mem_free(req_buffer);
3878 }
3879}
3880
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303881/*
3882 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3883 * @mac_ctx: Pointer to global mac context
3884 * @session: Pointer to PE session
3885 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3886 * 1 - Disable broadcast SSID
3887 *
3888 * Return: None
3889 */
3890static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3891 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003892{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003893 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003894 session->ssidHidden, ssid_hidden);
3895
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003896 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303897 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003898 } else {
3899 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05303900 return;
3901 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003902
Abhishek Singh6c681f42018-09-12 15:52:36 +05303903#ifdef CONFIG_VDEV_SM
3904 ap_mlme_set_hidden_ssid_restart_in_progress(session->vdev, true);
3905 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3906 WLAN_VDEV_SM_EV_FW_VDEV_RESTART,
3907 sizeof(*session), session);
3908#else
3909
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003910 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303911 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Abhishek Singh6c681f42018-09-12 15:52:36 +05303912#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003913
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003914 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303915}
3916
3917/**
3918 * __lim_process_sme_session_update - process SME session update msg
3919 *
3920 * @mac_ctx: Pointer to global mac context
3921 * @msg_buf: Pointer to the received message buffer
3922 *
3923 * Return: None
3924 */
3925static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
3926 uint32_t *msg_buf)
3927{
3928 struct sir_update_session_param *msg;
3929 tpPESession session;
3930
3931 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003932 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303933 return;
3934 }
3935
3936 msg = (struct sir_update_session_param *) msg_buf;
3937
3938 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
3939 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003940 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303941 msg->session_id);
3942 return;
3943 }
3944
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003945 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303946 msg->param_type, msg->param_val);
3947 switch (msg->param_type) {
3948 case SIR_PARAM_SSID_HIDDEN:
3949 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
3950 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303951 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
3952 session->ignore_assoc_disallowed = msg->param_val;
3953 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303954 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003955 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303956 break;
3957 }
3958}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003959
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003960/*
3961 Update the beacon Interval dynamically if beaconInterval is different in MCC
3962 */
3963static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3964{
3965 tpSirChangeBIParams pChangeBIParams;
3966 tpPESession psessionEntry;
3967 uint8_t sessionId = 0;
3968 tUpdateBeaconParams beaconParams;
3969
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003970 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003971
3972 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003973 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003974 return;
3975 }
3976
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303977 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003978 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
3979
3980 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08003981 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003982 &sessionId);
3983 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003984 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003985 return;
3986 }
3987
3988 /*Update sessionEntry Beacon Interval */
3989 if (psessionEntry->beaconParams.beaconInterval !=
3990 pChangeBIParams->beaconInterval) {
3991 psessionEntry->beaconParams.beaconInterval =
3992 pChangeBIParams->beaconInterval;
3993 }
3994
3995 /*Update sch beaconInterval */
3996 if (pMac->sch.schObject.gSchBeaconInterval !=
3997 pChangeBIParams->beaconInterval) {
3998 pMac->sch.schObject.gSchBeaconInterval =
3999 pChangeBIParams->beaconInterval;
4000
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004001 pe_debug("LIM send update BeaconInterval Indication: %d",
4002 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004003
4004 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4005 /* Update beacon */
4006 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4007
4008 beaconParams.bssIdx = psessionEntry->bssIdx;
4009 /* Set change in beacon Interval */
4010 beaconParams.beaconInterval =
4011 pChangeBIParams->beaconInterval;
4012 beaconParams.paramChangeBitmap =
4013 PARAM_BCN_INTERVAL_CHANGED;
4014 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4015 }
4016 }
4017
4018 return;
4019} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4020
4021#ifdef QCA_HT_2040_COEX
4022static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4023 uint32_t *pMsgBuf)
4024{
4025 tpSirSetHT2040Mode pSetHT2040Mode;
4026 tpPESession psessionEntry;
4027 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004028 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004029 tUpdateVHTOpMode *pHtOpMode = NULL;
4030 uint16_t staId = 0;
4031 tpDphHashNode pStaDs = NULL;
4032
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004033 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004034 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004035 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004036 return;
4037 }
4038
4039 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4040
4041 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004042 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004043 &sessionId);
4044 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004045 pe_debug("Session does not exist for given BSSID");
4046 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004047 return;
4048 }
4049
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004050 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051 pSetHT2040Mode->cbMode);
4052 /*Update sessionEntry HT related fields */
4053 switch (pSetHT2040Mode->cbMode) {
4054 case PHY_SINGLE_CHANNEL_CENTERED:
4055 psessionEntry->htSecondaryChannelOffset =
4056 PHY_SINGLE_CHANNEL_CENTERED;
4057 psessionEntry->htRecommendedTxWidthSet = 0;
4058 if (pSetHT2040Mode->obssEnabled)
4059 psessionEntry->htSupportedChannelWidthSet
4060 = eHT_CHANNEL_WIDTH_40MHZ;
4061 else
4062 psessionEntry->htSupportedChannelWidthSet
4063 = eHT_CHANNEL_WIDTH_20MHZ;
4064 break;
4065 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4066 psessionEntry->htSecondaryChannelOffset =
4067 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4068 psessionEntry->htRecommendedTxWidthSet = 1;
4069 break;
4070 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4071 psessionEntry->htSecondaryChannelOffset =
4072 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4073 psessionEntry->htRecommendedTxWidthSet = 1;
4074 break;
4075 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004076 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004077 return;
4078 }
4079
4080 /* Update beacon */
4081 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4082 lim_send_beacon_ind(pMac, psessionEntry);
4083
4084 /* update OP Mode for each associated peer */
4085 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4086 pStaDs = dph_get_hash_entry(pMac, staId,
4087 &psessionEntry->dph.dphHashTable);
4088 if (NULL == pStaDs)
4089 continue;
4090
4091 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304092 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004093 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004094 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004095 return;
4096 }
4097 pHtOpMode->opMode =
4098 (psessionEntry->htSecondaryChannelOffset ==
4099 PHY_SINGLE_CHANNEL_CENTERED) ?
4100 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4101 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304102 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004103 sizeof(tSirMacAddr));
4104 pHtOpMode->smesessionId = sessionId;
4105
4106 msg.type = WMA_UPDATE_OP_MODE;
4107 msg.reserved = 0;
4108 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004109 if (!QDF_IS_STATUS_SUCCESS
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05304110 (scheduler_post_message(QDF_MODULE_ID_PE,
4111 QDF_MODULE_ID_WMA,
4112 QDF_MODULE_ID_WMA,
4113 &msg))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004114 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304115 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004116 return;
4117 }
Jeff Johnson47d75242018-05-12 15:58:53 -07004118 pe_debug("Notified FW about OP mode: %d for staId=%d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004119 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004120
4121 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004122 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004123 }
4124
4125 return;
4126}
4127#endif
4128
4129/* -------------------------------------------------------------------- */
4130/**
4131 * __lim_process_report_message
4132 *
4133 * FUNCTION: Processes the next received Radio Resource Management message
4134 *
4135 * LOGIC:
4136 *
4137 * ASSUMPTIONS:
4138 *
4139 * NOTE:
4140 *
4141 * @param None
4142 * @return None
4143 */
4144
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004145static void __lim_process_report_message(tpAniSirGlobal pMac,
4146 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004147{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004148 switch (pMsg->type) {
4149 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4150 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4151 break;
4152 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004153 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004154 break;
4155 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004156 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004157 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004158}
4159
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004160/* -------------------------------------------------------------------- */
4161/**
4162 * lim_send_set_max_tx_power_req
4163 *
4164 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4165 *
4166 * LOGIC:
4167 *
4168 * ASSUMPTIONS:
4169 *
4170 * NOTE:
4171 *
4172 * @param txPower txPower to be set.
4173 * @param pSessionEntry session entry.
4174 * @return None
4175 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004176QDF_STATUS
Amar Singhala297bfa2015-10-15 15:07:29 -07004177lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004178 tpPESession pSessionEntry)
4179{
4180 tpMaxTxPowerParams pMaxTxParams = NULL;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004181 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004182 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004183
4184 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004185 pe_err("Invalid parameters");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004186 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004187 }
4188
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304189 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004190 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004191 pe_err("Unable to allocate memory for pMaxTxParams");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004192 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004193
4194 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004195 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304196 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304197 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304198 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004199 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304200 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201
4202 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4203 msgQ.bodyptr = pMaxTxParams;
4204 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004205 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004206 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4207 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004208 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004209 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304210 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004211 }
4212 return retCode;
4213}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004214
4215/**
4216 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4217 *
4218 * @mac_ctx: Pointer to Global MAC structure
4219 * @msg_buf: pointer to the SME message buffer
4220 *
4221 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4222 * from SME. It Register this information within PE.
4223 *
4224 * Return: None
4225 */
4226static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4227 uint32_t *msg_buf)
4228{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304229 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004230 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4231 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4232 struct mgmt_frm_reg_info *next = NULL;
4233 bool match = false;
4234
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004235 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004236 sme_req->registerFrame, sme_req->frameType,
4237 sme_req->matchLen);
4238 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304239 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304240 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4241 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304242 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004243
4244 while (lim_mgmt_regn != NULL) {
4245 if (lim_mgmt_regn->frameType != sme_req->frameType)
4246 goto skip_match;
4247 if (sme_req->matchLen) {
4248 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304249 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004250 sme_req->matchData,
4251 lim_mgmt_regn->matchLen))) {
4252 /* found match! */
4253 match = true;
4254 break;
4255 }
4256 } else {
4257 /* found match! */
4258 match = true;
4259 break;
4260 }
4261skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304262 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304263 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004264 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304265 (qdf_list_node_t *)lim_mgmt_regn,
4266 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304267 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004268 lim_mgmt_regn = next;
4269 next = NULL;
4270 }
4271 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304272 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004273 if (QDF_STATUS_SUCCESS ==
4274 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004275 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004276 (qdf_list_node_t *)lim_mgmt_regn))
4277 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304278 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004279 }
4280
4281 if (sme_req->registerFrame) {
4282 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304283 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004284 sme_req->matchLen);
4285 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004286 lim_mgmt_regn->frameType = sme_req->frameType;
4287 lim_mgmt_regn->matchLen = sme_req->matchLen;
4288 lim_mgmt_regn->sessionId = sme_req->sessionId;
4289 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304290 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004291 sme_req->matchData,
4292 sme_req->matchLen);
4293 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304294 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004295 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304296 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004297 gLimMgmtFrameRegistratinQueue,
4298 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304299 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004300 &mac_ctx->lim.lim_frame_register_lock);
4301 }
4302 }
4303 return;
4304}
4305
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004306static void
4307__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4308{
4309 tpSirResetAPCapsChange pResetCapsChange;
4310 tpPESession psessionEntry;
4311 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004312
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004313 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004314 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004315 return;
4316 }
4317
4318 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4319 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004320 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4321 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004322 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004323 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004324 return;
4325 }
4326
4327 psessionEntry->limSentCapsChangeNtf = false;
4328 return;
4329}
4330
4331/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304332 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4333 * indication callback in PE.
4334 * @mac_ptr: Mac pointer
4335 * @msg_buf: Msg pointer containing the callback
4336 *
4337 * This function is used save the Management frame
4338 * indication callback in PE.
4339 *
4340 * Return: None
4341 */
4342static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4343 uint32_t *msg_buf)
4344{
4345 struct sir_sme_mgmt_frame_cb_req *sme_req =
4346 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4347
4348 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004349 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304350 return;
4351 }
4352 if (sme_req->callback)
4353 mac_ctx->mgmt_frame_ind_cb =
4354 (sir_mgmt_frame_ind_callback)sme_req->callback;
4355 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004356 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304357}
4358
4359/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304360 *__lim_process_send_disassoc_frame: function processes disassoc frame
4361 * @mac_ctx: pointer to mac context
4362 * @msg_buf: message buffer
4363 *
4364 * function processes disassoc request received from SME
4365 *
4366 * return: none
4367 */
4368static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4369 uint32_t *msg_buf)
4370{
4371 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004372 QDF_STATUS status;
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304373 tpPESession session_entry = NULL;
4374 uint8_t sme_session_id;
4375 uint16_t sme_trans_id;
4376
4377 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004378 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304379 return;
4380 }
4381
4382 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4383 &sme_trans_id);
4384
4385 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4386 &sme_send_disassoc_frame_req,
4387 (uint8_t *)msg_buf);
4388
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004389 if ((QDF_STATUS_E_FAILURE == status) ||
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304390 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4391 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004392 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304393 return;
4394 }
4395
4396 session_entry = pe_find_session_by_sme_session_id(
4397 mac_ctx, sme_session_id);
4398 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004399 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304400 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4401 return;
4402 }
4403
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004404 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 +05304405 sme_send_disassoc_frame_req.msg_type,
4406 sme_send_disassoc_frame_req.length,
4407 sme_send_disassoc_frame_req.session_id,
4408 sme_send_disassoc_frame_req.trans_id,
4409 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4410 sme_send_disassoc_frame_req.reason,
4411 sme_send_disassoc_frame_req.wait_for_ack);
4412
4413 lim_send_disassoc_mgmt_frame(mac_ctx,
4414 sme_send_disassoc_frame_req.reason,
4415 sme_send_disassoc_frame_req.peer_mac,
4416 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4417}
4418
4419/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004420 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4421 * @mac_ctx: Pointer to Global MAC structure
4422 * @pdev_id: pdev id to set the IE.
4423 * @nss: Nss values to prepare the HT IE.
4424 *
4425 * Prepares the HT IE with self capabilities for different
4426 * Nss values and sends the set HT IE req to FW.
4427 *
4428 * Return: None
4429 */
4430static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4431 uint8_t nss)
4432{
4433 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004434 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004435 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004436 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004437 tHtCaps *p_ht_cap;
4438 int i;
4439
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004440 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004441 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4442 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004443 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004444 return;
4445 }
4446 ie_params->nss = i;
4447 ie_params->pdev_id = pdev_id;
4448 ie_params->ie_type = DOT11_HT_IE;
4449 /* 2 for IE len and EID */
4450 ie_params->ie_len = 2 + sizeof(tHtCaps);
4451 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4452 if (NULL == ie_params->ie_ptr) {
4453 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004454 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004455 return;
4456 }
4457 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4458 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4459 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4460 ie_params->ie_len);
4461
4462 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004463 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4464 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004465 if (NULL == p_ie) {
4466 qdf_mem_free(ie_params->ie_ptr);
4467 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004468 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004469 return;
4470 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004471 p_ht_cap = (tHtCaps *)&p_ie[2];
4472 p_ht_cap->supportedMCSSet[1] = 0;
4473 p_ht_cap->txSTBC = 0;
4474 }
4475
4476 msg.type = WMA_SET_PDEV_IE_REQ;
4477 msg.bodyptr = ie_params;
4478 msg.bodyval = 0;
4479
4480 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004481 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004482 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004483 qdf_mem_free(ie_params->ie_ptr);
4484 qdf_mem_free(ie_params);
4485 return;
4486 }
4487 }
4488}
4489
4490/**
4491 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4492 * @mac_ctx: Pointer to Global MAC structure
4493 * @pdev_id: pdev id to set the IE.
4494 * @nss: Nss values to prepare the VHT IE.
4495 *
4496 * Prepares the VHT IE with self capabilities for different
4497 * Nss values and sends the set VHT IE req to FW.
4498 *
4499 * Return: None
4500 */
4501static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4502 uint8_t nss)
4503{
4504 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004505 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004506 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004507 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004508 tSirMacVHTCapabilityInfo *vht_cap;
4509 int i;
4510 tSirVhtMcsInfo *vht_mcs;
4511
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004512 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004513 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4514 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004515 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004516 return;
4517 }
4518 ie_params->nss = i;
4519 ie_params->pdev_id = pdev_id;
4520 ie_params->ie_type = DOT11_VHT_IE;
4521 /* 2 for IE len and EID */
4522 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4523 sizeof(tSirVhtMcsInfo);
4524 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4525 if (NULL == ie_params->ie_ptr) {
4526 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004527 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004528 return;
4529 }
4530 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4531 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4532 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4533 ie_params->ie_len);
4534
4535 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004536 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4537 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004538 if (NULL == p_ie) {
4539 qdf_mem_free(ie_params->ie_ptr);
4540 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004541 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004542 return;
4543 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004544 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4545 vht_cap->txSTBC = 0;
4546 vht_mcs =
4547 (tSirVhtMcsInfo *)&p_ie[2 +
4548 sizeof(tSirMacVHTCapabilityInfo)];
4549 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4550 vht_mcs->rxHighest =
4551 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4552 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4553 vht_mcs->txHighest =
4554 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4555 }
4556 msg.type = WMA_SET_PDEV_IE_REQ;
4557 msg.bodyptr = ie_params;
4558 msg.bodyval = 0;
4559
4560 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004561 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004562 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004563 qdf_mem_free(ie_params->ie_ptr);
4564 qdf_mem_free(ie_params);
4565 return;
4566 }
4567 }
4568}
4569
4570/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004571 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4572 * @mac_ctx: Pointer to Global MAC structure
4573 * @msg_buf: Pointer to the SME message buffer
4574 *
4575 * This function is called by limProcessMessageQueue(). This function sets the
4576 * VDEV IEs to the FW.
4577 *
4578 * Return: None
4579 */
4580static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4581 uint32_t *msg_buf)
4582{
4583 struct sir_set_vdev_ies_per_band *p_msg =
4584 (struct sir_set_vdev_ies_per_band *)msg_buf;
4585
4586 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004587 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004588 return;
4589 }
4590
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004591 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004592 p_msg->vdev_id);
4593 /* intentionally using NULL here so that self capabilty are sent */
4594 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4595 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004596 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004597}
4598
4599/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004600 * lim_process_set_pdev_IEs() - process the set pdev IE req
4601 * @mac_ctx: Pointer to Global MAC structure
4602 * @msg_buf: Pointer to the SME message buffer
4603 *
4604 * This function is called by limProcessMessageQueue(). This
4605 * function sets the PDEV IEs to the FW.
4606 *
4607 * Return: None
4608 */
4609static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4610{
4611 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4612
4613 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4614
4615 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004616 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004617 return;
4618 }
4619
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004620 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004621 ht_vht_cfg->nss);
4622 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4623
4624 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4625 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4626 ht_vht_cfg->nss);
4627}
4628
4629/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304630 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4631 *
4632 * access policy
4633 * @mac_ctx: pointer to mac context
4634 * @msg: message buffer
4635 *
4636 * function processes vendor IE and access policy from SME and updates PE
4637 *
4638 * session entry
4639 *
4640 * return: none
4641*/
4642static void lim_process_sme_update_access_policy_vendor_ie(
4643 tpAniSirGlobal mac_ctx,
4644 uint32_t *msg)
4645{
4646 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4647 struct sPESession *pe_session_entry;
Pragaspathi Thilagaraj9b7a1162018-05-07 16:28:13 +05304648 uint16_t num_bytes;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304649
4650 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004651 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304652 return;
4653 }
4654 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4655 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4656 update_vendor_ie->sme_session_id);
4657
4658 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004659 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304660 update_vendor_ie->sme_session_id);
4661 return;
4662 }
4663 if (pe_session_entry->access_policy_vendor_ie)
4664 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4665
4666 num_bytes = update_vendor_ie->ie[1] + 2;
4667 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4668
4669 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004670 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304671 return;
4672 }
4673 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4674 &update_vendor_ie->ie[0], num_bytes);
4675
4676 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4677}
4678
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004679#ifdef CONFIG_VDEV_SM
4680QDF_STATUS lim_sta_mlme_vdev_disconnect_bss(struct vdev_mlme_obj *vdev_mlme,
4681 uint16_t data_len, void *data)
4682{
4683 tpAniSirGlobal mac_ctx;
4684 struct scheduler_msg *msg = (struct scheduler_msg *)data;
4685
4686 mac_ctx = cds_get_context(QDF_MODULE_ID_PE);
4687 if (!mac_ctx) {
4688 pe_err("mac_ctx is NULL");
4689 if (data)
4690 qdf_mem_free(data);
4691 return QDF_STATUS_E_INVAL;
4692 }
4693 pe_debug("VDEV Manager disconnect bss callback type:(%d)", msg->type);
4694
4695 switch (msg->type) {
4696 case eWNI_SME_DEAUTH_REQ:
4697 __lim_process_sme_deauth_req(mac_ctx,
4698 (uint32_t *)msg->bodyptr);
4699 break;
4700 case eWNI_SME_DISASSOC_CNF:
4701 case eWNI_SME_DEAUTH_CNF:
4702 __lim_process_sme_disassoc_cnf(mac_ctx,
4703 (uint32_t *)msg->bodyptr);
4704 break;
4705 case eWNI_SME_DISASSOC_REQ:
4706 __lim_process_sme_disassoc_req(mac_ctx,
4707 (uint32_t *)msg->bodyptr);
4708 break;
4709 default:
4710 pe_debug("Wrong message type received %d", msg->type);
4711 }
4712 return QDF_STATUS_SUCCESS;
4713}
4714#endif
4715
4716static void lim_process_sme_disassoc_cnf(tpAniSirGlobal mac_ctx,
4717 struct scheduler_msg *msg)
4718{
4719#ifdef CONFIG_VDEV_SM
4720 tSirSmeDisassocCnf sme_disassoc_cnf;
4721 tpPESession session;
4722 uint8_t session_id;
4723 QDF_STATUS status;
4724
4725 qdf_mem_copy(&sme_disassoc_cnf, msg->bodyptr,
4726 sizeof(struct sSirSmeDisassocCnf));
4727
4728 session = pe_find_session_by_bssid(mac_ctx,
4729 sme_disassoc_cnf.bssid.bytes,
4730 &session_id);
4731
4732 if (LIM_IS_STA_ROLE(session)) {
4733 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4734 WLAN_VDEV_SM_EV_DOWN,
4735 sizeof(*msg),
4736 msg);
4737 } else {
4738 __lim_process_sme_disassoc_cnf(mac_ctx,
4739 (uint32_t *)msg->bodyptr);
4740 }
4741#else
4742 __lim_process_sme_disassoc_cnf(mac_ctx, (uint32_t *)msg->bodyptr);
4743#endif
4744}
4745
4746static void lim_process_sme_disassoc_req(tpAniSirGlobal mac_ctx,
4747 struct scheduler_msg *msg)
4748{
4749#ifdef CONFIG_VDEV_SM
4750 tSirSmeDisassocReq disassoc_req;
4751 tpPESession session;
4752 uint8_t session_id;
4753 QDF_STATUS status;
4754
4755 qdf_mem_copy(&disassoc_req, msg->bodyptr, sizeof(tSirSmeDisassocReq));
4756
4757 session = pe_find_session_by_bssid(mac_ctx,
4758 disassoc_req.bssid.bytes,
4759 &session_id);
4760 if (LIM_IS_STA_ROLE(session)) {
4761 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4762 WLAN_VDEV_SM_EV_DOWN,
4763 sizeof(*msg),
4764 msg);
4765 } else {
4766 __lim_process_sme_disassoc_req(mac_ctx,
4767 (uint32_t *)msg->bodyptr);
4768 }
4769#else
4770 __lim_process_sme_disassoc_req(mac_ctx, (uint32_t *)msg->bodyptr);
4771#endif
4772}
4773
4774static void lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
4775 struct scheduler_msg *msg)
4776{
4777#ifdef CONFIG_VDEV_SM
4778 tSirSmeDeauthReq sme_deauth_req;
4779 tpPESession session;
4780 uint8_t session_id;
4781 QDF_STATUS status;
4782
4783 qdf_mem_copy(&sme_deauth_req, msg->bodyptr, sizeof(tSirSmeDeauthReq));
4784
4785 session = pe_find_session_by_bssid(mac_ctx,
4786 sme_deauth_req.bssid.bytes,
4787 &session_id);
4788 if (LIM_IS_STA_ROLE(session)) {
4789 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4790 WLAN_VDEV_SM_EV_DOWN,
4791 sizeof(*msg),
4792 msg);
4793 } else {
4794 __lim_process_sme_deauth_req(mac_ctx,
4795 (uint32_t *)msg->bodyptr);
4796 }
4797#else
4798 __lim_process_sme_deauth_req(mac_ctx, (uint32_t *)msg->bodyptr);
4799#endif
4800}
4801
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304802/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004803 * lim_process_sme_req_messages()
4804 *
4805 ***FUNCTION:
4806 * This function is called by limProcessMessageQueue(). This
4807 * function processes SME request messages from HDD or upper layer
4808 * application.
4809 *
4810 ***LOGIC:
4811 *
4812 ***ASSUMPTIONS:
4813 *
4814 ***NOTE:
4815 *
4816 * @param pMac Pointer to Global MAC structure
4817 * @param msgType Indicates the SME message type
4818 * @param *pMsgBuf A pointer to the SME message buffer
4819 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4820 * false - if pMsgBuf is not to be freed.
4821 */
4822
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004823bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4824 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004825{
Jeff Johnson33142e62018-05-06 17:58:36 -07004826 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 -08004827 uint32_t *pMsgBuf = pMsg->bodyptr;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004828
4829 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004830 lim_msg_str(pMsg->type), pMsg->type,
4831 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4832 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004833
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004834 /* If no insert NOA required then execute the code below */
4835
4836 switch (pMsg->type) {
4837 case eWNI_SME_SYS_READY_IND:
4838 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4839 break;
4840
4841 case eWNI_SME_START_BSS_REQ:
4842 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4843 break;
4844
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004845 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4846 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4847 break;
4848 case eWNI_SME_JOIN_REQ:
4849 __lim_process_sme_join_req(pMac, pMsgBuf);
4850 break;
4851
4852 case eWNI_SME_REASSOC_REQ:
4853 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4854 break;
4855
4856 case eWNI_SME_DISASSOC_REQ:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004857 lim_process_sme_disassoc_req(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004858 break;
4859
4860 case eWNI_SME_DISASSOC_CNF:
4861 case eWNI_SME_DEAUTH_CNF:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004862 lim_process_sme_disassoc_cnf(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004863 break;
4864
4865 case eWNI_SME_DEAUTH_REQ:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004866 lim_process_sme_deauth_req(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004867 break;
4868
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304869 case eWNI_SME_SEND_DISASSOC_FRAME:
4870 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4871 break;
4872
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004873 case eWNI_SME_SETCONTEXT_REQ:
4874 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4875 break;
4876
4877 case eWNI_SME_STOP_BSS_REQ:
4878 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4879 break;
4880
4881 case eWNI_SME_ASSOC_CNF:
4882 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004883 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004884 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4885 pMsgBuf);
4886 break;
4887
4888 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004889 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004890 __lim_process_sme_addts_req(pMac, pMsgBuf);
4891 break;
4892
4893 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004894 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004895 __lim_process_sme_delts_req(pMac, pMsgBuf);
4896 break;
4897
4898 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004899 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004900 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4901 break;
4902
4903 case eWNI_SME_GET_STATISTICS_REQ:
4904 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4905 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4906 bufConsumed = false;
4907 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004908#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004909 case eWNI_SME_GET_TSM_STATS_REQ:
4910 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4911 bufConsumed = false;
4912 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004913#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004914 case eWNI_SME_GET_ASSOC_STAS_REQ:
4915 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4916 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304917 case eWNI_SME_SESSION_UPDATE_PARAM:
4918 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004919 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304920 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4921 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4922 bufConsumed = false;
4923 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004924 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4925 /* Update the beaconInterval */
4926 __lim_process_sme_change_bi(pMac, pMsgBuf);
4927 break;
4928
4929#ifdef QCA_HT_2040_COEX
4930 case eWNI_SME_SET_HT_2040_MODE:
4931 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4932 break;
4933#endif
4934
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004935 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4936 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4937 __lim_process_report_message(pMac, pMsg);
4938 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004939
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004940 case eWNI_SME_FT_PRE_AUTH_REQ:
4941 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4942 break;
4943 case eWNI_SME_FT_UPDATE_KEY:
4944 lim_process_ft_update_key(pMac, pMsgBuf);
4945 break;
4946
4947 case eWNI_SME_FT_AGGR_QOS_REQ:
4948 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4949 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004950
4951 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4952 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4953 break;
4954#ifdef FEATURE_WLAN_TDLS
4955 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4956 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4957 break;
4958 case eWNI_SME_TDLS_ADD_STA_REQ:
4959 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4960 break;
4961 case eWNI_SME_TDLS_DEL_STA_REQ:
4962 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4963 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004964#endif
4965 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4966 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4967 break;
4968
4969 case eWNI_SME_CHANNEL_CHANGE_REQ:
4970 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4971 break;
4972
4973 case eWNI_SME_START_BEACON_REQ:
4974 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4975 break;
4976
4977 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4978 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4979 break;
4980
4981 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4982 lim_process_update_add_ies(pMac, pMsgBuf);
4983 break;
4984
4985 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4986 lim_process_modify_add_ies(pMac, pMsgBuf);
4987 break;
4988 case eWNI_SME_SET_HW_MODE_REQ:
4989 lim_process_set_hw_mode(pMac, pMsgBuf);
4990 break;
4991 case eWNI_SME_NSS_UPDATE_REQ:
4992 lim_process_nss_update_request(pMac, pMsgBuf);
4993 break;
4994 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4995 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4996 break;
4997 case eWNI_SME_SET_IE_REQ:
4998 lim_process_set_ie_req(pMac, pMsgBuf);
4999 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305000 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5001 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5002 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305003 case eWNI_SME_EXT_CHANGE_CHANNEL:
5004 lim_process_ext_change_channel(pMac, pMsgBuf);
5005 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005006 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5007 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5008 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005009 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5010 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005011 break;
5012 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5013 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5014 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305015 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5016 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5017 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07005018 case eWNI_SME_UPDATE_CONFIG:
5019 lim_process_sme_update_config(pMac,
5020 (struct update_config *)pMsgBuf);
5021 break;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08005022 case eWNI_SME_SET_ADDBA_ACCEPT:
5023 lim_process_sme_set_addba_accept(pMac,
5024 (struct sme_addba_accept *)pMsgBuf);
5025 break;
Arif Hussaineb8ba362018-03-07 19:15:13 -08005026 case eWNI_SME_UPDATE_EDCA_PROFILE:
5027 lim_process_sme_update_edca_params(pMac, pMsg->bodyval);
5028 break;
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07005029 case WNI_SME_UPDATE_MU_EDCA_PARAMS:
5030 lim_process_sme_update_mu_edca_params(pMac, pMsg->bodyval);
5031 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005032 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305033 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005034 pMsg->bodyptr = NULL;
5035 break;
5036 } /* switch (msgType) */
5037
5038 return bufConsumed;
5039} /*** end lim_process_sme_req_messages() ***/
5040
5041/**
5042 * lim_process_sme_start_beacon_req()
5043 *
5044 ***FUNCTION:
5045 * This function is called by limProcessMessageQueue(). This
5046 * function processes SME request messages from HDD or upper layer
5047 * application.
5048 *
5049 ***LOGIC:
5050 *
5051 ***ASSUMPTIONS:
5052 *
5053 ***NOTE:
5054 *
5055 * @param pMac Pointer to Global MAC structure
5056 * @param msgType Indicates the SME message type
5057 * @param *pMsgBuf A pointer to the SME message buffer
5058 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5059 * false - if pMsgBuf is not to be freed.
5060 */
5061static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5062{
5063 tpSirStartBeaconIndication pBeaconStartInd;
5064 tpPESession psessionEntry;
5065 uint8_t sessionId; /* PE sessionID */
5066
5067 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005068 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005069 return;
5070 }
5071
5072 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5073 psessionEntry = pe_find_session_by_bssid(pMac,
5074 pBeaconStartInd->bssid,
5075 &sessionId);
5076 if (psessionEntry == NULL) {
5077 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005078 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005079 return;
5080 }
5081
5082 if (pBeaconStartInd->beaconStartStatus == true) {
5083 /*
5084 * Currently this Indication comes from SAP
5085 * to start Beacon Tx on a DFS channel
5086 * since beaconing has to be done on DFS
5087 * channel only after CAC WAIT is completed.
5088 * On a DFS Channel LIM does not start beacon
5089 * Tx right after the WMA_ADD_BSS_RSP.
5090 */
5091 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05305092 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005093 FL("Start Beacon with ssid %s Ch %d"),
5094 psessionEntry->ssId.ssId,
5095 psessionEntry->currentOperChannel);
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05305096 lim_send_beacon(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08005097 lim_enable_obss_detection_config(pMac, psessionEntry);
Arif Hussain05fb4872018-01-03 16:02:55 -08005098 lim_send_obss_color_collision_cfg(pMac, psessionEntry,
5099 OBSS_COLOR_COLLISION_DETECTION);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005100 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005101 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005102 return;
5103 }
5104}
5105
5106/**
5107 * lim_process_sme_channel_change_request() - process sme ch change req
5108 *
5109 * @mac_ctx: Pointer to Global MAC structure
5110 * @msg_buf: pointer to the SME message buffer
5111 *
5112 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5113 *
5114 * Return: None
5115 */
5116static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5117 uint32_t *msg_buf)
5118{
5119 tpSirChanChangeRequest ch_change_req;
5120 tpPESession session_entry;
5121 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005122 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005123 uint32_t val = 0;
5124
5125 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005126 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005127 return;
5128 }
5129 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5130
5131 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5132 ch_change_req->targetChannel);
5133
5134 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5135 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005136 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005137 return;
5138 }
5139
5140 session_entry = pe_find_session_by_bssid(mac_ctx,
5141 ch_change_req->bssid, &session_id);
5142 if (session_entry == NULL) {
5143 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005144 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005145 return;
5146 }
5147
Manjunathappa Prakash34fda792018-02-07 18:23:42 -08005148 if ((session_entry->currentOperChannel ==
5149 ch_change_req->targetChannel) &&
5150 (session_entry->ch_width == ch_change_req->ch_width)) {
5151 pe_err("Target channel and mode is same as current channel and mode channel %d and mode %d",
5152 session_entry->currentOperChannel, session_entry->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005153 return;
5154 }
5155
5156 if (LIM_IS_AP_ROLE(session_entry))
5157 session_entry->channelChangeReasonCode =
5158 LIM_SWITCH_CHANNEL_SAP_DFS;
5159 else
5160 session_entry->channelChangeReasonCode =
5161 LIM_SWITCH_CHANNEL_OPERATION;
5162
Bala Venkateshb39ed152017-12-26 19:35:27 +05305163 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d, nw_type %d, dot11mode %d",
5164 session_entry->currentOperChannel,
5165 ch_change_req->targetChannel,
5166 ch_change_req->ch_width,
5167 ch_change_req->nw_type,
5168 ch_change_req->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005169
5170 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005171 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005172 session_entry->ch_center_freq_seg0 =
5173 ch_change_req->center_freq_seg_0;
5174 session_entry->ch_center_freq_seg1 =
5175 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005176 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005177 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005178 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005179 session_entry->htRecommendedTxWidthSet =
5180 session_entry->htSupportedChannelWidthSet;
5181 session_entry->currentOperChannel =
5182 ch_change_req->targetChannel;
5183 session_entry->limRFBand =
5184 lim_get_rf_band(session_entry->currentOperChannel);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305185 session_entry->cac_duration_ms = ch_change_req->cac_duration_ms;
5186 session_entry->dfs_regdomain = ch_change_req->dfs_regdomain;
5187 session_entry->maxTxPower = max_tx_pwr;
Vignesh Viswanathan153ae932018-04-11 14:24:13 +05305188
5189 /* Update the global beacon filter */
5190 lim_update_bcn_probe_filter(mac_ctx, session_entry);
5191
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005192 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08005193 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005194 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005195 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005196 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005197 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005198 }
5199
5200 session_entry->lim11hEnable = val;
5201 session_entry->dot11mode = ch_change_req->dot11mode;
Bala Venkateshb39ed152017-12-26 19:35:27 +05305202 session_entry->nwType = ch_change_req->nw_type;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305203 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005204 &ch_change_req->operational_rateset,
5205 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305206 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005207 &ch_change_req->extended_rateset,
5208 sizeof(session_entry->extRateSet));
Abhishek Singh20a8e442018-09-12 15:50:44 +05305209
5210#ifdef CONFIG_VDEV_SM
Abhishek Singha063f1c2018-09-19 11:37:51 +05305211 mlme_set_chan_switch_in_progress(session_entry->vdev, true);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305212 if (wlan_vdev_mlme_get_state(session_entry->vdev) ==
5213 WLAN_VDEV_S_DFS_CAC_WAIT)
5214 wlan_vdev_mlme_sm_deliver_evt(session_entry->vdev,
5215 WLAN_VDEV_SM_EV_RADAR_DETECTED,
5216 sizeof(*session_entry),
5217 session_entry);
5218 else
5219 wlan_vdev_mlme_sm_deliver_evt(session_entry->vdev,
5220 WLAN_VDEV_SM_EV_CSA_COMPLETE,
5221 sizeof(*session_entry),
5222 session_entry);
5223
5224
5225#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005226 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5227 session_entry->ch_center_freq_seg0,
5228 session_entry->ch_center_freq_seg1,
5229 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07005230 max_tx_pwr, session_entry->peSessionId,
5231 ch_change_req->cac_duration_ms,
5232 ch_change_req->dfs_regdomain);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305233#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005234}
5235
5236/******************************************************************************
5237* lim_start_bss_update_add_ie_buffer()
5238*
5239***FUNCTION:
5240* This function checks the src buffer and its length and then malloc for
5241* dst buffer update the same
5242*
5243***LOGIC:
5244*
5245***ASSUMPTIONS:
5246*
5247***NOTE:
5248*
5249* @param pMac Pointer to Global MAC structure
5250* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5251* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5252* @param *pSrcData_buff A pointer of uint8_t src buffer
5253* @param srcDataLen src buffer length
5254******************************************************************************/
5255
5256static void
5257lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5258 uint8_t **pDstData_buff,
5259 uint16_t *pDstDataLen,
5260 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5261{
5262
5263 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5264 *pDstDataLen = srcDataLen;
5265
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305266 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005267
5268 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005269 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005270 return;
5271 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305272 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005273 } else {
5274 *pDstData_buff = NULL;
5275 *pDstDataLen = 0;
5276 }
5277}
5278
5279/******************************************************************************
5280* lim_update_add_ie_buffer()
5281*
5282***FUNCTION:
5283* This function checks the src buffer and length if src buffer length more
5284* than dst buffer length then free the dst buffer and malloc for the new src
5285* length, and update the dst buffer and length. But if dst buffer is bigger
5286* than src buffer length then it just update the dst buffer and length
5287*
5288***LOGIC:
5289*
5290***ASSUMPTIONS:
5291*
5292***NOTE:
5293*
5294* @param pMac Pointer to Global MAC structure
5295* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5296* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5297* @param *pSrcData_buff A pointer of uint8_t src buffer
5298* @param srcDataLen src buffer length
5299******************************************************************************/
5300
5301static void
5302lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5303 uint8_t **pDstData_buff,
5304 uint16_t *pDstDataLen,
5305 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5306{
5307
5308 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005309 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005310 return;
5311 }
5312
5313 if (srcDataLen > *pDstDataLen) {
5314 *pDstDataLen = srcDataLen;
5315 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305316 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005317 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305318 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005319
5320 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005321 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005322 *pDstDataLen = 0;
5323 return;
5324 }
5325 }
5326
5327 /* copy the content of buffer into dst buffer
5328 */
5329 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305330 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005331
5332}
5333
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005334/**
5335 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5336 * @pMac : Pointer to Global MAC structure
5337 * @pDstData_buff : A pointer to pointer of dst buffer
5338 * @pDstDataLen : A pointer to pointer of dst buffer length
5339 * @pModifyIE : A pointer to tSirModifyIE
5340 *
5341 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5342 *
5343 * Return:
5344 * True or false depending upon whether IE is updated or not
5345 */
5346static bool
5347lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5348 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5349{
Hong Shi1553d692016-09-28 12:16:19 +08005350 int32_t oui_length;
5351 uint8_t *ibss_ie = NULL;
5352 uint8_t *vendor_ie;
5353#define MAC_VENDOR_OUI "\x00\x16\x32"
5354#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005355
5356 ibss_ie = pModifyIE->pIEBuffer;
5357 oui_length = pModifyIE->oui_length;
5358
5359 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005360 pe_err("Invalid set IBSS vendor IE command length %d",
5361 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005362 return false;
5363 }
5364
Hong Shi1553d692016-09-28 12:16:19 +08005365 /*
5366 * Why replace only beacon OUI data here:
5367 * 1. other ie (such as wpa) shall not be overwritten here.
5368 * 2. per spec, beacon oui ie might be set twice and original one
5369 * shall be updated.
5370 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005371 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005372 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5373 if (vendor_ie) {
5374 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5375 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5376 pModifyIE->ieBufferlength);
5377 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005378 uint16_t new_length;
5379 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005380
Naveen Rawat668dee32017-09-29 14:39:40 -07005381 /*
5382 * check for uint16 overflow before using sum of two numbers as
5383 * length of size to malloc
5384 */
5385 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5386 pe_err("U16 overflow due to %d + %d",
5387 pModifyIE->ieBufferlength, *pDstDataLen);
5388 return false;
5389 }
5390
5391 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5392 new_ptr = qdf_mem_malloc(new_length);
Hong Shi1553d692016-09-28 12:16:19 +08005393 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005394 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005395 return false;
5396 }
5397 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5398 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5399 pModifyIE->ieBufferlength);
5400 qdf_mem_free(*pDstData_buff);
5401 *pDstDataLen = new_length;
5402 *pDstData_buff = new_ptr;
5403 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005404 return true;
5405}
5406
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005407/*
5408* lim_process_modify_add_ies() - process modify additional IE req.
5409*
5410* @mac_ctx: Pointer to Global MAC structure
5411* @msg_buf: pointer to the SME message buffer
5412*
5413* This function update the PE buffers for additional IEs.
5414*
5415* Return: None
5416*/
5417static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5418 uint32_t *msg_buf)
5419{
5420 tpSirModifyIEsInd modify_add_ies;
5421 tpPESession session_entry;
5422 uint8_t session_id;
5423 bool ret = false;
5424 tSirAddIeParams *add_ie_params;
5425
5426 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005427 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005428 return;
5429 }
5430
5431 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5432 /* Incoming message has smeSession, use BSSID to find PE session */
5433 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005434 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005435
5436 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005437 pe_err("Session not found for given bssid"
5438 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005439 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005440 goto end;
5441 }
5442 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5443 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5444 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005445 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005446 modify_add_ies->modifyIE.pIEBuffer,
5447 modify_add_ies->modifyIE.ieBufferlength,
5448 modify_add_ies->modifyIE.ieID,
5449 modify_add_ies->modifyIE.ieIDLen,
5450 modify_add_ies->updateType);
5451 goto end;
5452 }
5453 add_ie_params = &session_entry->addIeParams;
5454 switch (modify_add_ies->updateType) {
5455 case eUPDATE_IE_PROBE_RESP:
5456 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005457 if (LIM_IS_IBSS_ROLE(session_entry)) {
5458 lim_update_ibss_prop_add_ies(mac_ctx,
5459 &add_ie_params->probeRespData_buff,
5460 &add_ie_params->probeRespDataLen,
5461 &modify_add_ies->modifyIE);
5462 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005463 break;
5464 case eUPDATE_IE_ASSOC_RESP:
5465 /* assoc resp IE */
5466 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305467 QDF_TRACE(QDF_MODULE_ID_PE,
5468 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005469 "assoc resp add ie not present %d"),
5470 add_ie_params->assocRespDataLen);
5471 }
5472 /* search through the buffer and modify the IE */
5473 break;
5474 case eUPDATE_IE_PROBE_BCN:
5475 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005476 if (LIM_IS_IBSS_ROLE(session_entry)) {
5477 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5478 &add_ie_params->probeRespBCNData_buff,
5479 &add_ie_params->probeRespBCNDataLen,
5480 &modify_add_ies->modifyIE);
5481 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005482 if (ret == true && modify_add_ies->modifyIE.notify) {
5483 lim_handle_param_update(mac_ctx,
5484 modify_add_ies->updateType);
5485 }
5486 break;
5487 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005488 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005489 modify_add_ies->updateType);
5490 break;
5491 }
5492end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305493 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005494 modify_add_ies->modifyIE.pIEBuffer = NULL;
5495}
5496
5497/*
5498* lim_process_update_add_ies() - process additional IE update req
5499*
5500* @mac_ctx: Pointer to Global MAC structure
5501* @msg_buf: pointer to the SME message buffer
5502*
5503* This function update the PE buffers for additional IEs.
5504*
5505* Return: None
5506*/
5507static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5508 uint32_t *msg_buf)
5509{
5510 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5511 uint8_t session_id;
5512 tpPESession session_entry;
5513 tSirAddIeParams *addn_ie;
5514 uint16_t new_length = 0;
5515 uint8_t *new_ptr = NULL;
5516 tSirUpdateIE *update_ie;
5517
5518 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005519 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005520 return;
5521 }
5522 update_ie = &update_add_ies->updateIE;
5523 /* incoming message has smeSession, use BSSID to find PE session */
5524 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005525 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005526
5527 if (NULL == session_entry) {
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05305528 pe_debug("Session not found for given bssid"
5529 MAC_ADDRESS_STR,
5530 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005531 goto end;
5532 }
5533 addn_ie = &session_entry->addIeParams;
5534 /* if len is 0, upper layer requested freeing of buffer */
5535 if (0 == update_ie->ieBufferlength) {
5536 switch (update_add_ies->updateType) {
5537 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305538 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005539 addn_ie->probeRespData_buff = NULL;
5540 addn_ie->probeRespDataLen = 0;
5541 break;
5542 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305543 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005544 addn_ie->assocRespData_buff = NULL;
5545 addn_ie->assocRespDataLen = 0;
5546 break;
5547 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305548 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005549 addn_ie->probeRespBCNData_buff = NULL;
5550 addn_ie->probeRespBCNDataLen = 0;
5551
5552 if (update_ie->notify)
5553 lim_handle_param_update(mac_ctx,
5554 update_add_ies->updateType);
5555 break;
5556 default:
5557 break;
5558 }
5559 return;
5560 }
5561 switch (update_add_ies->updateType) {
5562 case eUPDATE_IE_PROBE_RESP:
5563 if (update_ie->append) {
5564 /*
5565 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005566 * with combined length.
5567 * Multiple back to back append commands
5568 * can lead to a huge length.So, check
5569 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005570 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005571 if (addn_ie->probeRespDataLen >
5572 (USHRT_MAX - update_ie->ieBufferlength)) {
5573 pe_err("IE Length overflow, curr:%d, new:%d",
5574 addn_ie->probeRespDataLen,
5575 update_ie->ieBufferlength);
5576 goto end;
5577 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005578 new_length = update_ie->ieBufferlength +
5579 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305580 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005581 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005582 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005583 goto end;
5584 }
5585 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305586 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005587 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305588 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005589 update_ie->pAdditionIEBuffer,
5590 update_ie->ieBufferlength);
5591 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305592 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005593 /* adjust length accordingly */
5594 addn_ie->probeRespDataLen = new_length;
5595 /* save refernece of local buffer in PE session */
5596 addn_ie->probeRespData_buff = new_ptr;
5597 goto end;
5598 }
5599 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5600 &addn_ie->probeRespDataLen,
5601 update_ie->pAdditionIEBuffer,
5602 update_ie->ieBufferlength);
5603 break;
5604 case eUPDATE_IE_ASSOC_RESP:
5605 /* assoc resp IE */
5606 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5607 &addn_ie->assocRespDataLen,
5608 update_ie->pAdditionIEBuffer,
5609 update_ie->ieBufferlength);
5610 break;
5611 case eUPDATE_IE_PROBE_BCN:
5612 /* probe resp Bcn IE */
5613 lim_update_add_ie_buffer(mac_ctx,
5614 &addn_ie->probeRespBCNData_buff,
5615 &addn_ie->probeRespBCNDataLen,
5616 update_ie->pAdditionIEBuffer,
5617 update_ie->ieBufferlength);
5618 if (update_ie->notify)
5619 lim_handle_param_update(mac_ctx,
5620 update_add_ies->updateType);
5621 break;
5622 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005623 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005624 break;
5625 }
5626end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305627 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005628 update_ie->pAdditionIEBuffer = NULL;
5629}
5630
5631/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305632 * send_extended_chan_switch_action_frame()- function to send ECSA
5633 * action frame for each sta connected to SAP/GO and AP in case of
5634 * STA .
5635 * @mac_ctx: pointer to global mac structure
5636 * @new_channel: new channel to switch to.
5637 * @ch_bandwidth: BW of channel to calculate op_class
5638 * @session_entry: pe session
5639 *
5640 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5641 *
5642 * Return: void
5643 */
5644
5645static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5646 uint16_t new_channel, uint8_t ch_bandwidth,
5647 tpPESession session_entry)
5648{
5649 uint16_t op_class;
5650 uint8_t switch_mode = 0, i;
5651 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005652 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305653
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005654 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305655 mac_ctx->scan.countryCodeCurrent,
5656 new_channel,
5657 ch_bandwidth);
5658
5659 if (LIM_IS_AP_ROLE(session_entry) &&
5660 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005661 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305662
gaoleze2920bd2017-03-21 17:38:42 +08005663 switch_count = session_entry->gLimChannelSwitch.switchCount;
5664
Abhishek Singh518323d2015-10-19 17:42:01 +05305665 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005666 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305667 psta =
5668 session_entry->dph.dphHashTable.pDphNodeArray + i;
5669 if (psta && psta->added)
5670 lim_send_extended_chan_switch_action_frame(
5671 mac_ctx,
5672 psta->staAddr,
5673 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005674 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305675 }
5676 } else if (LIM_IS_STA_ROLE(session_entry)) {
5677 lim_send_extended_chan_switch_action_frame(mac_ctx,
5678 session_entry->bssId,
5679 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005680 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305681 }
5682
5683}
5684
gaolez76d2a162017-03-21 19:23:58 +08005685void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5686 uint16_t new_channel,
5687 uint8_t ch_bandwidth,
5688 tpPESession session_entry)
5689{
5690 uint16_t op_class;
5691 uint8_t switch_mode = 0, i;
5692 uint8_t switch_count;
5693 tpDphHashNode psta;
5694 tpDphHashNode dph_node_array_ptr;
5695
5696 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5697
5698 op_class = wlan_reg_dmn_get_opclass_from_channel(
5699 mac_ctx->scan.countryCodeCurrent,
5700 new_channel, ch_bandwidth);
5701
5702 if (LIM_IS_AP_ROLE(session_entry) &&
5703 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5704 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5705
5706 switch_count = session_entry->gLimChannelSwitch.switchCount;
5707
5708 if (LIM_IS_AP_ROLE(session_entry)) {
5709 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5710 psta = dph_node_array_ptr + i;
5711 if (!(psta && psta->added))
5712 continue;
5713 if (session_entry->lim_non_ecsa_cap_num == 0)
5714 lim_send_extended_chan_switch_action_frame
5715 (mac_ctx, psta->staAddr, switch_mode,
5716 op_class, new_channel, switch_count,
5717 session_entry);
5718 else
5719 lim_send_channel_switch_mgmt_frame
5720 (mac_ctx, psta->staAddr, switch_mode,
5721 new_channel, switch_count,
5722 session_entry);
5723 }
5724 } else if (LIM_IS_STA_ROLE(session_entry)) {
5725 lim_send_extended_chan_switch_action_frame
5726 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5727 new_channel, switch_count, session_entry);
5728 }
5729}
5730
5731/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005732 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5733 *
5734 * @mac_ctx: Pointer to Global MAC structure
5735 * @msg_buf: pointer to the SME message buffer
5736 *
5737 * This function processes SME request messages from HDD or upper layer
5738 * application.
5739 *
5740 * Return: None
5741 */
5742static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5743 uint32_t *msg_buf)
5744{
5745 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5746 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005747 uint8_t session_id;
5748 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005749 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005750
5751 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005752 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005753 return;
5754 }
5755
5756 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5757 session_entry = pe_find_session_by_bssid(mac_ctx,
5758 dfs_csa_ie_req->bssid, &session_id);
5759 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005760 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005761 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5762 return;
5763 }
5764
5765 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005766 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005767 GET_LIM_SYSTEM_ROLE(session_entry));
5768 return;
5769 }
5770
5771 /* target channel */
5772 session_entry->gLimChannelSwitch.primaryChannel =
5773 dfs_csa_ie_req->targetChannel;
5774
5775 /* Channel switch announcement needs to be included in beacon */
5776 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005777 session_entry->gLimChannelSwitch.switchCount =
5778 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005779 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005780 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305781 session_entry->gLimChannelSwitch.sec_ch_offset =
5782 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005783 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005784 session_entry->gLimChannelSwitch.switchMode =
5785 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005786
5787 /*
5788 * Validate if SAP is operating HT or VHT mode and set the Channel
5789 * Switch Wrapper element with the Wide Band Switch subelement.
5790 */
5791 if (true != session_entry->vhtCapability)
5792 goto skip_vht;
5793
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005794 /* Now encode the Wider Ch BW element depending on the ch width */
5795 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005796 switch (dfs_csa_ie_req->ch_params.ch_width) {
5797 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005798 /*
5799 * Wide channel BW sublement in channel wrapper element is not
5800 * required in case of 20 Mhz operation. Currently It is set
5801 * only set in case of 40/80 Mhz Operation.
5802 */
5803 session_entry->dfsIncludeChanWrapperIe = false;
5804 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_40MHZ:
5808 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005809 wider_bw_ch_switch->newChanWidth =
5810 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5811 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005812 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005813 session_entry->dfsIncludeChanWrapperIe = true;
5814 wider_bw_ch_switch->newChanWidth =
5815 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5816 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005817 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005818 session_entry->dfsIncludeChanWrapperIe = true;
5819 wider_bw_ch_switch->newChanWidth =
5820 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5821 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005822 case CH_WIDTH_80P80MHZ:
5823 session_entry->dfsIncludeChanWrapperIe = true;
5824 wider_bw_ch_switch->newChanWidth =
5825 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005826 /*
5827 * This is not applicable for 20/40/80 Mhz.
5828 * Only used when we support 80+80 Mhz operation.
5829 * In case of 80+80 Mhz, this parameter indicates
5830 * center channel frequency index of 80 Mhz channel of
5831 * frequency segment 1.
5832 */
5833 wider_bw_ch_switch->newCenterChanFreq1 =
5834 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005835 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005836 default:
5837 session_entry->dfsIncludeChanWrapperIe = false;
5838 /*
5839 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5840 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5841 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005842 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005843 break;
5844 }
5845 /* Fetch the center channel based on the channel width */
5846 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005847 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005848skip_vht:
5849 /* Send CSA IE request from here */
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05305850 lim_send_dfs_chan_sw_ie_update(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305851
5852 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5853 ch_offset = BW80;
5854 else
5855 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5856
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005857 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305858 session_entry->gLimChannelSwitch.switchCount,
5859 session_entry->gLimChannelSwitch.primaryChannel,
5860 session_entry->gLimChannelSwitch.ch_width,
5861 session_entry->dfsIncludeChanWrapperIe,
5862 ch_offset);
5863
gaolez76d2a162017-03-21 19:23:58 +08005864 /* Send ECSA/CSA Action frame after updating the beacon */
5865 if (CHAN_HOP_ALL_BANDS_ENABLE)
5866 lim_send_chan_switch_action_frame(mac_ctx,
5867 session_entry->gLimChannelSwitch.primaryChannel,
5868 ch_offset, session_entry);
5869 else
5870 send_extended_chan_switch_action_frame(mac_ctx,
5871 session_entry->gLimChannelSwitch.primaryChannel,
5872 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005873}
5874
5875/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305876 * lim_process_ext_change_channel()- function to send ECSA
5877 * action frame for STA/CLI .
5878 * @mac_ctx: pointer to global mac structure
5879 * @msg: params from sme for new channel.
5880 *
5881 * This function is called to send ECSA frame for STA/CLI.
5882 *
5883 * Return: void
5884 */
5885
5886static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5887 uint32_t *msg)
5888{
5889 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5890 (struct sir_sme_ext_cng_chan_req *) msg;
5891 tpPESession session_entry = NULL;
5892
5893 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005894 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305895 return;
5896 }
5897 session_entry =
5898 pe_find_session_by_sme_session_id(mac_ctx,
5899 ext_chng_channel->session_id);
5900 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005901 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305902 ext_chng_channel->session_id);
5903 return;
5904 }
5905 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005906 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305907 return;
5908 }
5909 send_extended_chan_switch_action_frame(mac_ctx,
5910 ext_chng_channel->new_channel,
5911 0, session_entry);
5912}
5913
5914/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005915 * lim_process_nss_update_request() - process sme nss update req
5916 *
5917 * @mac_ctx: Pointer to Global MAC structure
5918 * @msg_buf: pointer to the SME message buffer
5919 *
5920 * This function processes SME request messages from HDD or upper layer
5921 * application.
5922 *
5923 * Return: None
5924 */
5925static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5926 uint32_t *msg_buf)
5927{
5928 struct sir_nss_update_request *nss_update_req_ptr;
5929 tpPESession session_entry = NULL;
5930
5931 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005932 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005933 return;
5934 }
5935
5936 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305937 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005938 nss_update_req_ptr->vdev_id);
5939 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005940 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005941 nss_update_req_ptr->vdev_id);
5942 return;
5943 }
5944
5945 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005946 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005947 GET_LIM_SYSTEM_ROLE(session_entry));
5948 return;
5949 }
5950
5951 /* populate nss field in the beacon */
5952 session_entry->gLimOperatingMode.present = 1;
5953 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05305954 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
5955
5956 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
5957 (session_entry->ch_width > CH_WIDTH_80MHZ))
5958 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
5959
5960 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
5961
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005962 /* Send nss update request from here */
5963 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005964 QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005965 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005966 return;
5967 }
5968
5969 lim_send_beacon_ind(mac_ctx, session_entry);
5970}
5971
5972/**
5973 * lim_process_set_ie_req() - process sme set IE request
5974 *
5975 * @mac_ctx: Pointer to Global MAC structure
5976 * @msg_buf: pointer to the SME message buffer
5977 *
5978 * This function processes SME request messages from HDD or upper layer
5979 * application.
5980 *
5981 * Return: None
5982 */
5983static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5984{
5985 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305986 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005987
5988 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005989 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005990 return;
5991 }
5992
5993 msg = (struct send_extcap_ie *)msg_buf;
5994 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305995 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005996 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005997
5998}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005999
6000#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Arif Hussain05fb4872018-01-03 16:02:55 -08006001
6002/**
6003 * obss_color_collision_process_color_disable() - Disable bss color
6004 * @mac_ctx: Pointer to Global MAC structure
6005 * @session: pointer to session
6006 *
6007 * This function will disbale bss color.
6008 *
6009 * Return: None
6010 */
6011static void obss_color_collision_process_color_disable(tpAniSirGlobal mac_ctx,
6012 tpPESession session)
6013{
6014 tUpdateBeaconParams beacon_params;
6015
6016 if (!session) {
6017 pe_err("Invalid session");
6018 return;
6019 }
6020
6021 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6022 pe_err("Invalid SystemRole %d",
6023 GET_LIM_SYSTEM_ROLE(session));
6024 return;
6025 }
6026
6027 if (session->bss_color_changing == 1) {
6028 pe_warn("%d: color change in progress", session->smeSessionId);
6029 /* Continue color collision detection */
6030 lim_send_obss_color_collision_cfg(mac_ctx, session,
6031 OBSS_COLOR_COLLISION_DETECTION);
6032 return;
6033 }
6034
6035 if (session->he_op.bss_col_disabled == 1) {
6036 pe_warn("%d: bss color already disabled",
6037 session->smeSessionId);
6038 /* Continue free color detection */
6039 lim_send_obss_color_collision_cfg(mac_ctx, session,
6040 OBSS_COLOR_FREE_SLOT_AVAILABLE);
6041 return;
6042 }
6043
6044 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
6045 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
6046 session->he_op.bss_col_disabled = 1;
Arif Hussain05fb4872018-01-03 16:02:55 -08006047 beacon_params.bss_color_disabled = 1;
Arif Hussain2f2d3512018-03-06 12:37:03 -08006048 beacon_params.bss_color = session->he_op.bss_color;
Arif Hussain05fb4872018-01-03 16:02:55 -08006049
6050 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006051 QDF_STATUS_SUCCESS) {
Arif Hussain05fb4872018-01-03 16:02:55 -08006052 pe_err("Unable to set op mode IE in beacon");
6053 return;
6054 }
6055
6056 lim_send_beacon_params(mac_ctx, &beacon_params, session);
6057 lim_send_obss_color_collision_cfg(mac_ctx, session,
6058 OBSS_COLOR_FREE_SLOT_AVAILABLE);
6059}
6060
6061/**
6062 * obss_color_collision_process_color_change() - Process bss color change
6063 * @mac_ctx: Pointer to Global MAC structure
6064 * @session: pointer to session
6065 * @obss_color_info: obss color collision/free slot indication info
6066 *
6067 * This function selects new color ib case of bss color collision.
6068 *
6069 * Return: None
6070 */
6071static void obss_color_collision_process_color_change(tpAniSirGlobal mac_ctx,
6072 tpPESession session,
6073 struct wmi_obss_color_collision_info *obss_color_info)
6074{
6075 int i, num_bss_color = 0;
6076 uint32_t bss_color_bitmap;
6077 uint8_t bss_color_index_array[MAX_BSS_COLOR_VALUE];
6078 uint32_t rand_byte = 0;
6079 struct sir_set_he_bss_color he_bss_color;
6080 bool is_color_collision = false;
6081
6082
6083 if (session->bss_color_changing == 1) {
6084 pe_err("%d: color change in progress", session->smeSessionId);
6085 return;
6086 }
6087
6088 if (!session->he_op.bss_col_disabled) {
6089 if (session->he_op.bss_color < 32)
6090 is_color_collision = (obss_color_info->
6091 obss_color_bitmap_bit0to31 >>
6092 session->he_op.bss_color) & 0x01;
6093 else
6094 is_color_collision = (obss_color_info->
6095 obss_color_bitmap_bit32to63 >>
6096 (session->he_op.bss_color -
Arif Hussain9e8c5612018-04-12 16:35:48 -07006097 32)) & 0x01;
Arif Hussain05fb4872018-01-03 16:02:55 -08006098 if (!is_color_collision) {
6099 pe_err("%d: color collision not found, curr_color: %d",
6100 session->smeSessionId,
6101 session->he_op.bss_color);
6102 return;
6103 }
6104 }
6105
6106 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit0to31;
6107
6108 /* Skip color zero */
6109 bss_color_bitmap = bss_color_bitmap >> 1;
6110 for (i = 0; (i < 31) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
6111 if (!(bss_color_bitmap & 0x01)) {
6112 bss_color_index_array[num_bss_color] = i + 1;
6113 num_bss_color++;
6114 }
6115 bss_color_bitmap = bss_color_bitmap >> 1;
6116 }
6117
6118 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit32to63;
6119 for (i = 0; (i < 32) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
6120 if (!(bss_color_bitmap & 0x01)) {
6121 bss_color_index_array[num_bss_color] = i + 32;
6122 num_bss_color++;
6123 }
6124 bss_color_bitmap = bss_color_bitmap >> 1;
6125 }
6126
6127 if (num_bss_color) {
6128 qdf_get_random_bytes((void *) &rand_byte, 1);
6129 i = (rand_byte + qdf_mc_timer_get_system_ticks()) %
6130 num_bss_color;
6131 pe_debug("New bss color = %d", bss_color_index_array[i]);
6132 he_bss_color.session_id = obss_color_info->vdev_id;
6133 he_bss_color.bss_color = bss_color_index_array[i];
6134 lim_process_set_he_bss_color(mac_ctx,
6135 (uint32_t *)&he_bss_color);
6136 } else {
6137 pe_err("Unable to find bss color from bitmasp");
6138 if (obss_color_info->evt_type ==
6139 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY &&
6140 session->obss_color_collision_dec_evt ==
6141 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6142 /* In dot11BSSColorCollisionAPPeriod and
6143 * timer expired, time to disable bss color.
6144 */
6145 obss_color_collision_process_color_disable(mac_ctx,
6146 session);
6147 else
6148 /*
6149 * Enter dot11BSSColorCollisionAPPeriod period.
6150 */
6151 lim_send_obss_color_collision_cfg(mac_ctx, session,
6152 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY);
6153 }
6154}
6155
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006156void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6157{
6158 struct sir_set_he_bss_color *bss_color;
6159 tpPESession session_entry = NULL;
6160 tUpdateBeaconParams beacon_params;
6161
6162 if (!msg_buf) {
6163 pe_err("Buffer is Pointing to NULL");
6164 return;
6165 }
6166
6167 bss_color = (struct sir_set_he_bss_color *)msg_buf;
6168 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
6169 bss_color->session_id);
6170 if (!session_entry) {
6171 pe_err("Session not found for given session_id %d",
6172 bss_color->session_id);
6173 return;
6174 }
6175
6176 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6177 pe_err("Invalid SystemRole %d",
6178 GET_LIM_SYSTEM_ROLE(session_entry));
6179 return;
6180 }
6181
6182 if (bss_color->bss_color == session_entry->he_op.bss_color) {
6183 pe_err("No change in BSS color, current BSS color %d",
6184 bss_color->bss_color);
6185 return;
6186 }
6187 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
6188 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
6189 session_entry->he_op.bss_col_disabled = 1;
6190 session_entry->he_bss_color_change.countdown =
6191 BSS_COLOR_SWITCH_COUNTDOWN;
6192 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08006193 beacon_params.bss_color_disabled = 1;
6194 beacon_params.bss_color = session_entry->he_op.bss_color;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006195 session_entry->bss_color_changing = 1;
6196
6197 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006198 QDF_STATUS_SUCCESS) {
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006199 pe_err("Unable to set op mode IE in beacon");
6200 return;
6201 }
6202
6203 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
Arif Hussain05fb4872018-01-03 16:02:55 -08006204 lim_send_obss_color_collision_cfg(mac_ctx, session_entry,
6205 OBSS_COLOR_COLLISION_DETECTION_DISABLE);
6206}
6207
6208void lim_send_obss_color_collision_cfg(tpAniSirGlobal mac_ctx,
6209 tpPESession session,
6210 enum wmi_obss_color_collision_evt_type
6211 event_type)
6212{
6213 struct wmi_obss_color_collision_cfg_param *cfg_param;
6214 struct scheduler_msg msg = {0};
6215
6216 if (!session) {
6217 pe_err("Invalid session");
6218 return;
6219 }
6220
6221 if (!session->he_capable ||
6222 !session->is_session_obss_color_collision_det_enabled) {
6223 pe_debug("%d: obss color det not enabled, he_cap:%d, sup:%d:%d",
6224 session->smeSessionId, session->he_capable,
6225 session->is_session_obss_color_collision_det_enabled,
6226 mac_ctx->lim.global_obss_color_collision_det_offload);
6227 return;
6228 }
6229
6230 cfg_param = qdf_mem_malloc(sizeof(*cfg_param));
6231 if (!cfg_param) {
6232 pe_err("Failed to allocate memory");
6233 return;
6234 }
6235
6236 pe_debug("%d: sending event:%d", session->smeSessionId, event_type);
6237 qdf_mem_zero(cfg_param, sizeof(*cfg_param));
6238 cfg_param->vdev_id = session->smeSessionId;
6239 cfg_param->evt_type = event_type;
6240 if (LIM_IS_AP_ROLE(session))
6241 cfg_param->detection_period_ms =
6242 OBSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS;
6243 else
6244 cfg_param->detection_period_ms =
6245 OBSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS;
6246
6247 cfg_param->scan_period_ms = OBSS_COLOR_COLLISION_SCAN_PERIOD_MS;
6248 if (event_type == OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6249 cfg_param->free_slot_expiry_time_ms =
6250 OBSS_COLOR_COLLISION_FREE_SLOT_EXPIRY_MS;
6251
6252 msg.type = WMA_OBSS_COLOR_COLLISION_REQ;
6253 msg.bodyptr = cfg_param;
6254 msg.reserved = 0;
6255
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05306256 if (QDF_IS_STATUS_ERROR(scheduler_post_message(QDF_MODULE_ID_PE,
6257 QDF_MODULE_ID_WMA,
6258 QDF_MODULE_ID_WMA,
6259 &msg))) {
Arif Hussain05fb4872018-01-03 16:02:55 -08006260 pe_err("Failed to post WMA_OBSS_COLOR_COLLISION_REQ to WMA");
6261 qdf_mem_free(cfg_param);
6262 } else {
6263 session->obss_color_collision_dec_evt = event_type;
6264 }
6265}
6266
6267void lim_process_obss_color_collision_info(tpAniSirGlobal mac_ctx,
6268 uint32_t *msg_buf)
6269{
6270 struct wmi_obss_color_collision_info *obss_color_info;
6271 tpPESession session;
6272
6273 if (!msg_buf) {
6274 pe_err("Buffer is Pointing to NULL");
6275 return;
6276 }
6277
6278 obss_color_info = (struct wmi_obss_color_collision_info *)msg_buf;
6279 session = pe_find_session_by_sme_session_id(mac_ctx,
6280 obss_color_info->vdev_id);
6281 if (!session) {
6282 pe_err("Session not found for given session_id %d",
6283 obss_color_info->vdev_id);
6284 return;
6285 }
6286
6287 pe_debug("vdev_id:%d, evt:%d:%d, 0to31:0x%x, 32to63:0x%x, cap:%d:%d:%d",
6288 obss_color_info->vdev_id,
6289 obss_color_info->evt_type,
6290 session->obss_color_collision_dec_evt,
6291 obss_color_info->obss_color_bitmap_bit0to31,
6292 obss_color_info->obss_color_bitmap_bit32to63,
6293 session->he_capable,
6294 session->is_session_obss_color_collision_det_enabled,
6295 mac_ctx->lim.global_obss_color_collision_det_offload);
6296
6297 if (!session->he_capable ||
6298 !session->is_session_obss_color_collision_det_enabled) {
6299 return;
6300 }
6301
6302 switch (obss_color_info->evt_type) {
6303 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
6304 pe_err("%d: FW disabled obss color det. he_cap:%d, sup:%d:%d",
6305 session->smeSessionId, session->he_capable,
6306 session->is_session_obss_color_collision_det_enabled,
6307 mac_ctx->lim.global_obss_color_collision_det_offload);
6308 session->is_session_obss_color_collision_det_enabled = false;
6309 return;
6310 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
6311 case OBSS_COLOR_COLLISION_DETECTION:
6312 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
6313 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6314 pe_debug("Invalid System Role %d",
6315 GET_LIM_SYSTEM_ROLE(session));
6316 return;
6317 }
6318
6319 if (session->obss_color_collision_dec_evt !=
6320 obss_color_info->evt_type) {
6321 pe_debug("%d: Wrong event: %d, skiping",
6322 obss_color_info->vdev_id,
6323 obss_color_info->evt_type);
6324 return;
6325 }
6326 obss_color_collision_process_color_change(mac_ctx, session,
6327 obss_color_info);
6328 break;
6329 default:
6330 pe_err("%d: Invalid event type %d",
6331 obss_color_info->vdev_id, obss_color_info->evt_type);
6332 return;
6333 }
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006334}
6335#endif
Abhishek Singh20a8e442018-09-12 15:50:44 +05306336
6337#ifdef CONFIG_VDEV_SM
6338void lim_send_csa_restart_req(tpAniSirGlobal mac_ctx, uint8_t vdev_id)
6339{
6340 tpPESession session;
6341
6342 session = pe_find_session_by_sme_session_id(mac_ctx, vdev_id);
6343
6344 if (!session) {
6345 pe_err("session not found for vdev id %d", vdev_id);
6346 return;
6347 }
6348
6349 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
6350 WLAN_VDEV_SM_EV_CSA_RESTART,
6351 sizeof(*session), session);
6352}
6353#endif