blob: 83ab2294abce6527ca02e44d8c6f6a499b3bbb18 [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
53#include "sap_api.h"
54
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080055
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080056#include <lim_ft.h>
Naveen Rawat3b6068c2016-04-14 19:01:06 -070057#include "cds_regdomain.h"
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053058#include "lim_process_fils.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070059#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060
61/*
62 * This overhead is time for sending NOA start to host in case of GO/sending
63 * NULL data & receiving ACK in case of P2P Client and starting actual scanning
64 * with init scan req/rsp plus in case of concurrency, taking care of sending
65 * null data and receiving ACK to/from AP/Also SetChannel with calibration
66 * is taking around 7ms .
67 */
68#define SCAN_MESSAGING_OVERHEAD 20 /* in msecs */
69#define JOIN_NOA_DURATION 2000 /* in msecs */
70#define OEM_DATA_NOA_DURATION 60 /* in msecs */
71#define DEFAULT_PASSIVE_MAX_CHANNEL_TIME 110 /* in msecs */
72
73#define CONV_MS_TO_US 1024 /* conversion factor from ms to us */
74
Paul Zhangd2315472017-02-22 10:02:50 +080075#define BEACON_INTERVAL_THRESHOLD 50 /* in msecs */
76#define STA_BURST_SCAN_DURATION 120 /* in msecs */
77
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080078/* SME REQ processing function templates */
79static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080080static bool __lim_process_sme_start_bss_req(tpAniSirGlobal,
81 struct scheduler_msg *pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080082static void __lim_process_sme_join_req(tpAniSirGlobal, uint32_t *);
83static void __lim_process_sme_reassoc_req(tpAniSirGlobal, uint32_t *);
84static void __lim_process_sme_disassoc_req(tpAniSirGlobal, uint32_t *);
85static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal, uint32_t *);
86static void __lim_process_sme_deauth_req(tpAniSirGlobal, uint32_t *);
87static void __lim_process_sme_set_context_req(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080088static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal,
89 struct scheduler_msg *pMsg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053090static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
91 uint32_t *msg_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080092static void lim_process_sme_channel_change_request(tpAniSirGlobal pMac,
93 uint32_t *pMsg);
94static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg);
95static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal pMac, uint32_t *pMsg);
96static void lim_process_nss_update_request(tpAniSirGlobal pMac, uint32_t *pMsg);
97static void lim_process_set_ie_req(tpAniSirGlobal pMac, uint32_t *pMsg);
98
99static void lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
100 uint8_t **pDstData_buff,
101 uint16_t *pDstDataLen,
102 uint8_t *pSrcData_buff,
103 uint16_t srcDataLen);
104
105static void lim_update_add_ie_buffer(tpAniSirGlobal pMac,
106 uint8_t **pDstData_buff,
107 uint16_t *pDstDataLen,
108 uint8_t *pSrcData_buff, uint16_t srcDataLen);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800109static bool lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac,
110 uint8_t **pDstData_buff,
111 uint16_t *pDstDataLen,
112 tSirModifyIE *pModifyIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800113static void lim_process_modify_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
114
115static void lim_process_update_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
116
Abhishek Singh518323d2015-10-19 17:42:01 +0530117static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
118 uint32_t *msg);
119
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800120/**
121 * lim_process_set_hw_mode() - Send set HW mode command to WMA
122 * @mac: Globacl MAC pointer
123 * @msg: Message containing the hw mode index
124 *
125 * Send the set HW mode command to WMA
126 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530127 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800128 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530129static QDF_STATUS lim_process_set_hw_mode(tpAniSirGlobal mac, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800130{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530131 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700132 struct scheduler_msg message = {0};
Tushnim Bhattacharyya66348bd2017-03-09 15:02:10 -0800133 struct policy_mgr_hw_mode *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800134 uint32_t len;
135 struct s_sir_set_hw_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700136 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800137 struct sir_set_hw_mode_resp *param;
138
139 buf = (struct s_sir_set_hw_mode *) msg;
140 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700141 pe_err("Set HW mode param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800142 /* To free the active command list */
143 goto fail;
144 }
145
146 len = sizeof(*req_msg);
147
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530148 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700150 pe_err("qdf_mem_malloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800151 /* Free the active command list
152 * Probably the malloc is going to fail there as well?!
153 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530154 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800155 }
156
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800157 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530158 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159 /* Other parameters are not needed for WMA */
160
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800161 message.bodyptr = req_msg;
162 message.type = SIR_HAL_PDEV_SET_HW_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800163
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700164 pe_debug("Posting SIR_HAL_SOC_SET_HW_MOD to WMA");
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800165 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530166 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700167 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530169 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170 goto fail;
171 }
172 return status;
173fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530174 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800175 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700176 pe_err("HW mode resp failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530177 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800178 }
179 param->status = SET_HW_MODE_STATUS_ECANCELED;
180 param->cfgd_hw_mode_index = 0;
181 param->num_vdev_mac_entries = 0;
182 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
183 resp_msg.bodyptr = param;
184 resp_msg.bodyval = 0;
185 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530186 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800187}
188
189/**
190 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
191 * @mac: Global MAC pointer
192 * @msg: Message containing the dual mac config parameter
193 *
194 * Send the set dual mac config command to WMA
195 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530196 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800197 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530198static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800199 uint32_t *msg)
200{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530201 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700202 struct scheduler_msg message = {0};
Srinivas Girigowdaeb6ecf32018-02-15 17:04:22 -0800203 struct policy_mgr_dual_mac_config *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800204 uint32_t len;
205 struct sir_set_dual_mac_cfg *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700206 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800207 struct sir_dual_mac_config_resp *param;
208
209 buf = (struct sir_set_dual_mac_cfg *) msg;
210 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700211 pe_err("Set Dual mac config is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800212 /* To free the active command list */
213 goto fail;
214 }
215
216 len = sizeof(*req_msg);
217
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530218 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800219 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700220 pe_err("qdf_mem_malloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800221 /* Free the active command list
222 * Probably the malloc is going to fail there as well?!
223 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530224 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225 }
226
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 req_msg->scan_config = buf->set_dual_mac.scan_config;
228 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
229 /* Other parameters are not needed for WMA */
230
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800231 message.bodyptr = req_msg;
232 message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800233
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700234 pe_debug("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235 req_msg->scan_config, req_msg->fw_mode_config);
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800236 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530237 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700238 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800239 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530240 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800241 goto fail;
242 }
243 return status;
244fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530245 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800246 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700247 pe_err("Dual mac config resp failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530248 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249 }
250 param->status = SET_HW_MODE_STATUS_ECANCELED;
251 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
252 resp_msg.bodyptr = param;
253 resp_msg.bodyval = 0;
254 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530255 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800256}
257
258/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800259 * lim_process_set_antenna_mode_req() - Set antenna mode command
260 * to WMA
261 * @mac: Global MAC pointer
262 * @msg: Message containing the antenna mode parameter
263 *
264 * Send the set antenna mode command to WMA
265 *
266 * Return: QDF_STATUS_SUCCESS if message posting is successful
267 */
268static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
269 uint32_t *msg)
270{
271 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700272 struct scheduler_msg message = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800273 struct sir_antenna_mode_param *req_msg;
274 struct sir_set_antenna_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700275 struct scheduler_msg resp_msg = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800276 struct sir_antenna_mode_resp *param;
277
278 buf = (struct sir_set_antenna_mode *) msg;
279 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700280 pe_err("Set antenna mode is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800281 /* To free the active command list */
282 goto fail;
283 }
284
285 req_msg = qdf_mem_malloc(sizeof(*req_msg));
286 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700287 pe_err("qdf_mem_malloc failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800288 return QDF_STATUS_E_NOMEM;
289 }
290
291 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
292 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
293
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800294 message.bodyptr = req_msg;
295 message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800296
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700297 pe_debug("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800298 req_msg->num_rx_chains,
299 req_msg->num_tx_chains);
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800300 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800301 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700302 pe_err("scheduler_post_msg failed!(err=%d)",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800303 status);
304 qdf_mem_free(req_msg);
305 goto fail;
306 }
307 return status;
308fail:
309 param = qdf_mem_malloc(sizeof(*param));
310 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700311 pe_err("antenna mode resp failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800312 return QDF_STATUS_E_NOMEM;
313 }
314 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
315 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
316 resp_msg.bodyptr = param;
317 resp_msg.bodyval = 0;
318 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
319 return QDF_STATUS_SUCCESS;
320}
321
322/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800323 * __lim_is_sme_assoc_cnf_valid()
324 *
325 ***FUNCTION:
326 * This function is called by __lim_process_sme_assoc_cnf_new() upon
327 * receiving SME_ASSOC_CNF.
328 *
329 ***LOGIC:
330 * Message validity checks are performed in this function
331 *
332 ***ASSUMPTIONS:
333 *
334 ***NOTE:
335 *
336 * @param pMeasReq Pointer to Received ASSOC_CNF message
337 * @return true When received SME_ASSOC_CNF is formatted
338 * correctly
339 * false otherwise
340 */
341
342static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
343{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530344 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800345 return false;
346 else
347 return true;
348} /*** end __lim_is_sme_assoc_cnf_valid() ***/
349
350/**
351 * __lim_get_sme_join_req_size_for_alloc()
352 *
353 ***FUNCTION:
354 * This function is called in various places to get IE length
355 * from tSirBssDescription structure
356 * number being scanned.
357 *
358 ***PARAMS:
359 *
360 ***LOGIC:
361 *
362 ***ASSUMPTIONS:
363 * NA
364 *
365 ***NOTE:
366 * NA
367 *
368 * @param pBssDescr
369 * @return Total IE length
370 */
371
372static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
373{
374 uint16_t len = 0;
375
376 if (!pBuf)
377 return len;
378
379 pBuf += sizeof(uint16_t);
380 len = lim_get_u16(pBuf);
Arif Hussainc9651922017-04-16 14:08:23 -0700381 return len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800382}
383
384/**
385 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
386 * @pMac: Global MAC context
387 * @pMsg: Pointer to message posted from SME to LIM.
388 *
389 * Has role only if 11h is enabled. Not used on STA side.
390 * Defers the message if SME is in learn state and brings
391 * the LIM back to normal mode.
392 *
393 * Return: true - If defered false - Otherwise
394 */
395
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800396static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac,
397 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800398{
399 if (lim_is_system_in_scan_state(pMac)) {
400 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700401 pe_err("Could not defer Msg: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800402 return false;
403 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700404 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800405 pMsg->type);
406 return true;
407 }
408 return false;
409}
410
411/**
412 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
413 * @mac_ctx: Pointer to Global MAC structure
414 * @message: Pointer to message posted from SME to LIM.
415 *
416 * Has role only if 11h is enabled. Not used on STA side.
417 * Defers the message if radar is detected.
418 *
419 * Return: true, if defered otherwise return false.
420 */
421static bool
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800422__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx,
423 struct scheduler_msg *message)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800424{
425 /*
426 * fRadarDetCurOperChan will be set only if we
427 * detect radar in current operating channel and
428 * System Role == AP ROLE
429 *
430 * TODO: Need to take care radar detection.
431 *
432 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
433 */
434 if (0) {
435 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700436 pe_err("Could not defer Msg: %d", message->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437 return false;
438 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700439 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800440 message->type);
441 return true;
442 }
443 return false;
444}
445
446/**
447 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
448 * @pMac: Global MAC context
449 * @pMsgBuf: Message from WMA
450 *
451 * handles the notification from HDD. PE just forwards this message to HAL.
452 *
453 * Return: true-Posting to HAL failed, so PE will consume the buffer.
454 * false-Posting to HAL successful, so HAL will consume the buffer.
455 */
456
457static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
458{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700459 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800460 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
461
462 msg.type = WMA_SYS_READY_IND;
463 msg.reserved = 0;
464 msg.bodyptr = pMsgBuf;
465 msg.bodyval = 0;
466
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700467 if (ANI_DRIVER_TYPE(pMac) != QDF_DRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800468 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +0530469 pe_register_mgmt_rx_frm_callback(pMac);
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700470 pe_register_callbacks_with_wma(pMac, ready_req);
Sandeep Puligilla1426d612017-04-12 18:22:06 -0700471 pMac->lim.sme_msg_callback = ready_req->sme_msg_cb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800472 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700473
474 pe_debug("sending WMA_SYS_READY_IND msg to HAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800475 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
476
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700477 if (QDF_STATUS_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700478 pe_err("wma_post_ctrl_msg failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800479 return true;
480 }
481 return false;
482}
483
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800484/**
485 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
486 *@mac_ctx: Pointer to Global MAC structure
487 *@session: A pointer to session entry
488 *@sme_start_bss_req: Start BSS Request from upper layers.
489 *
490 * This function is used to configure the start bss parameters
491 * in to the session.
492 *
493 * Return: None.
494 */
495static void
496lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
497 tpSirSmeStartBssReq sme_start_bss_req)
498{
499 session->limSystemRole = eLIM_AP_ROLE;
500 session->privacy = sme_start_bss_req->privacy;
501 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
502 session->authType = sme_start_bss_req->authType;
503 /* Store the DTIM period */
504 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
505 /* Enable/disable UAPSD */
506 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530507 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800508 session->proxyProbeRspEn = 0;
509 } else {
510 /*
511 * To detect PBC overlap in SAP WPS mode,
512 * Host handles Probe Requests.
513 */
514 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
515 session->proxyProbeRspEn = 1;
516 else
517 session->proxyProbeRspEn = 0;
518 }
519 session->ssidHidden = sme_start_bss_req->ssidHidden;
520 session->wps_state = sme_start_bss_req->wps_state;
521 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530522 session->vendor_vht_sap =
523 sme_start_bss_req->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800524 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
525 &session->shortSlotTimeSupported);
526 session->isCoalesingInIBSSAllowed =
527 sme_start_bss_req->isCoalesingInIBSSAllowed;
528
Jiachao Wu712d4fd2017-08-23 16:52:34 +0800529 session->beacon_tx_rate = sme_start_bss_req->beacon_tx_rate;
530
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800531}
532
533/**
Arif Hussain53cf5692018-04-05 16:35:54 -0700534 * lim_clear_he_tx_stbc() - Clear tx stbc for a given session
535 * @session: Session
536 *
537 * Clear tx stbc for a given session
538 *
539 * Return: None
540 */
541#ifdef WLAN_FEATURE_11AX
542static void lim_clear_he_tx_stbc(tpPESession session)
543{
544 if (session) {
545 session->he_config.tx_stbc_lt_80mhz = 0;
546 session->he_config.tx_stbc_gt_80mhz = 0;
547 }
548}
549#else
550static void lim_clear_he_tx_stbc(tpPESession session)
551{}
552#endif
553
554/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800555 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
556 *@mac_ctx: Pointer to Global MAC structure
557 *@msg_buf: A pointer to the SME message buffer
558 *
559 * This function is called to process SME_START_BSS_REQ message
560 * from HDD or upper layer application.
561 *
562 * Return: None
563 */
564static void
565__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
566{
567 uint16_t size;
568 uint32_t val = 0;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700569 QDF_STATUS ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800570 tSirMacChanNum channel_number;
571 tLimMlmStartReq *mlm_start_req = NULL;
572 tpSirSmeStartBssReq sme_start_bss_req = NULL;
573 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
574 /* Flag Used in case of IBSS to Auto generate BSSID. */
575 uint32_t auto_gen_bssid = false;
576 uint8_t session_id;
577 tpPESession session = NULL;
Krunal Sonib37bb352016-12-20 14:12:21 -0800578 uint8_t sme_session_id = 0xFF;
579 uint16_t sme_transaction_id = 0xFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800580 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700581 struct vdev_type_nss *vdev_type_nss;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700582 QDF_STATUS cfg_get_wmi_dfs_master_param = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800583
584/* FEATURE_WLAN_DIAG_SUPPORT */
585#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
586 /*
587 * Since the session is not created yet, sending NULL.
588 * The response should have the correct state.
589 */
590 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
591 NULL, 0, 0);
592#endif /* FEATURE_WLAN_DIAG_SUPPORT */
593
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700594 pe_debug("Received START_BSS_REQ");
Krunal Sonib37bb352016-12-20 14:12:21 -0800595 size = sizeof(tSirSmeStartBssReq);
596 sme_start_bss_req = qdf_mem_malloc(size);
597 if (NULL == sme_start_bss_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700598 pe_err("Allocate Memory fail for LimStartBssReq");
Krunal Sonib37bb352016-12-20 14:12:21 -0800599 /* Send failure response to host */
600 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
601 goto free;
602 }
603 qdf_mem_copy(sme_start_bss_req, msg_buf, sizeof(tSirSmeStartBssReq));
604 sme_session_id = sme_start_bss_req->sessionId;
605 sme_transaction_id = sme_start_bss_req->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800606
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800607 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
608 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800609 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
610 sme_start_bss_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700611 pe_warn("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800612 ret_code = eSIR_SME_INVALID_PARAMETERS;
613 goto free;
614 }
615
616 /*
617 * This is the place where PE is going to create a session.
618 * If session is not existed, then create a new session
619 */
620 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800621 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800622 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700623 pe_warn("Session Already exists for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800624 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
625 session = NULL;
626 goto free;
627 } else {
628 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800629 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800630 &session_id, mac_ctx->lim.maxStation,
631 sme_start_bss_req->bssType);
632 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700633 pe_warn("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800634 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
635 goto free;
636 }
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +0530637
638 /* Update the beacon/probe filter in mac_ctx */
639 lim_set_bcn_probe_filter(mac_ctx, session,
640 &sme_start_bss_req->ssId,
641 sme_start_bss_req->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800642 }
643
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700644 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
645 /* Probe resp add ie */
646 lim_start_bss_update_add_ie_buffer(mac_ctx,
647 &session->addIeParams.probeRespData_buff,
648 &session->addIeParams.probeRespDataLen,
649 sme_start_bss_req->addIeParams.
650 probeRespData_buff,
651 sme_start_bss_req->addIeParams.
652 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800653
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700654 /* Probe Beacon add ie */
655 lim_start_bss_update_add_ie_buffer(mac_ctx,
656 &session->addIeParams.probeRespBCNData_buff,
657 &session->addIeParams.probeRespBCNDataLen,
658 sme_start_bss_req->addIeParams.
659 probeRespBCNData_buff,
660 sme_start_bss_req->addIeParams.
661 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800662
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700663 /* Assoc resp IE */
664 lim_start_bss_update_add_ie_buffer(mac_ctx,
665 &session->addIeParams.assocRespData_buff,
666 &session->addIeParams.assocRespDataLen,
667 sme_start_bss_req->addIeParams.
668 assocRespData_buff,
669 sme_start_bss_req->addIeParams.
670 assocRespDataLen);
671 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800672 /* Store the session related params in newly created session */
673 session->pLimStartBssReq = sme_start_bss_req;
674
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800675 /* Store SME session Id in sessionTable */
676 session->smeSessionId = sme_start_bss_req->sessionId;
677
678 session->transactionId = sme_start_bss_req->transactionId;
679
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530680 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800681 &(sme_start_bss_req->htConfig),
682 sizeof(session->htConfig));
683
Sandeep Puligilla98917432016-06-10 13:50:28 -0700684 qdf_mem_copy(&(session->vht_config),
685 &(sme_start_bss_req->vht_config),
686 sizeof(session->vht_config));
687
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800688 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800689 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800690
691 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530692 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800693 (uint8_t *) &sme_start_bss_req->ssId,
694 (sme_start_bss_req->ssId.length + 1));
695
696 session->bssType = sme_start_bss_req->bssType;
697
698 session->nwType = sme_start_bss_req->nwType;
699
700 session->beaconParams.beaconInterval =
701 sme_start_bss_req->beaconInterval;
702
703 /* Store the channel number in session Table */
704 session->currentOperChannel =
705 sme_start_bss_req->channelId;
706
707 /* Store Persona */
708 session->pePersona = sme_start_bss_req->bssPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +0530709 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800710 FL("PE PERSONA=%d"), session->pePersona);
711
712 /* Update the phymode */
713 session->gLimPhyMode = sme_start_bss_req->nwType;
714
715 session->maxTxPower =
716 cfg_get_regulatory_max_transmit_power(mac_ctx,
717 session->currentOperChannel);
718 /* Store the dot 11 mode in to the session Table */
719 session->dot11mode = sme_start_bss_req->dot11mode;
720#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
721 session->cc_switch_mode =
722 sme_start_bss_req->cc_switch_mode;
723#endif
724 session->htCapability =
725 IS_DOT11_MODE_HT(session->dot11mode);
726 session->vhtCapability =
727 IS_DOT11_MODE_VHT(session->dot11mode);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800728
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700729 pe_debug("HT[%d], VHT[%d]",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800730 session->htCapability, session->vhtCapability);
731
732 if (IS_DOT11_MODE_HE(session->dot11mode)) {
733 lim_update_session_he_capable(mac_ctx, session);
734 lim_copy_bss_he_cap(session, sme_start_bss_req);
735 }
736
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800737 session->txLdpcIniFeatureEnabled =
738 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739#ifdef WLAN_FEATURE_11W
740 session->limRmfEnabled =
741 sme_start_bss_req->pmfCapable ? 1 : 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700742 pe_debug("Session RMF enabled: %d", session->limRmfEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743#endif
744
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530745 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800746 (void *)&sme_start_bss_req->operationalRateSet,
747 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530748 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800749 (void *)&sme_start_bss_req->extendedRateSet,
750 sizeof(tSirMacRateSet));
751
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700752 if (IS_5G_CH(session->currentOperChannel))
753 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
754 else
755 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
756
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800757 switch (sme_start_bss_req->bssType) {
758 case eSIR_INFRA_AP_MODE:
759 lim_configure_ap_start_bss_session(mac_ctx, session,
760 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700761 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700762 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700763 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700764 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800765 break;
766 case eSIR_IBSS_MODE:
767 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
768 lim_get_short_slot_from_phy_mode(mac_ctx, session,
769 session->gLimPhyMode,
770 &session->shortSlotTimeSupported);
771
772 /*
773 * initialize to "OPEN".
774 * will be updated upon key installation
775 */
776 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700777 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800778
779 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700780 case eSIR_NDI_MODE:
781 session->limSystemRole = eLIM_NDI_ROLE;
782 break;
783
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800784
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800785 /*
786 * There is one more mode called auto mode.
787 * which is used no where
788 */
789
790 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
791
792 default:
793 /* not used anywhere...used in scan function */
794 break;
795 }
796
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700797 pe_debug("persona - %d, nss - %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700798 session->pePersona, session->vdev_nss);
799 session->nss = session->vdev_nss;
Kiran Kumar Lokerebc6fb2f2018-05-09 19:04:11 -0700800 if (!mac_ctx->roam.configParam.enable2x2)
801 session->nss = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800802 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700803 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800804 * parsed (Re)Assoc request structure
805 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700806 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800807 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530808 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700809 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800810 if (NULL == session->parsedAssocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700811 pe_warn("AllocateMemory() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800812 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
813 goto free;
814 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815 }
816
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700817 if (!sme_start_bss_req->channelId &&
818 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700819 pe_err("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800820 ret_code = eSIR_SME_INVALID_PARAMETERS;
821 goto free;
822 }
823 channel_number = sme_start_bss_req->channelId;
824#ifdef QCA_HT_2040_COEX
825 if (sme_start_bss_req->obssEnabled)
826 session->htSupportedChannelWidthSet =
827 session->htCapability;
828 else
829#endif
830 session->htSupportedChannelWidthSet =
831 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
832 session->htSecondaryChannelOffset =
833 sme_start_bss_req->sec_ch_offset;
834 session->htRecommendedTxWidthSet =
835 (session->htSecondaryChannelOffset) ? 1 : 0;
Abhishek Singh4294f802017-08-10 16:37:07 +0530836 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800837 FL("cbMode %u"), sme_start_bss_req->cbMode);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800838 if (lim_is_session_he_capable(session) ||
839 session->vhtCapability || session->htCapability) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800840 chanwidth = sme_start_bss_req->vht_channel_width;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700841 pe_debug("vht_channel_width %u htSupportedChannelWidthSet %d",
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800842 sme_start_bss_req->vht_channel_width,
843 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800844 session->ch_width = chanwidth;
845 if (session->htSupportedChannelWidthSet) {
846 session->ch_center_freq_seg0 =
847 sme_start_bss_req->center_freq_seg0;
848 session->ch_center_freq_seg1 =
849 sme_start_bss_req->center_freq_seg1;
850 } else {
851 session->ch_center_freq_seg0 = 0;
852 session->ch_center_freq_seg1 = 0;
853 }
854 }
855
856 if (session->vhtCapability &&
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800857 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858 session->nss = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700859 pe_debug("nss set to [%d]", session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800860 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700861 pe_debug("vht su tx bformer %d",
Krunal Soni53993f72016-07-08 18:20:03 -0700862 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800863
864 /* Delete pre-auth list if any */
865 lim_delete_pre_auth_list(mac_ctx);
866
Krunal Soni53993f72016-07-08 18:20:03 -0700867 if (session->nss == 1) {
868 session->vht_config.su_beam_former = 0;
869 session->vht_config.tx_stbc = 0;
870 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530871 session->htConfig.ht_tx_stbc = 0;
Arif Hussain53cf5692018-04-05 16:35:54 -0700872 lim_clear_he_tx_stbc(session);
Krunal Soni53993f72016-07-08 18:20:03 -0700873 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800874 /*
875 * keep the RSN/WPA IE information in PE Session Entry
876 * later will be using this to check when received (Re)Assoc req
877 */
878 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
879 &sme_start_bss_req->rsnIE, session);
880
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700881 if (LIM_IS_AP_ROLE(session) ||
882 LIM_IS_IBSS_ROLE(session) ||
883 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800884 session->gLimProtectionControl =
885 sme_start_bss_req->protEnabled;
886 /*
887 * each byte will have the following info
888 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
889 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
890 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530891 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800892 (void *)&sme_start_bss_req->ht_capab,
893 sizeof(uint16_t));
894 /* Initialize WPS PBC session link list */
895 session->pAPWPSPBCSession = NULL;
896 }
897 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530898 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800899 if (NULL == mlm_start_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700900 pe_err("Allocate Memory failed for mlmStartReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800901 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
902 goto free;
903 }
904
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800905 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530906 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800907 (uint8_t *) &sme_start_bss_req->ssId,
908 sme_start_bss_req->ssId.length + 1);
909 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
910 mlm_start_req->obssProtEnabled =
911 sme_start_bss_req->obssProtEnabled;
912
913 mlm_start_req->bssType = session->bssType;
914
915 /* Fill PE session Id from the session Table */
916 mlm_start_req->sessionId = session->peSessionId;
917
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700918 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
919 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920 /*
921 * Copy the BSSId from sessionTable to
922 * mlmStartReq struct
923 */
924 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
925 } else {
926 /* ibss mode */
927 mac_ctx->lim.gLimIbssCoalescingHappened = false;
928
929 ret_status = wlan_cfg_get_int(mac_ctx,
930 WNI_CFG_IBSS_AUTO_BSSID,
931 &auto_gen_bssid);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700932 if (ret_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700933 pe_err("Get Auto Gen BSSID fail,Status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800934 ret_status);
Abhishek Singh4294f802017-08-10 16:37:07 +0530935 ret_code = eSIR_LOGE_EXCEPTION;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800936 goto free;
937 }
938
939 if (!auto_gen_bssid) {
940 /*
941 * We're not auto generating BSSID.
942 * Instead, get it from session entry
943 */
944 sir_copy_mac_addr(mlm_start_req->bssId,
945 session->bssId);
946 /*
947 * Start IBSS group BSSID
948 * Auto Generating BSSID.
949 */
950 auto_gen_bssid = ((mlm_start_req->bssId[0] &
951 0x01) ? true : false);
952 }
953
954 if (auto_gen_bssid) {
955 /*
956 * if BSSID is not any uc id.
957 * then use locally generated BSSID.
958 * Autogenerate the BSSID
959 */
960 lim_get_random_bssid(mac_ctx,
961 mlm_start_req->bssId);
962 mlm_start_req->bssId[0] = 0x02;
963
964 /*
965 * Copy randomly generated BSSID
966 * to the session Table
967 */
968 sir_copy_mac_addr(session->bssId,
969 mlm_start_req->bssId);
970 }
971 }
972 /* store the channel num in mlmstart req structure */
973 mlm_start_req->channelNumber = session->currentOperChannel;
974 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
975 mlm_start_req->beaconPeriod =
976 session->beaconParams.beaconInterval;
Arif Hussain671a1902017-03-17 09:08:32 -0700977 mlm_start_req->cac_duration_ms =
978 sme_start_bss_req->cac_duration_ms;
979 mlm_start_req->dfs_regdomain =
980 sme_start_bss_req->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800981 if (LIM_IS_AP_ROLE(session)) {
982 mlm_start_req->dtimPeriod = session->dtimPeriod;
983 mlm_start_req->wps_state = session->wps_state;
984
985 } else {
986 if (wlan_cfg_get_int(mac_ctx,
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700987 WNI_CFG_DTIM_PERIOD, &val) != QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700988 pe_err("could not retrieve DTIM Period");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800989 mlm_start_req->dtimPeriod = (uint8_t) val;
990 }
991
992 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700993 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700994 pe_err("could not retrieve Beacon interval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
996
997 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700998 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700999 pe_err("could not retrieve CFPMaxDuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001000 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1001
1002 /*
1003 * this may not be needed anymore now,
1004 * as rateSet is now included in the
1005 * session entry and MLM has session context.
1006 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301007 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008 (void *)&session->rateSet,
1009 sizeof(tSirMacRateSet));
1010
1011 /* Now populate the 11n related parameters */
1012 mlm_start_req->nwType = session->nwType;
1013 mlm_start_req->htCapable = session->htCapability;
1014
1015 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1016 /* Unused */
1017 mlm_start_req->dualCTSProtection =
1018 mac_ctx->lim.gHTDualCTSProtection;
1019 mlm_start_req->txChannelWidthSet =
1020 session->htRecommendedTxWidthSet;
1021
1022 session->limRFBand = lim_get_rf_band(channel_number);
1023
1024 /* Initialize 11h Enable Flag */
1025 session->lim11hEnable = 0;
gaolez76d2a162017-03-21 19:23:58 +08001026 if (mlm_start_req->bssType != eSIR_IBSS_MODE &&
1027 (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001028 BAND_5G == session->limRFBand)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001029 if (wlan_cfg_get_int(mac_ctx,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001030 WNI_CFG_11H_ENABLED, &val) != QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001031 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001032 else
1033 session->lim11hEnable = val;
1034
1035 if (session->lim11hEnable &&
1036 (eSIR_INFRA_AP_MODE ==
1037 mlm_start_req->bssType)) {
1038 cfg_get_wmi_dfs_master_param =
1039 wlan_cfg_get_int(mac_ctx,
1040 WNI_CFG_DFS_MASTER_ENABLED,
1041 &val);
1042 session->lim11hEnable = val;
1043 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001044 if (cfg_get_wmi_dfs_master_param != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001045 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001046 pe_err("Get Fail, CFG DFS ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001047 }
1048
1049 if (!session->lim11hEnable) {
1050 if (cfg_set_int(mac_ctx,
1051 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001052 QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001053 /*
1054 * Failed to set the CFG param
1055 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1056 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001057 pe_err("Set LOCAL_POWER_CONSTRAINT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001058 }
1059
Jiachao Wu712d4fd2017-08-23 16:52:34 +08001060 mlm_start_req->beacon_tx_rate = session->beacon_tx_rate;
1061
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001062 session->limPrevSmeState = session->limSmeState;
1063 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1064 MTRACE(mac_trace
1065 (mac_ctx, TRACE_CODE_SME_STATE,
1066 session->peSessionId,
1067 session->limSmeState));
1068
1069 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1070 (uint32_t *) mlm_start_req);
1071 return;
1072 } else {
1073
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001074 pe_err("Received unexpected START_BSS_REQ, in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001075 mac_ctx->lim.gLimSmeState);
1076 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001077 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001078 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1079
1080free:
1081 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001082 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001083 session->pLimStartBssReq = NULL;
1084 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001085 if (NULL != sme_start_bss_req)
1086 qdf_mem_free(sme_start_bss_req);
1087 if (NULL != mlm_start_req)
1088 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001089 if (NULL != session) {
1090 pe_delete_session(mac_ctx, session);
1091 session = NULL;
1092 }
1093 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1094 session, sme_session_id, sme_transaction_id);
1095}
1096
1097/**
1098 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1099 *
1100 * @pMac: Global MAC context
1101 * @pMsg: Message pointer
1102 *
1103 * Wrapper for the function __lim_handle_sme_start_bss_request
1104 * This message will be defered until softmac come out of
1105 * scan mode or if we have detected radar on the current
1106 * operating channel.
1107 *
1108 * return true - If we consumed the buffer
1109 * false - If have defered the message.
1110 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001111static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1112 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001113{
1114 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1115 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1116 /**
1117 * If message defered, buffer is not consumed yet.
1118 * So return false
1119 */
1120 return false;
1121 }
1122
1123 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1124 return true;
1125}
1126
1127/**
1128 * lim_get_random_bssid()
1129 *
1130 * FUNCTION:This function is called to process generate the random number for bssid
1131 * This function is called to process SME_SCAN_REQ message
1132 * from HDD or upper layer application.
1133 *
1134 * LOGIC:
1135 *
1136 * ASSUMPTIONS:
1137 *
1138 * NOTE:
1139 * 1. geneartes the unique random number for bssid in ibss
1140 *
1141 * @param pMac Pointer to Global MAC structure
1142 * @param *data Pointer to bssid buffer
1143 * @return None
1144 */
1145void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1146{
1147 uint32_t random[2];
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001148
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001149 random[0] = tx_time_get();
1150 random[0] |= (random[0] << 15);
1151 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301152 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001153}
1154
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001155/**
1156 * __lim_process_clear_dfs_channel_list()
1157 *
1158 ***FUNCTION:
Jeff Johnsonc00ae5b2018-05-06 16:06:35 -07001159 ***Clear DFS channel list when country is changed/acquired.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001160 .*This message is sent from SME.
1161 *
1162 ***LOGIC:
1163 *
1164 ***ASSUMPTIONS:
1165 *
1166 ***NOTE:
1167 *
1168 * @param pMac Pointer to Global MAC structure
1169 * @param *pMsgBuf A pointer to the SME message buffer
1170 * @return None
1171 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001172static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1173 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001174{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301175 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001176}
1177
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301178#ifdef WLAN_FEATURE_SAE
1179
1180/**
1181 * lim_update_sae_config()- This API update SAE session info to csr config
1182 * from join request.
1183 * @session: PE session
1184 * @sme_join_req: pointer to join request
1185 *
1186 * Return: None
1187 */
1188static void lim_update_sae_config(tpPESession session,
1189 tpSirSmeJoinReq sme_join_req)
1190{
1191 session->sae_pmk_cached = sme_join_req->sae_pmk_cached;
1192
1193 pe_debug("pmk_cached %d for BSSID=" MAC_ADDRESS_STR,
1194 session->sae_pmk_cached,
1195 MAC_ADDR_ARRAY(sme_join_req->bssDescription.bssId));
1196}
1197#else
1198static inline void lim_update_sae_config(tpPESession session,
1199 tpSirSmeJoinReq sme_join_req)
1200{}
1201#endif
1202
1203
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001204/**
1205 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1206 * @mac_ctx: Pointer to Global MAC structure
1207 * @msg_buf: A pointer to the SME message buffer
1208 *
1209 * This function is called to process SME_JOIN_REQ message
1210 * from HDD or upper layer application.
1211 *
1212 * Return: None
1213 */
1214static void
1215__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1216{
1217 tpSirSmeJoinReq sme_join_req = NULL;
1218 tLimMlmJoinReq *mlm_join_req;
1219 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1220 uint32_t val = 0;
1221 uint16_t n_size;
1222 uint8_t session_id;
1223 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301224 uint8_t sme_session_id = 0;
1225 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001226 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001227 uint16_t ie_len;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001228 const uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001229 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001230 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001231
Arif Hussain995fcaf2016-07-18 11:28:22 -07001232 if (!mac_ctx || !msg_buf) {
1233 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1234 FL("JOIN REQ with invalid data"));
1235 return;
1236 }
1237
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001238/* FEATURE_WLAN_DIAG_SUPPORT */
1239#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1240 /*
1241 * Not sending any session, since it is not created yet.
1242 * The response whould have correct state.
1243 */
1244 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1245#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1246
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247 /*
1248 * Expect Join request in idle state.
1249 * Reassociate request is expected in link established state.
1250 */
1251
1252 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1253 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1254 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1255 msg_buf);
1256
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301257 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001258 if (NULL == sme_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001259 pe_err("AllocateMemory failed for sme_join_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001260 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301261 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001262 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301263 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001264 n_size);
1265
1266 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1267 /* Received invalid eWNI_SME_JOIN_REQ */
1268 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001269 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001270 sme_join_req->sessionId);
1271 ret_code = eSIR_SME_INVALID_PARAMETERS;
1272 goto end;
1273 }
1274
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001275 /*
1276 * Update the capability here itself as this is used in
1277 * lim_extract_ap_capability() below. If not updated issues
1278 * like not honoring power constraint on 1st association after
1279 * driver loading might occur.
1280 */
1281 lim_update_rrm_capability(mac_ctx, sme_join_req);
1282
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001283 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001284 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001285 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286 &session_id);
1287
1288 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001289 pe_err("Session(%d) Already exists for BSSID: "
1290 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001291 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001292 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293 session->limSmeState);
1294
1295 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1296 session->smeSessionId == sme_join_req->sessionId) {
1297 /*
1298 * Received eWNI_SME_JOIN_REQ for same
1299 * BSS as currently associated.
1300 * Log the event and send success
1301 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001302 pe_warn("SessionId: %d", session_id);
1303 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001304 /* Send Join success response to host */
1305 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1306 session = NULL;
1307 goto end;
1308 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001309 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001310 ret_code = eSIR_SME_REFUSED;
1311 session = NULL;
1312 goto end;
1313 }
1314 } else {
1315 /*
1316 * Session Entry does not exist for given BSSId
1317 * Try to Create a new session
1318 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001319 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001320 &session_id, mac_ctx->lim.maxStation,
1321 eSIR_INFRASTRUCTURE_MODE);
1322 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001323 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001324 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1325 goto end;
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301326 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001327 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328 session_id);
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301329 }
1330
1331 /* Update the beacon/probe filter in mac_ctx */
1332 lim_set_bcn_probe_filter(mac_ctx, session,
1333 &sme_join_req->ssId,
1334 bss_desc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001335 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001336 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001337
1338 /*
1339 * Store Session related parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001340 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341
1342 /* store the smejoin req handle in session table */
1343 session->pLimJoinReq = sme_join_req;
1344
1345 /* Store SME session Id in sessionTable */
1346 session->smeSessionId = sme_join_req->sessionId;
1347
1348 /* Store SME transaction Id in session Table */
1349 session->transactionId = sme_join_req->transactionId;
1350
1351 /* Store beaconInterval */
1352 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001353 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001354
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301355 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001356 sizeof(session->htConfig));
1357
Sandeep Puligilla98917432016-06-10 13:50:28 -07001358 qdf_mem_copy(&(session->vht_config),
1359 &(sme_join_req->vht_config),
1360 sizeof(session->vht_config));
1361
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001362 /* Copying of bssId is already done, while creating session */
1363 sir_copy_mac_addr(session->selfMacAddr,
1364 sme_join_req->selfMacAddr);
1365 session->bssType = sme_join_req->bsstype;
1366
1367 session->statypeForBss = STA_ENTRY_PEER;
1368 session->limWmeEnabled = sme_join_req->isWMEenabled;
1369 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301370 session->wps_registration = sme_join_req->wps_registration;
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001371 session->he_with_wep_tkip = sme_join_req->he_with_wep_tkip;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001372
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301373 session->enable_bcast_probe_rsp =
1374 sme_join_req->enable_bcast_probe_rsp;
1375
Jeff Johnson179fd8a2018-05-11 14:20:05 -07001376 /* Store vendor specific IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001377 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001378 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1379
Naveen Rawat08db88f2017-09-08 15:07:48 -07001380 vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001382 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001383
1384 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001385 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001386 session->isCiscoVendorAP = true;
1387 } else {
1388 session->isCiscoVendorAP = false;
1389 }
1390
1391 /* Copy the dot 11 mode in to the session table */
1392
1393 session->dot11mode = sme_join_req->dot11mode;
1394#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1395 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1396#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001397 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001398 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1399 session->enableHtSmps = sme_join_req->enableHtSmps;
1400 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001401 session->send_smps_action =
1402 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001403 /*
1404 * By default supported NSS 1x1 is set to true
1405 * and later on updated while determining session
1406 * supported rates which is the intersection of
1407 * self and peer rates
1408 */
1409 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301410 /*Store Persona */
1411 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001412 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 -08001413 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001414 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001415 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301416 session->supported_nss_1x1,
1417 session->pePersona,
1418 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001419
1420 /*Store Persona */
1421 session->pePersona = sme_join_req->staPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +05301422 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301423 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d force_24ghz_in_ht20 %d"),
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001424 session->pePersona, sme_join_req->cbMode,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301425 session->nwType, session->dot11mode,
1426 sme_join_req->force_24ghz_in_ht20);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001427
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001428 /* Copy The channel Id to the session Table */
1429 session->currentOperChannel = bss_desc->channelId;
1430 if (IS_5G_CH(session->currentOperChannel))
1431 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001432 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001433 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1434 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1435 session->vdev_nss = vdev_type_nss->p2p_cli;
1436 else
1437 session->vdev_nss = vdev_type_nss->sta;
1438 session->nss = session->vdev_nss;
Kiran Kumar Lokerebc6fb2f2018-05-09 19:04:11 -07001439 if (!mac_ctx->roam.configParam.enable2x2)
1440 session->nss = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441 session->vhtCapability =
1442 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001443 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301444 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001445 session->vht_config.su_beam_formee =
1446 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001447 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001448 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001449 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001450 session->enableVhtpAid =
1451 sme_join_req->enableVhtpAid;
1452 session->enableVhtGid =
1453 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001454 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001455 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001456 }
Krunal Soni53993f72016-07-08 18:20:03 -07001457
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001458 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301459 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001460 session->vht_config.su_beam_formee,
1461 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001462 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001463 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001464 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001465 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301466 session->force_24ghz_in_ht20 =
1467 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001468 /* cbMode is already merged value of peer and self -
1469 * done by csr in csr_get_cb_mode_from_ies */
1470 session->htSupportedChannelWidthSet =
1471 (sme_join_req->cbMode) ? 1 : 0;
1472 session->htRecommendedTxWidthSet =
1473 session->htSupportedChannelWidthSet;
1474 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1475
1476 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1477 session->ch_center_freq_seg0 =
1478 session->currentOperChannel - 2;
1479 session->ch_width = CH_WIDTH_40MHZ;
1480 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1481 sme_join_req->cbMode) {
1482 session->ch_center_freq_seg0 =
1483 session->currentOperChannel + 2;
1484 session->ch_width = CH_WIDTH_40MHZ;
1485 } else {
1486 session->ch_center_freq_seg0 = 0;
1487 session->ch_width = CH_WIDTH_20MHZ;
1488 }
1489
Naveen Rawataeca1b92017-10-16 16:55:31 -07001490 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1491 lim_update_session_he_capable(mac_ctx, session);
1492 lim_copy_join_req_he_cap(session, sme_join_req);
1493 }
1494
1495
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001496 /* Record if management frames need to be protected */
1497#ifdef WLAN_FEATURE_11W
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +05301498 if ((eSIR_ED_AES_128_CMAC ==
1499 sme_join_req->MgmtEncryptionType) ||
1500 (eSIR_ED_AES_GMAC_128 == sme_join_req->MgmtEncryptionType) ||
1501 (eSIR_ED_AES_GMAC_256 == sme_join_req->MgmtEncryptionType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001502 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001503 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001504 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001505#endif
1506
1507#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001508 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001509#endif
1510
1511 /* Copy the SSID from smejoinreq to session entry */
1512 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301513 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001514 session->ssId.length);
1515
1516 /*
1517 * Determin 11r or ESE connection based on input from SME
1518 * which inturn is dependent on the profile the user wants
1519 * to connect to, So input is coming from supplicant
1520 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001522#ifdef FEATURE_WLAN_ESE
1523 session->isESEconnection = sme_join_req->isESEconnection;
1524#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001525 session->isFastTransitionEnabled =
1526 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001527
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001528 session->isFastRoamIniFeatureEnabled =
1529 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001530 session->txLdpcIniFeatureEnabled =
1531 sme_join_req->txLdpcIniFeatureEnabled;
1532
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301533 lim_update_fils_config(session, sme_join_req);
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301534 lim_update_sae_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001535 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1536 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001537 } else {
1538 /*
1539 * Throw an error and return and make
1540 * sure to delete the session.
1541 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001542 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001543 session->bssType);
1544 ret_code = eSIR_SME_INVALID_PARAMETERS;
1545 goto end;
1546 }
1547
1548 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301549 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001550 &sme_join_req->addIEScan, sizeof(tSirAddie));
1551
1552 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301553 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001554 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1555
1556 val = sizeof(tLimMlmJoinReq) +
1557 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301558 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001559 if (NULL == mlm_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001560 pe_err("AllocateMemory failed for mlmJoinReq");
Nitesh Shah0102cac2016-07-13 14:38:30 +05301561 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1562 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001563 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001564
1565 /* PE SessionId is stored as a part of JoinReq */
1566 mlm_join_req->sessionId = session->peSessionId;
1567
1568 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1569 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001570 QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001571 pe_err("couldn't retrieve JoinFailureTimer value"
1572 " setting to default value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001573 mlm_join_req->joinFailureTimeout =
1574 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1575 }
1576
1577 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301578 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001579 (void *)&sme_join_req->operationalRateSet,
1580 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301581 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582 (void *)&sme_join_req->extendedRateSet,
1583 sizeof(tSirMacRateSet));
1584 /*
1585 * this may not be needed anymore now, as rateSet is now
1586 * included in the session entry and MLM has session context.
1587 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301588 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001589 (void *)&session->rateSet,
1590 sizeof(tSirMacRateSet));
1591
1592 session->encryptType = sme_join_req->UCEncryptionType;
1593
1594 mlm_join_req->bssDescription.length =
1595 session->pLimJoinReq->bssDescription.length;
1596
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301597 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001598 (uint8_t *)
1599 &session->pLimJoinReq->bssDescription.bssId,
1600 session->pLimJoinReq->bssDescription.length + 2);
1601
1602 session->limCurrentBssCaps =
1603 session->pLimJoinReq->bssDescription.capabilityInfo;
1604
1605 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1606 session->currentOperChannel);
1607 local_power_constraint = reg_max;
1608
1609 lim_extract_ap_capability(mac_ctx,
1610 (uint8_t *)
1611 session->pLimJoinReq->bssDescription.ieFields,
1612 lim_get_ielen_from_bss_description(
1613 &session->pLimJoinReq->bssDescription),
1614 &session->limCurrentBssQosCaps,
1615 &session->limCurrentBssPropCap,
1616 &session->gLimCurrentBssUapsd,
1617 &local_power_constraint, session);
1618
Krunal Soni53993f72016-07-08 18:20:03 -07001619 /*
1620 * Once the AP capabilities are available then set the
1621 * beam forming capabilities accordingly.
1622 */
1623 if (session->nss == 1) {
1624 session->vht_config.su_beam_former = 0;
1625 session->vht_config.tx_stbc = 0;
1626 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301627 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001628 }
1629
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001630 session->maxTxPower = lim_get_max_tx_power(reg_max,
1631 local_power_constraint,
1632 mac_ctx->roam.configParam.nTxPowerCap);
Abhinav Kumard528d192018-03-09 17:31:12 +05301633 session->def_max_tx_pwr = session->maxTxPower;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301634
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001635 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301636 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301638 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1639 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1640 pe_debug("Update MaxTxPower in join Req to %d",
1641 sme_join_req->powerCap.maxTxPower);
1642 }
1643
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001644 if (session->gLimCurrentBssUapsd) {
1645 session->gUapsdPerAcBitmask =
1646 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001647 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001648 session->gUapsdPerAcBitmask);
1649
1650 /* resetting the dynamic uapsd mask */
1651 session->gUapsdPerAcDeliveryEnableMask = 0;
1652 session->gUapsdPerAcTriggerEnableMask = 0;
1653 }
1654
1655 session->limRFBand =
1656 lim_get_rf_band(session->currentOperChannel);
1657
1658 /* Initialize 11h Enable Flag */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001659 if (BAND_5G == session->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001660 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001661 &val) != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001662 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001663 session->lim11hEnable =
1664 WNI_CFG_11H_ENABLED_STADEF;
1665 } else {
1666 session->lim11hEnable = val;
1667 }
1668 } else {
1669 session->lim11hEnable = 0;
1670 }
1671
1672 /*
1673 * To care of the scenario when STA transitions from
1674 * IBSS to Infrastructure mode.
1675 */
1676 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1677
1678 session->limPrevSmeState = session->limSmeState;
1679 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1680 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1681 session->peSessionId,
1682 session->limSmeState));
1683
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001684 /* Indicate whether spectrum management is enabled */
1685 session->spectrumMgtEnabled =
1686 sme_join_req->spectrumMgtIndicator;
1687
1688 /* Enable the spectrum management if this is a DFS channel */
1689 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001690 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001691 session->currentOperChannel))
1692 session->spectrumMgtEnabled = true;
1693
1694 session->isOSENConnection = sme_join_req->isOSENConnection;
1695
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001696 /* Issue LIM_MLM_JOIN_REQ to MLM */
1697 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1698 (uint32_t *) mlm_join_req);
1699 return;
1700
1701 } else {
1702 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001703 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001704 mac_ctx->lim.gLimSmeState);
1705 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1706 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1707 session = NULL;
1708 goto end;
1709 }
1710
1711end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301712 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1713 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001714
1715 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301716 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717 sme_join_req = NULL;
1718 if (NULL != session)
1719 session->pLimJoinReq = NULL;
1720 }
1721 if (ret_code != eSIR_SME_SUCCESS) {
1722 if (NULL != session) {
1723 pe_delete_session(mac_ctx, session);
1724 session = NULL;
1725 }
1726 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001727 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001728 sme_session_id, ret_code);
1729 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1730 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1731 sme_transaction_id);
1732}
1733
Amar Singhala297bfa2015-10-15 15:07:29 -07001734uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001735 uint8_t iniTxPower)
1736{
1737 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301738 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001739
Anurag Chouhan6d760662016-02-20 16:05:43 +05301740 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001741 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1742 maxTxPower = txPower;
1743 else if (txPower < MIN_TX_PWR_CAP)
1744 maxTxPower = MIN_TX_PWR_CAP;
1745 else
1746 maxTxPower = MAX_TX_PWR_CAP;
1747
1748 return maxTxPower;
1749}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001750
1751/**
1752 * __lim_process_sme_reassoc_req() - process reassoc req
1753 *
1754 * @mac_ctx: Pointer to Global MAC structure
1755 * @msg_buf: pointer to the SME message buffer
1756 *
1757 * This function is called to process SME_REASSOC_REQ message
1758 * from HDD or upper layer application.
1759 *
1760 * Return: None
1761 */
1762
1763static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
1764 uint32_t *msg_buf)
1765{
1766 uint16_t caps;
1767 uint32_t val;
1768 tpSirSmeJoinReq reassoc_req = NULL;
1769 tLimMlmReassocReq *mlm_reassoc_req;
1770 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1771 tpPESession session_entry = NULL;
1772 uint8_t session_id;
1773 uint8_t sme_session_id;
1774 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001775 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001776 uint32_t tele_bcn_en = 0;
1777 uint16_t size;
1778
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001779 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301780 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001781 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001782 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001783
1784 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1785 goto end;
1786 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301787 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001788
1789 if (!lim_is_sme_join_req_valid(mac_ctx,
1790 (tpSirSmeJoinReq)reassoc_req)) {
1791 /*
1792 * Received invalid eWNI_SME_REASSOC_REQ
1793 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001794 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001795
1796 ret_code = eSIR_SME_INVALID_PARAMETERS;
1797 goto end;
1798 }
1799
1800 session_entry = pe_find_session_by_bssid(mac_ctx,
1801 reassoc_req->bssDescription.bssId,
1802 &session_id);
1803 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001804 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001805 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
1806 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001808 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
1809 &sme_session_id, &transaction_id);
1810 session_entry =
1811 pe_find_session_by_sme_session_id(mac_ctx,
1812 sme_session_id);
1813 if (session_entry != NULL)
1814 lim_handle_sme_join_result(mac_ctx,
1815 eSIR_SME_INVALID_PARAMETERS,
1816 eSIR_MAC_UNSPEC_FAILURE_STATUS,
1817 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001818 goto end;
1819 }
1820#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
1821 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001822 session_entry, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001823#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1824 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
1825
1826 /* Store the reassoc handle in the session Table */
1827 session_entry->pLimReAssocReq = reassoc_req;
1828
1829 session_entry->dot11mode = reassoc_req->dot11mode;
1830 session_entry->vhtCapability =
1831 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001832
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301833 if (session_entry->vhtCapability) {
1834 if (session_entry->pePersona == QDF_STA_MODE) {
1835 session_entry->vht_config.su_beam_formee =
1836 reassoc_req->vht_config.su_beam_formee;
1837 } else {
1838 reassoc_req->vht_config.su_beam_formee = 0;
1839 }
1840 session_entry->enableVhtpAid =
1841 reassoc_req->enableVhtpAid;
1842 session_entry->enableVhtGid =
1843 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001844 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301845 }
1846
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001847 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301848 session_entry->vhtCapability,
1849 session_entry->vht_config.su_beam_formee,
1850 session_entry->vht_config.su_beam_former);
1851
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001852 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
1853 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001854 session_entry->send_smps_action =
1855 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001856 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001857 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001858 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001859 session_entry->send_smps_action,
1860 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001861 /*
1862 * Reassociate request is expected
1863 * in link established state only.
1864 */
1865
1866 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001867 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
1868 /*
1869 * May be from 11r FT pre-auth. So lets check it
1870 * before we bail out
1871 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001872 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001873 session_entry->peSessionId);
1874
1875 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301876 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001877 session_entry->limReAssocbssId,
1878 6)) {
1879 lim_print_mac_addr(mac_ctx,
1880 reassoc_req->bssDescription.
1881 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001882 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001883 ret_code = eSIR_SME_INVALID_PARAMETERS;
1884 goto end;
1885 }
1886
1887 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
1888 session_entry);
1889 return;
1890 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891 /*
1892 * Should not have received eWNI_SME_REASSOC_REQ
1893 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001894 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001895 session_entry->limSmeState);
1896 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
1897
1898 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1899 goto end;
1900 }
1901
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301902 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001903 session_entry->pLimReAssocReq->bssDescription.bssId,
1904 sizeof(tSirMacAddr));
1905
1906 session_entry->limReassocChannelId =
1907 session_entry->pLimReAssocReq->bssDescription.channelId;
1908
1909 session_entry->reAssocHtSupportedChannelWidthSet =
1910 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
1911 session_entry->reAssocHtRecommendedTxWidthSet =
1912 session_entry->reAssocHtSupportedChannelWidthSet;
1913 session_entry->reAssocHtSecondaryChannelOffset =
1914 session_entry->pLimReAssocReq->cbMode;
1915
1916 session_entry->limReassocBssCaps =
1917 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
1918 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1919 session_entry->currentOperChannel);
1920 local_pwr_constraint = reg_max;
1921
1922 lim_extract_ap_capability(mac_ctx,
1923 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
1924 lim_get_ielen_from_bss_description(
1925 &session_entry->pLimReAssocReq->bssDescription),
1926 &session_entry->limReassocBssQosCaps,
1927 &session_entry->limReassocBssPropCap,
1928 &session_entry->gLimCurrentBssUapsd,
1929 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05301930 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001931 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301932 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001933 /* Copy the SSID from session entry to local variable */
1934 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301935 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001936 reassoc_req->ssId.ssId,
1937 session_entry->limReassocSSID.length);
1938 if (session_entry->gLimCurrentBssUapsd) {
1939 session_entry->gUapsdPerAcBitmask =
1940 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001941 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001942 session_entry->gUapsdPerAcBitmask);
1943 }
1944
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301945 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001946 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001947 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001948
1949 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1950 goto end;
1951 }
1952
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301953 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001954 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
1955
1956 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
1957 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001958 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001959 pe_err("could not retrieve ReassocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001960
1961 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001962 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001963 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301964
1965 lim_update_caps_info_for_bss(mac_ctx, &caps,
1966 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001967 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301968
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001969 mlm_reassoc_req->capabilityInfo = caps;
1970
1971 /* Update PE session_id */
1972 mlm_reassoc_req->sessionId = session_id;
1973
1974 /*
1975 * If telescopic beaconing is enabled, set listen interval to
1976 * WNI_CFG_TELE_BCN_MAX_LI
1977 */
1978 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001979 &tele_bcn_en) != QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001980 pe_err("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001981
1982 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
1983
1984 if (tele_bcn_en) {
1985 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001986 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001987 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001988 } else {
1989 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001990 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001991 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001992 }
1993
1994 mlm_reassoc_req->listenInterval = (uint16_t) val;
1995
1996 /* Indicate whether spectrum management is enabled */
1997 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
1998
1999 /* Enable the spectrum management if this is a DFS channel */
2000 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002001 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002002 session_entry->currentOperChannel))
2003 session_entry->spectrumMgtEnabled = true;
2004
2005 session_entry->limPrevSmeState = session_entry->limSmeState;
2006 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2007
2008 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2009 session_entry->peSessionId,
2010 session_entry->limSmeState));
2011
2012 lim_post_mlm_message(mac_ctx,
2013 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2014 return;
2015end:
2016 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302017 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002018 if (session_entry)
2019 session_entry->pLimReAssocReq = NULL;
2020 }
2021
2022 if (session_entry) {
2023 /*
2024 * error occurred after we determined the session so extract
2025 * session and transaction info from there
2026 */
2027 sme_session_id = session_entry->smeSessionId;
2028 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002029 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002030 /*
2031 * error occurred before or during the time we determined
2032 * the session so extract the session and transaction info
2033 * from the message
2034 */
2035 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2036 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002037 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002038 /*
2039 * Send Reassoc failure response to host
2040 * (note session_entry may be NULL, but that's OK)
2041 */
2042 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2043 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2044 session_entry, sme_session_id,
2045 transaction_id);
2046}
2047
2048bool send_disassoc_frame = 1;
2049/**
2050 * __lim_process_sme_disassoc_req()
2051 *
2052 ***FUNCTION:
2053 * This function is called to process SME_DISASSOC_REQ message
2054 * from HDD or upper layer application.
2055 *
2056 ***LOGIC:
2057 *
2058 ***ASSUMPTIONS:
2059 *
2060 ***NOTE:
2061 *
2062 * @param pMac Pointer to Global MAC structure
2063 * @param *pMsgBuf A pointer to the SME message buffer
2064 * @return None
2065 */
2066
2067static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2068{
2069 uint16_t disassocTrigger, reasonCode;
2070 tLimMlmDisassocReq *pMlmDisassocReq;
2071 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2072 tSirSmeDisassocReq smeDisassocReq;
2073 tpPESession psessionEntry = NULL;
2074 uint8_t sessionId;
2075 uint8_t smesessionId;
2076 uint16_t smetransactionId;
2077
2078 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002079 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002080 return;
2081 }
2082
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302083 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002084 smesessionId = smeDisassocReq.sessionId;
2085 smetransactionId = smeDisassocReq.transactionId;
2086 if (!lim_is_sme_disassoc_req_valid(pMac,
2087 &smeDisassocReq,
2088 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002089 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002090 if (pMac->lim.gLimRspReqd) {
2091 pMac->lim.gLimRspReqd = false;
2092
2093 retCode = eSIR_SME_INVALID_PARAMETERS;
2094 disassocTrigger = eLIM_HOST_DISASSOC;
2095 goto sendDisassoc;
2096 }
2097
2098 return;
2099 }
2100
2101 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002102 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103 &sessionId);
2104 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002105 pe_err("session does not exist for given bssId "
2106 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002107 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002108 retCode = eSIR_SME_INVALID_PARAMETERS;
2109 disassocTrigger = eLIM_HOST_DISASSOC;
2110 goto sendDisassoc;
2111 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002112 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2113 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002114 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2115 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002116 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002117
2118#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2119 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2120 0, smeDisassocReq.reasonCode);
2121#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2122
2123 /* Update SME session Id and SME transaction ID */
2124
2125 psessionEntry->smeSessionId = smesessionId;
2126 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002127 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002128 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002129
2130 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2131 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002132 switch (psessionEntry->limSmeState) {
2133 case eLIM_SME_ASSOCIATED_STATE:
2134 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002135 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002136 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002137 psessionEntry->limPrevSmeState =
2138 psessionEntry->limSmeState;
2139 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002140 /* Delete all TDLS peers connected before leaving BSS */
2141 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002142 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2143 psessionEntry->peSessionId,
2144 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002145 break;
2146
2147 case eLIM_SME_WT_DEAUTH_STATE:
2148 /* PE shall still process the DISASSOC_REQ and proceed with
2149 * link tear down even if it had already sent a DEAUTH_IND to
2150 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2151 * its been set when PE entered WT_DEAUTH_STATE.
2152 */
2153 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2154 MTRACE(mac_trace
2155 (pMac, TRACE_CODE_SME_STATE,
2156 psessionEntry->peSessionId,
2157 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002158 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002159 break;
2160
2161 case eLIM_SME_WT_DISASSOC_STATE:
Jeff Johnson47d75242018-05-12 15:58:53 -07002162 /* PE Received a Disassoc frame. Normally it gets DISASSOC_CNF but it
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002163 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2164 * PE can continue processing DISASSOC_REQ and send the response instead
2165 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2166 * for disassoc frame.
2167 *
2168 * It will send a disassoc, which is ok. However, we can use the global flag
2169 * sendDisassoc to not send disassoc frame.
2170 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002171 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002172 break;
2173
2174 case eLIM_SME_JOIN_FAILURE_STATE: {
2175 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002176 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002177 if (pMac->lim.gLimRspReqd) {
2178 retCode = eSIR_SME_SUCCESS;
2179 disassocTrigger = eLIM_HOST_DISASSOC;
2180 goto sendDisassoc;
2181 }
2182 }
2183 break;
2184 default:
2185 /**
2186 * STA is not currently associated.
2187 * Log error and send response to host
2188 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002189 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190 psessionEntry->limSmeState);
2191 lim_print_sme_state(pMac, LOGE,
2192 psessionEntry->limSmeState);
2193
2194 if (pMac->lim.gLimRspReqd) {
2195 if (psessionEntry->limSmeState !=
2196 eLIM_SME_WT_ASSOC_STATE)
2197 pMac->lim.gLimRspReqd = false;
2198
2199 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2200 disassocTrigger = eLIM_HOST_DISASSOC;
2201 goto sendDisassoc;
2202 }
2203
2204 return;
2205 }
2206
2207 break;
2208
2209 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002210 /* Fall through */
2211 break;
2212
2213 case eLIM_STA_IN_IBSS_ROLE:
2214 default:
2215 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002216 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002217 GET_LIM_SYSTEM_ROLE(psessionEntry));
2218
2219 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2220 disassocTrigger = eLIM_HOST_DISASSOC;
2221 goto sendDisassoc;
2222 } /* end switch (pMac->lim.gLimSystemRole) */
2223
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302224 disassocTrigger = eLIM_HOST_DISASSOC;
2225 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002226
2227 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002228 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002229 send_disassoc_frame = 0;
2230 }
2231 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002232 pe_debug("Sending Disasscoc with disassoc Trigger"
2233 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002234 disassocTrigger, reasonCode);
2235
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302236 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002237 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002238 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002239 return;
2240 }
2241
Anurag Chouhanc5548422016-02-24 18:33:27 +05302242 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002243 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002244
2245 pMlmDisassocReq->reasonCode = reasonCode;
2246 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2247
2248 /* Update PE session ID */
2249 pMlmDisassocReq->sessionId = sessionId;
2250
2251 lim_post_mlm_message(pMac,
2252 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2253 return;
2254
2255sendDisassoc:
2256 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002257 lim_send_sme_disassoc_ntf(pMac,
2258 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002259 retCode,
2260 disassocTrigger,
2261 1, smesessionId, smetransactionId,
2262 psessionEntry);
2263 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002264 lim_send_sme_disassoc_ntf(pMac,
2265 smeDisassocReq.peer_macaddr.bytes,
2266 retCode, disassocTrigger, 1,
2267 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002268
2269} /*** end __lim_process_sme_disassoc_req() ***/
2270
2271/** -----------------------------------------------------------------
2272 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2273
2274 This function is called to process SME_DISASSOC_CNF message
2275 from HDD or upper layer application.
2276
2277 \param pMac - global mac structure
2278 \param pStaDs - station dph hash node
2279 \return none
2280 \sa
2281 ----------------------------------------------------------------- */
2282static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2283{
2284 tSirSmeDisassocCnf smeDisassocCnf;
2285 uint16_t aid;
2286 tpDphHashNode pStaDs;
2287 tpPESession psessionEntry;
2288 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302289 uint32_t *msg = NULL;
2290 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002291
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302292 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002293 sizeof(struct sSirSmeDisassocCnf));
2294
2295 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002296 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002297 &sessionId);
2298 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002299 pe_err("session does not exist for given bssId");
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302300 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302301 smeDisassocCnf.sme_session_id,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302302 eSIR_SME_INVALID_SESSION,
2303 NULL);
2304 if (QDF_IS_STATUS_SUCCESS(status))
2305 lim_send_sme_disassoc_deauth_ntf(pMac,
2306 QDF_STATUS_SUCCESS,
2307 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002308 return;
2309 }
2310
2311 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002312 pe_err("received invalid SME_DISASSOC_CNF message");
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302313 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2314 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302315 eSIR_SME_INVALID_PARAMETERS,
2316 &smeDisassocCnf.bssid.bytes[0]);
2317 if (QDF_IS_STATUS_SUCCESS(status))
2318 lim_send_sme_disassoc_deauth_ntf(pMac,
2319 QDF_STATUS_SUCCESS,
2320 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002321 return;
2322 }
2323#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2324 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2325 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2326 psessionEntry,
2327 (uint16_t) smeDisassocCnf.statusCode, 0);
2328 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2329 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2330 psessionEntry,
2331 (uint16_t) smeDisassocCnf.statusCode, 0);
2332#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2333
2334 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2335 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002336 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2337 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2338 && (psessionEntry->limSmeState !=
2339 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002340 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002341 psessionEntry->limSmeState);
2342 lim_print_sme_state(pMac, LOGE,
2343 psessionEntry->limSmeState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302344 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302345 psessionEntry->smeSessionId,
2346 eSIR_SME_INVALID_STATE,
2347 &smeDisassocCnf.bssid.bytes[0]);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302348 if (QDF_IS_STATUS_SUCCESS(status))
2349 lim_send_sme_disassoc_deauth_ntf(pMac,
2350 QDF_STATUS_SUCCESS,
2351 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002352 return;
2353 }
2354 break;
2355
2356 case eLIM_AP_ROLE:
2357 /* Fall through */
2358 break;
2359
2360 case eLIM_STA_IN_IBSS_ROLE:
2361 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002362 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002363 GET_LIM_SYSTEM_ROLE(psessionEntry));
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302364 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2365 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302366 eSIR_SME_INVALID_STATE,
2367 &smeDisassocCnf.bssid.bytes[0]);
2368 if (QDF_IS_STATUS_SUCCESS(status))
2369 lim_send_sme_disassoc_deauth_ntf(pMac,
2370 QDF_STATUS_SUCCESS,
2371 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002372 return;
2373 }
2374
2375 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2376 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2377 LIM_IS_AP_ROLE(psessionEntry)) {
2378 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002379 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002380 &psessionEntry->dph.dphHashTable);
2381 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002382 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2383 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002384 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302385 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302386 psessionEntry->smeSessionId,
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05302387 eSIR_SME_INVALID_PARAMETERS,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302388 &smeDisassocCnf.bssid.bytes[0]);
2389 if (QDF_IS_STATUS_SUCCESS(status))
2390 lim_send_sme_disassoc_deauth_ntf(pMac,
2391 QDF_STATUS_SUCCESS,
2392 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002393 return;
2394 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302395
2396 if ((pStaDs->mlmStaContext.mlmState ==
2397 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2398 (pStaDs->mlmStaContext.mlmState ==
Arif Hussain5fa13782018-05-10 11:29:52 -07002399 eLIM_MLM_WT_DEL_BSS_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002400 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002401 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302402 pStaDs->mlmStaContext.mlmState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302403 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302404 psessionEntry->smeSessionId,
2405 eSIR_SME_SUCCESS,
2406 NULL);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302407 if (QDF_IS_STATUS_SUCCESS(status))
2408 lim_send_sme_disassoc_deauth_ntf(pMac,
2409 QDF_STATUS_SUCCESS,
2410 (uint32_t *)msg);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302411 return;
2412 }
2413
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002414 /* Delete FT session if there exists one */
2415 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002416 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2417
2418 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002419 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002420 }
2421
2422 return;
2423}
2424
2425/**
2426 * __lim_process_sme_deauth_req() - process sme deauth req
2427 * @mac_ctx: Pointer to Global MAC structure
2428 * @msg_buf: pointer to the SME message buffer
2429 *
2430 * This function is called to process SME_DEAUTH_REQ message
2431 * from HDD or upper layer application.
2432 *
2433 * Return: None
2434 */
2435
2436static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2437 uint32_t *msg_buf)
2438{
2439 uint16_t deauth_trigger, reason_code;
2440 tLimMlmDeauthReq *mlm_deauth_req;
2441 tSirSmeDeauthReq sme_deauth_req;
2442 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2443 tpPESession session_entry;
2444 uint8_t session_id; /* PE sessionId */
2445 uint8_t sme_session_id;
2446 uint16_t sme_transaction_id;
2447
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302448 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002449 sme_session_id = sme_deauth_req.sessionId;
2450 sme_transaction_id = sme_deauth_req.transactionId;
2451
2452 /*
2453 * We need to get a session first but we don't even know
2454 * if the message is correct.
2455 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002456 session_entry = pe_find_session_by_bssid(mac_ctx,
2457 sme_deauth_req.bssid.bytes,
2458 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002459 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002460 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002461 ret_code = eSIR_SME_INVALID_PARAMETERS;
2462 deauth_trigger = eLIM_HOST_DEAUTH;
2463 goto send_deauth;
2464 }
2465
2466 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2467 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002468 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002469 mac_ctx->lim.gLimRspReqd = false;
2470
2471 ret_code = eSIR_SME_INVALID_PARAMETERS;
2472 deauth_trigger = eLIM_HOST_DEAUTH;
2473 goto send_deauth;
2474 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002475 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2476 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002477 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2478 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002479 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002480#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2481 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2482 session_entry, 0, sme_deauth_req.reasonCode);
2483#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2484
2485 /* Update SME session ID and Transaction ID */
2486 session_entry->smeSessionId = sme_session_id;
2487 session_entry->transactionId = sme_transaction_id;
2488
2489 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2490 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002491 switch (session_entry->limSmeState) {
2492 case eLIM_SME_ASSOCIATED_STATE:
2493 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302494 /* Delete all TDLS peers connected before leaving BSS */
2495 lim_delete_tdls_peers(mac_ctx, session_entry);
Abhinav Kumarac12c762018-05-02 13:51:02 +05302496 /* fallthrough */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002497 case eLIM_SME_WT_ASSOC_STATE:
2498 case eLIM_SME_JOIN_FAILURE_STATE:
2499 case eLIM_SME_IDLE_STATE:
2500 session_entry->limPrevSmeState =
2501 session_entry->limSmeState;
2502 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2503 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2504 session_entry->peSessionId,
2505 session_entry->limSmeState));
2506 /* Send Deauthentication request to MLM below */
2507 break;
2508 case eLIM_SME_WT_DEAUTH_STATE:
2509 case eLIM_SME_WT_DISASSOC_STATE:
2510 /*
Jeff Johnson47d75242018-05-12 15:58:53 -07002511 * PE Received a Deauth/Disassoc frame. Normally it get
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002512 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2513 * Which means host is also trying to disconnect.
2514 * PE can continue processing DEAUTH_REQ and send
2515 * the response instead of failing the request.
2516 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2517 * was sent for deauth/disassoc frame.
2518 */
2519 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002520 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002521 break;
2522 default:
2523 /*
2524 * STA is not in a state to deauthenticate with
2525 * peer. Log error and send response to host.
2526 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002527 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002528 session_entry->limSmeState);
2529 lim_print_sme_state(mac_ctx, LOGE,
2530 session_entry->limSmeState);
2531
2532 if (mac_ctx->lim.gLimRspReqd) {
2533 mac_ctx->lim.gLimRspReqd = false;
2534
2535 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2536 deauth_trigger = eLIM_HOST_DEAUTH;
2537
wadesong42968e92017-06-08 14:11:21 +08002538 /*
2539 * here we received deauth request from AP so
2540 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2541 * have ISSUED delSta then mlm state should be
2542 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2543 * delBSS rsp then mlm state should be
2544 * eLIM_MLM_IDLE_STATE so the below condition
2545 * captures the state where delSta not done
2546 * and firmware still in connected state.
2547 */
2548 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002549 eLIM_SME_WT_DEAUTH_STATE &&
2550 session_entry->limMlmState !=
2551 eLIM_MLM_IDLE_STATE &&
2552 session_entry->limMlmState !=
2553 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002554 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002555 goto send_deauth;
2556 }
2557 return;
2558 }
2559 break;
2560
2561 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002562 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002563 if (mac_ctx->lim.gLimRspReqd) {
2564 mac_ctx->lim.gLimRspReqd = false;
2565 ret_code = eSIR_SME_INVALID_PARAMETERS;
2566 deauth_trigger = eLIM_HOST_DEAUTH;
2567 goto send_deauth;
2568 }
2569 return;
2570 case eLIM_AP_ROLE:
2571 break;
2572 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002573 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002574 GET_LIM_SYSTEM_ROLE(session_entry));
2575 if (mac_ctx->lim.gLimRspReqd) {
2576 mac_ctx->lim.gLimRspReqd = false;
2577 ret_code = eSIR_SME_INVALID_PARAMETERS;
2578 deauth_trigger = eLIM_HOST_DEAUTH;
2579 goto send_deauth;
2580 }
2581 return;
2582 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2583
2584 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2585 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002586 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002587 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2588 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2589 } else {
2590 deauth_trigger = eLIM_HOST_DEAUTH;
2591 reason_code = sme_deauth_req.reasonCode;
2592 }
2593
2594 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302595 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002596 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002597 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002598 if (mac_ctx->lim.gLimRspReqd) {
2599 mac_ctx->lim.gLimRspReqd = false;
2600 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2601 deauth_trigger = eLIM_HOST_DEAUTH;
2602 goto send_deauth;
2603 }
2604 return;
2605 }
2606
Anurag Chouhanc5548422016-02-24 18:33:27 +05302607 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002608 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002609
2610 mlm_deauth_req->reasonCode = reason_code;
2611 mlm_deauth_req->deauthTrigger = deauth_trigger;
2612
2613 /* Update PE session Id */
2614 mlm_deauth_req->sessionId = session_id;
2615
2616 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2617 (uint32_t *)mlm_deauth_req);
2618 return;
2619
2620send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002621 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2622 ret_code, deauth_trigger, 1,
2623 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002624}
2625
2626/**
2627 * __lim_process_sme_set_context_req()
2628 *
2629 * @mac_ctx: Pointer to Global MAC structure
2630 * @msg_buf: pointer to the SME message buffer
2631 *
2632 * This function is called to process SME_SETCONTEXT_REQ message
2633 * from HDD or upper layer application.
2634 *
2635 * Return: None
2636 */
2637
2638static void
2639__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2640{
2641 tpSirSmeSetContextReq set_context_req;
2642 tLimMlmSetKeysReq *mlm_set_key_req;
2643 tpPESession session_entry;
2644 uint8_t session_id; /* PE sessionID */
2645 uint8_t sme_session_id;
2646 uint16_t sme_transaction_id;
2647
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002648 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002649 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002650 return;
2651 }
2652
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302653 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002654 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002655 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002656 return;
2657 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302658 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002659 sizeof(struct sSirSmeSetContextReq));
2660 sme_session_id = set_context_req->sessionId;
2661 sme_transaction_id = set_context_req->transactionId;
2662
2663 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002664 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002665 goto end;
2666 }
2667
2668 if (set_context_req->keyMaterial.numKeys >
2669 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002670 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002671 set_context_req->keyMaterial.numKeys);
2672 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002673 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002674 eSIR_SME_INVALID_PARAMETERS, NULL,
2675 sme_session_id, sme_transaction_id);
2676 goto end;
2677 }
2678
2679 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002680 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002681 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002682 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002683 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002684 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002685 eSIR_SME_INVALID_PARAMETERS, NULL,
2686 sme_session_id, sme_transaction_id);
2687 goto end;
2688 }
2689#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2690 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2691 session_entry, 0, 0);
2692#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2693
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002694 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002695 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2696 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002697 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002698 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2699 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302700 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002701 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002702 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002703 goto end;
2704 }
2705 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2706 mlm_set_key_req->numKeys =
2707 set_context_req->keyMaterial.numKeys;
2708 if (mlm_set_key_req->numKeys >
2709 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002710 pe_err("no.of keys exceeded max num of default keys limit");
Jingxiang Ge4168a232018-01-03 18:47:15 +08002711 qdf_mem_free(mlm_set_key_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002712 goto end;
2713 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302714 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002715 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002716
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302717 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002718 (uint8_t *) &set_context_req->keyMaterial.key,
2719 sizeof(tSirKeys) *
2720 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2721 numKeys : 1));
2722
2723 mlm_set_key_req->sessionId = session_id;
2724 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002725 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002726 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002727
2728 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2729 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2730 LIM_IS_AP_ROLE(session_entry)) {
2731 if (set_context_req->keyMaterial.key[0].keyLength) {
2732 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002733
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002734 key_id =
2735 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302736 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002737 &session_entry->WEPKeyMaterial[key_id],
2738 (uint8_t *) &set_context_req->keyMaterial,
2739 sizeof(tSirKeyMaterial));
2740 } else {
2741 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002742
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002743 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2744 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302745 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002746 &mlm_set_key_req->key[i],
2747 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2748 sizeof(tSirKeys));
2749 }
2750 }
2751 }
2752 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2753 (uint32_t *) mlm_set_key_req);
2754 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002755 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002756 GET_LIM_SYSTEM_ROLE(session_entry),
2757 session_entry->limSmeState);
2758 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2759
2760 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002761 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002762 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2763 session_entry, sme_session_id,
2764 sme_transaction_id);
2765 }
2766end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302767 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002768 return;
2769}
2770
2771/**
2772 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2773 *
2774 * @mac_ctx: Pointer to Global MAC structure
2775 * @msg_buf: pointer to the SME message buffer
2776 *
2777 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2778 * from HDD or upper layer application.
2779 *
2780 * Return: None
2781 */
2782
Jeff Johnson801f1532016-10-07 07:54:50 -07002783static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2784 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002785{
2786 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2787 tpDphHashNode sta_ds = NULL;
2788 tpPESession session_entry = NULL;
2789 tSap_Event sap_event;
2790 tpWLAN_SAPEventCB sap_event_cb = NULL;
2791 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2792 uint8_t session_id = CSR_SESSION_ID_INVALID;
2793 uint8_t assoc_id = 0;
2794 uint8_t sta_cnt = 0;
2795
2796 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002797 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002798 return;
2799 }
2800
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302801 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002802 sizeof(struct sSirSmeGetAssocSTAsReq));
2803 /*
2804 * Get Associated stations from PE.
2805 * Find PE session Entry
2806 */
2807 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08002808 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002809 &session_id);
2810 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002811 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002812 goto lim_assoc_sta_end;
2813 }
2814
2815 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002816 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002817 session_entry->limSmeState,
2818 GET_LIM_SYSTEM_ROLE(session_entry));
2819 goto lim_assoc_sta_end;
2820 }
2821 /* Retrieve values obtained in the request message */
2822 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
2823 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2824
2825 if (NULL == assoc_sta_tmp)
2826 goto lim_assoc_sta_end;
2827 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
2828 assoc_id++) {
2829 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
2830 &session_entry->dph.dphHashTable);
2831 if (NULL == sta_ds)
2832 continue;
2833 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302834 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002835 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302836 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002837 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
2838 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
2839
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302840 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002841 (uint8_t *)&sta_ds->supportedRates,
2842 sizeof(tSirSupportedRates));
2843 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
2844 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
2845 assoc_sta_tmp->Support40Mhz =
2846 sta_ds->htDsssCckRate40MHzSupport;
2847
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002848 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002849 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002850 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002851 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002852 pe_debug("Association Id: %d Station Index: %d",
2853 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002854 assoc_sta_tmp++;
2855 sta_cnt++;
2856 }
2857 }
2858lim_assoc_sta_end:
2859 /*
2860 * Call hdd callback with sap event to send the list of
2861 * associated stations from PE
2862 */
2863 if (sap_event_cb != NULL) {
2864 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
2865 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302866 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002867 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
2868 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
2869 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2870 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
2871 }
2872}
2873
2874/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002875 * __lim_counter_measures()
2876 *
2877 * FUNCTION:
2878 * This function is called to "implement" MIC counter measure
2879 * and is *temporary* only
2880 *
2881 * LOGIC: on AP, disassoc all STA associated thru TKIP,
2882 * we don't do the proper STA disassoc sequence since the
Jeff Johnsond460e842018-05-11 13:25:53 -07002883 * BSS will be stopped anyway
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002884 *
2885 ***ASSUMPTIONS:
2886 *
2887 ***NOTE:
2888 *
2889 * @param pMac Pointer to Global MAC structure
2890 * @return None
2891 */
2892
2893static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
2894{
2895 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002896
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002897 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002898 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
2899 mac, psessionEntry, false);
2900};
2901
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002902static void
2903__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2904{
2905 tSirSmeStopBssReq stopBssReq;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002906 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002907 tLimSmeStates prevState;
2908 tpPESession psessionEntry;
2909 uint8_t smesessionId;
2910 uint8_t sessionId;
2911 uint16_t smetransactionId;
2912 uint8_t i = 0;
2913 tpDphHashNode pStaDs = NULL;
2914
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302915 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002916 smesessionId = stopBssReq.sessionId;
2917 smetransactionId = stopBssReq.transactionId;
2918
2919 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002920 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002921 /* Send Stop BSS response to host */
2922 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2923 eSIR_SME_INVALID_PARAMETERS, smesessionId,
2924 smetransactionId);
2925 return;
2926 }
2927
2928 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08002929 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002930 &sessionId);
2931 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002932 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002933 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2934 eSIR_SME_INVALID_PARAMETERS, smesessionId,
2935 smetransactionId);
2936 return;
2937 }
2938#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2939 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
2940 0, 0);
2941#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2942
2943 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
2944 LIM_IS_STA_ROLE(psessionEntry)) {
2945 /**
2946 * Should not have received STOP_BSS_REQ in states
2947 * other than 'normal' state or on STA in Infrastructure
2948 * mode. Log error and return response to host.
2949 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002950 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002951 psessionEntry->limSmeState,
2952 GET_LIM_SYSTEM_ROLE(psessionEntry));
2953 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
2954 /* / Send Stop BSS response to host */
2955 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2956 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
2957 smetransactionId);
2958 return;
2959 }
2960
2961 if (LIM_IS_AP_ROLE(psessionEntry))
2962 lim_wpspbc_close(pMac, psessionEntry);
2963
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002964 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002965 stopBssReq.reasonCode);
2966
2967 prevState = psessionEntry->limSmeState;
2968
2969 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
2970 MTRACE(mac_trace
2971 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
2972 psessionEntry->limSmeState));
2973
2974 /* Update SME session Id and Transaction Id */
2975 psessionEntry->smeSessionId = smesessionId;
2976 psessionEntry->transactionId = smetransactionId;
2977
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002978 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
2979 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
2980 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002981 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002982
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002983 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
2984 /* Send disassoc all stations associated thru TKIP */
2985 __lim_counter_measures(pMac, psessionEntry);
2986 else
2987 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002988 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
2989 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002990 }
2991
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002992 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
2993 /* Free the buffer allocated in START_BSS_REQ */
2994 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
2995 psessionEntry->addIeParams.probeRespDataLen = 0;
2996 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002997
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002998 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
2999 psessionEntry->addIeParams.assocRespDataLen = 0;
3000 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003001
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003002 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3003 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3004 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003005
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003006 /*
3007 * lim_del_bss is also called as part of coalescing,
3008 * when we send DEL BSS followed by Add Bss msg.
3009 */
3010 pMac->lim.gLimIbssCoalescingHappened = false;
3011 }
Sandeep Puligillaa894ffc2018-06-01 15:33:36 -07003012 for (i = 1; i < psessionEntry->dph.dphHashTable.size; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003013 pStaDs =
3014 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3015 if (NULL == pStaDs)
3016 continue;
3017 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003018 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003019 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3020 pStaDs->assocId, psessionEntry);
3021 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3022 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003023 pe_err("lim_del_sta failed with Status: %d", status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303024 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003025 }
3026 }
3027 /* send a delBss to HAL and wait for a response */
3028 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3029
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003030 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003031 pe_err("delBss failed for bss %d", psessionEntry->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003032 psessionEntry->limSmeState = prevState;
3033
3034 MTRACE(mac_trace
3035 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3036 psessionEntry->limSmeState));
3037
3038 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3039 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3040 smetransactionId);
3041 }
3042}
3043
3044/**
3045 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3046 * @pMac: Global MAC context
3047 * @pMsg: Message from SME
3048 *
3049 * Wrapper for the function __lim_handle_sme_stop_bss_request
3050 * This message will be defered until softmac come out of
3051 * scan mode. Message should be handled even if we have
3052 * detected radar in the current operating channel.
3053 *
3054 * Return: true - If we consumed the buffer
3055 * false - If have defered the message.
3056 */
3057
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003058static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3059 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003060{
3061 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3062 /**
3063 * If message defered, buffer is not consumed yet.
3064 * So return false
3065 */
3066 return false;
3067 }
3068 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3069 return true;
3070} /*** end __lim_process_sme_stop_bss_req() ***/
3071
3072void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3073 uint32_t body, tpPESession psessionEntry)
3074{
3075
3076 (void)body;
3077 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3078 lim_ibss_delete(pMac, psessionEntry);
3079 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3080 lim_delete_pre_auth_list(pMac);
3081 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3082 psessionEntry->smeSessionId,
3083 psessionEntry->transactionId);
3084 return;
3085}
3086
3087/**
3088 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3089 *
3090 * @mac_ctx: pointer to mac context
3091 * @msg_type: message type
3092 * @msg_buf: pointer to the SME message buffer
3093 *
3094 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3095 * in BTAMP AP.
3096 *
3097 * Return: None
3098 */
3099
3100void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3101 uint32_t *msg_buf)
3102{
3103 tSirSmeAssocCnf assoc_cnf;
3104 tpDphHashNode sta_ds = NULL;
3105 tpPESession session_entry = NULL;
3106 uint8_t session_id;
3107 tpSirAssocReq assoc_req;
3108
3109 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003110 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003111 goto end;
3112 }
3113
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303114 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003115 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003116 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003117 goto end;
3118 }
3119
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003120 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003121 &session_id);
3122 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003123 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003124 goto end;
3125 }
3126
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003127 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003128 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3129 (session_entry->limSmeState !=
3130 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003131 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003132 msg_type, session_entry->limSmeState,
3133 GET_LIM_SYSTEM_ROLE(session_entry));
3134 goto end;
3135 }
3136 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3137 &session_entry->dph.dphHashTable);
3138 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003139 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003140 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303141 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003142
3143 /*
3144 * send a DISASSOC_IND message to WSM to make sure
3145 * the state in WSM and LIM is the same
3146 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003147 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003148 eSIR_SME_STA_NOT_ASSOCIATED,
3149 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3150 session_entry->smeSessionId,
3151 session_entry->transactionId,
3152 session_entry);
3153 goto end;
3154 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303155 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003156 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303157 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003158 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003159 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303160 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003161 goto end;
3162 }
3163
3164 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3165 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3166 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3167 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3168 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003169 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3170 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003171 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303172 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003173 goto end;
3174 }
3175 /*
3176 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3177 * has been received
3178 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003179 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003180 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3181 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3182
3183 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3184 /*
3185 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3186 * when it had received Assoc Request frame. Now, PE just needs
3187 * to send association rsp frame to the requesting BTAMP-STA.
3188 */
3189 sta_ds->mlmStaContext.mlmState =
3190 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003191 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192 sta_ds->assocId);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003193 lim_send_assoc_rsp_mgmt_frame(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003194 sta_ds->assocId, sta_ds->staAddr,
3195 sta_ds->mlmStaContext.subType, sta_ds,
3196 session_entry);
3197 goto end;
3198 } else {
3199 /*
3200 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3201 * to be associated since the HAL sta entry is created for
3202 * denied STA we need to remove this HAL entry.
3203 * So to do that set updateContext to 1
3204 */
3205 if (!sta_ds->mlmStaContext.updateContext)
3206 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003207 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003208 assoc_cnf.statusCode, sta_ds->assocId);
3209 lim_reject_association(mac_ctx, sta_ds->staAddr,
3210 sta_ds->mlmStaContext.subType,
3211 true, sta_ds->mlmStaContext.authType,
3212 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003213 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003214 session_entry);
3215 }
3216end:
3217 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3218 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3219 assoc_req = (tpSirAssocReq)
3220 session_entry->parsedAssocReq[sta_ds->assocId];
3221 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303222 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003223 assoc_req->assocReqFrame = NULL;
3224 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303225 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3227 }
3228}
3229
3230static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3231{
3232 tpDphHashNode pStaDs;
3233 tSirMacAddr peerMac;
3234 tpSirAddtsReq pSirAddts;
3235 uint32_t timeout;
3236 tpPESession psessionEntry;
3237 uint8_t sessionId; /* PE sessionId */
3238 uint8_t smesessionId;
3239 uint16_t smetransactionId;
3240
3241 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003242 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243 return;
3244 }
3245
3246 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3247 &smetransactionId);
3248
3249 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3250
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003251 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3252 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003254 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003255 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303256 NULL, pSirAddts->req.tspec,
3257 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003258 return;
3259 }
3260#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3261 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3262 0);
3263#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3264
3265 /* if sta
3266 * - verify assoc state
3267 * - send addts request to ap
3268 * - wait for addts response from ap
3269 * if ap, just ignore with error log
3270 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003271 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3272 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3273 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003274
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003275 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003276 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303277 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003278 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279
3280 pStaDs =
3281 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3282 &psessionEntry->dph.dphHashTable);
3283
3284 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003285 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303286 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003287 }
3288
3289 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3290 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003291 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303292 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003293 }
3294
3295 pSirAddts->req.wsmTspecPresent = 0;
3296 pSirAddts->req.wmeTspecPresent = 0;
3297 pSirAddts->req.lleTspecPresent = 0;
3298
3299 if ((pStaDs->wsmEnabled) &&
3300 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3301 SIR_MAC_ACCESSPOLICY_EDCA))
3302 pSirAddts->req.wsmTspecPresent = 1;
3303 else if (pStaDs->wmeEnabled)
3304 pSirAddts->req.wmeTspecPresent = 1;
3305 else if (pStaDs->lleEnabled)
3306 pSirAddts->req.lleTspecPresent = 1;
3307 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003308 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303309 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003310 }
3311
3312 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3313 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003314 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003315 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303316 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003317 }
3318
3319 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003320 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321 pMac->lim.gLimAddtsReq.req.dialogToken,
3322 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3323 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3324 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303325 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003326 }
3327
3328 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3329
3330 /* save the addts request */
3331 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303332 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003333 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3334
3335 /* ship out the message now */
3336 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3337 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303338 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003339 /* start a timer to wait for the response */
3340 if (pSirAddts->timeout)
3341 timeout = pSirAddts->timeout;
3342 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003343 QDF_STATUS_SUCCESS) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303344 pe_debug("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003345 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303346 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003347 }
3348
3349 timeout = SYS_MS_TO_TICKS(timeout);
3350 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3351 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003352 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303353 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003354 }
3355 pMac->lim.gLimAddtsRspTimerCount++;
3356 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3357 pMac->lim.gLimAddtsRspTimerCount) !=
3358 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003359 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303360 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003361 }
3362 MTRACE(mac_trace
3363 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3364 eLIM_ADDTS_RSP_TIMER));
3365
3366 /* add the sessionId to the timer object */
3367 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3368 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3369 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003370 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303371 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003372 }
3373 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303374
3375send_failure_addts_rsp:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003376 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303377 psessionEntry, pSirAddts->req.tspec,
3378 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003379}
3380
3381static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3382{
3383 tSirMacAddr peerMacAddr;
3384 uint8_t ac;
3385 tSirMacTSInfo *pTsinfo;
3386 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3387 tpDphHashNode pStaDs = NULL;
3388 tpPESession psessionEntry;
3389 uint8_t sessionId;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003390 uint32_t status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003391 uint8_t smesessionId;
3392 uint16_t smetransactionId;
3393
3394 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3395 &smetransactionId);
3396
3397 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003398 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003399 &sessionId);
3400 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003401 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003402 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003403 goto end;
3404 }
3405#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3406 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3407 0);
3408#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3409
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003410 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003411 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003412 pe_err("lim_validate_delts_req failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003413 status = QDF_STATUS_E_FAILURE;
3414 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_E_FAILURE, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003415 smesessionId, smetransactionId);
3416 return;
3417 }
3418
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003419 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3420 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003421 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3422
3423 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3424 pDeltsReq->req.wmeTspecPresent,
3425 &pDeltsReq->req.tsinfo,
3426 &pDeltsReq->req.tspec, psessionEntry);
3427
3428 pTsinfo =
3429 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3430 tsinfo : &pDeltsReq->req.tsinfo;
3431
3432 /* We've successfully send DELTS frame to AP. Update the
3433 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3434 * is no longer trigger enabled or delivery enabled
3435 */
3436 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3437 pTsinfo, CLEAR_UAPSD_MASK);
3438
3439 /* We're deleting the TSPEC, so this particular AC is no longer
3440 * admitted. PE needs to downgrade the EDCA
3441 * parameters(for the AC for which TS is being deleted) to the
3442 * next best AC for which ACM is not enabled, and send the
3443 * updated values to HAL.
3444 */
3445 ac = upToAc(pTsinfo->traffic.userPrio);
3446
3447 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3448 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3449 ~(1 << ac);
3450 } else if (pTsinfo->traffic.direction ==
3451 SIR_MAC_DIRECTION_DNLINK) {
3452 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3453 ~(1 << ac);
3454 } else if (pTsinfo->traffic.direction ==
3455 SIR_MAC_DIRECTION_BIDIR) {
3456 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3457 ~(1 << ac);
3458 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3459 ~(1 << ac);
3460 }
3461
3462 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3463 psessionEntry);
3464
3465 pStaDs =
3466 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3467 &psessionEntry->dph.dphHashTable);
3468 if (pStaDs != NULL) {
3469 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003470 pStaDs->bssId, false);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003471 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003472 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003473 pe_err("Self entry missing in Hash Table");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003474 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003475 }
3476#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003477 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003478#endif
3479
3480 /* send an sme response back */
3481end:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003482 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_SUCCESS, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003483 smesessionId, smetransactionId);
3484}
3485
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303486void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003487{
3488 /* fetch the sessionEntry based on the sessionId */
3489 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003490
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003491 psessionEntry = pe_find_session_by_session_id(pMac,
3492 pMac->lim.limTimers.gLimAddtsRspTimer.
3493 sessionId);
3494 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003495 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496 return;
3497 }
3498
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003499 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003500 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003501 GET_LIM_SYSTEM_ROLE(psessionEntry));
3502 pMac->lim.gLimAddtsSent = false;
3503 return;
3504 }
3505
3506 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003507 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003508 return;
3509 }
3510
3511 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003512 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003513 pMac->lim.gLimAddtsRspTimerCount);
3514 return;
3515 }
3516 /* this a real response timeout */
3517 pMac->lim.gLimAddtsSent = false;
3518 pMac->lim.gLimAddtsRspTimerCount++;
3519
3520 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3521 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3522 psessionEntry->smeSessionId,
3523 psessionEntry->transactionId);
3524}
3525
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003526#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003527/**
3528 * __lim_process_sme_get_statistics_request()
3529 *
3530 ***FUNCTION:
3531 *
3532 *
3533 ***NOTE:
3534 *
3535 * @param pMac Pointer to Global MAC structure
3536 * @param *pMsgBuf A pointer to the SME message buffer
3537 * @return None
3538 */
3539static void
3540__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3541{
3542 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003543 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003544
3545 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3546
3547 msgQ.type = WMA_GET_STATISTICS_REQ;
3548
3549 msgQ.reserved = 0;
3550 msgQ.bodyptr = pMsgBuf;
3551 msgQ.bodyval = 0;
3552 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3553
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003554 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303555 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003556 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003557 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003558 return;
3559 }
3560
3561 return;
3562}
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003563#else
3564static void __lim_process_sme_get_statistics_request(
3565 struct sAniSirGlobal *mac_ctx, uint32_t *pMsgBuf) {}
3566#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003567
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003568#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003569/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003570 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003571 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003572 * @pMac: Pointer to Global MAC structure
3573 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003574 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003575 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003576 */
3577static void
3578__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3579{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003580 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003581
3582 msgQ.type = WMA_TSM_STATS_REQ;
3583 msgQ.reserved = 0;
3584 msgQ.bodyptr = pMsgBuf;
3585 msgQ.bodyval = 0;
3586 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3587
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003588 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303589 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003590 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003591 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003592 return;
3593 }
3594}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003595#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003596
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08003597static void lim_process_sme_set_addba_accept(tpAniSirGlobal mac_ctx,
3598 struct sme_addba_accept *msg)
3599{
3600 if (!msg) {
3601 pe_err("Msg Buffer is NULL");
3602 return;
3603 }
3604 if (!msg->addba_accept)
3605 mac_ctx->reject_addba_req = 1;
3606 else
3607 mac_ctx->reject_addba_req = 0;
3608}
3609
Arif Hussaineb8ba362018-03-07 19:15:13 -08003610static void lim_process_sme_update_edca_params(tpAniSirGlobal mac_ctx,
3611 uint32_t sme_session_id)
3612{
3613 tpPESession pe_session;
3614 tpDphHashNode sta_ds_ptr;
3615
3616 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3617 if (!pe_session) {
3618 pe_err("Session does not exist: sme_id %d", sme_session_id);
3619 return;
3620 }
3621 pe_session->gLimEdcaParamsActive[EDCA_AC_BE].no_ack =
3622 mac_ctx->no_ack_policy_cfg[EDCA_AC_BE];
3623 pe_session->gLimEdcaParamsActive[EDCA_AC_BK].no_ack =
3624 mac_ctx->no_ack_policy_cfg[EDCA_AC_BK];
3625 pe_session->gLimEdcaParamsActive[EDCA_AC_VI].no_ack =
3626 mac_ctx->no_ack_policy_cfg[EDCA_AC_VI];
3627 pe_session->gLimEdcaParamsActive[EDCA_AC_VO].no_ack =
3628 mac_ctx->no_ack_policy_cfg[EDCA_AC_VO];
3629 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3630 &pe_session->dph.dphHashTable);
3631 if (sta_ds_ptr)
3632 lim_send_edca_params(mac_ctx,
3633 pe_session->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003634 sta_ds_ptr->bssId, false);
Arif Hussaineb8ba362018-03-07 19:15:13 -08003635 else
3636 pe_err("Self entry missing in Hash Table");
3637}
3638
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07003639static void lim_process_sme_update_mu_edca_params(tpAniSirGlobal mac_ctx,
3640 uint32_t sme_session_id)
3641{
3642 tpPESession pe_session;
3643 tpDphHashNode sta_ds_ptr;
3644
3645 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3646 if (!pe_session) {
3647 pe_err("Session does not exist: sme_id %d", sme_session_id);
3648 return;
3649 }
3650 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3651 &pe_session->dph.dphHashTable);
3652 if (sta_ds_ptr)
3653 lim_send_edca_params(mac_ctx, mac_ctx->usr_mu_edca_params,
3654 sta_ds_ptr->bssId, true);
3655 else
3656 pe_err("Self entry missing in Hash Table");
3657}
3658
Naveen Rawat8029a402017-06-01 10:54:19 -07003659static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3660 struct update_config *msg)
3661{
3662 tpPESession pe_session;
3663
3664 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3665 if (msg == NULL) {
3666 pe_err("Buffer is Pointing to NULL");
3667 return;
3668 }
3669
3670 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3671 msg->sme_session_id);
3672 if (pe_session == NULL) {
3673 pe_warn("Session does not exist for given BSSID");
3674 return;
3675 }
3676
3677 switch (msg->capab) {
3678 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3679 pe_session->htConfig.ht_rx_ldpc = msg->value;
3680 break;
3681 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3682 pe_session->htConfig.ht_tx_stbc = msg->value;
3683 break;
3684 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3685 pe_session->htConfig.ht_rx_stbc = msg->value;
3686 break;
3687 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3688 pe_session->htConfig.ht_sgi20 = msg->value;
3689 break;
3690 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3691 pe_session->htConfig.ht_sgi40 = msg->value;
3692 break;
3693 }
3694
3695 if (LIM_IS_AP_ROLE(pe_session)) {
3696 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3697 lim_send_beacon_ind(mac_ctx, pe_session);
3698 }
3699}
3700
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003701void
3702lim_send_vdev_restart(tpAniSirGlobal pMac,
3703 tpPESession psessionEntry, uint8_t sessionId)
3704{
3705 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003706 struct scheduler_msg msgQ = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003707 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003708
3709 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003710 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003711 return;
3712 }
3713
3714 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303715 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003716 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003717 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003718 return;
3719 }
3720
3721 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3722 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003723 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003724
3725 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3726 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3727 msgQ.bodyval = 0;
3728
3729 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003730 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003731 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303732 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003733 }
3734}
3735
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303736/**
3737 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3738 * @mac_ctx: Pointer to Global MAC structure
3739 * @msg_buf: Pointer to SME message buffer
3740 *
3741 * Return: None
3742 */
3743static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3744 uint32_t *msg_buf)
3745{
3746 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003747 struct scheduler_msg wma_msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003748 QDF_STATUS status;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303749 tSirRoamOffloadScanReq *req_buffer;
3750 uint16_t local_ie_len;
3751 uint8_t *local_ie_buf;
3752
3753 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3754 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3755 req_buffer->sessionId);
3756
3757 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3758 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003759 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303760 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303761 return;
3762 }
3763
3764 local_ie_len = req_buffer->assoc_ie.length;
3765 /* Update ext cap IE if present */
3766 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003767 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3768 local_ie_buf, &local_ie_len)) {
3769 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003770 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3771 req_buffer->assoc_ie.length = local_ie_len;
3772 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3773 local_ie_buf, local_ie_len);
3774 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303775 }
3776 qdf_mem_free(local_ie_buf);
3777
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303778 if (pe_session)
3779 lim_update_fils_rik(pe_session, req_buffer);
3780
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303781 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3782 wma_msg.bodyptr = req_buffer;
3783
3784 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003785 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003786 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303787 qdf_mem_free(req_buffer);
3788 }
3789}
3790
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303791/*
3792 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3793 * @mac_ctx: Pointer to global mac context
3794 * @session: Pointer to PE session
3795 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3796 * 1 - Disable broadcast SSID
3797 *
3798 * Return: None
3799 */
3800static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3801 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003802{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003803 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003804 session->ssidHidden, ssid_hidden);
3805
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003806 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303807 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003808 } else {
3809 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05303810 return;
3811 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003812
3813 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303814 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003815
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003816 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303817}
3818
3819/**
3820 * __lim_process_sme_session_update - process SME session update msg
3821 *
3822 * @mac_ctx: Pointer to global mac context
3823 * @msg_buf: Pointer to the received message buffer
3824 *
3825 * Return: None
3826 */
3827static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
3828 uint32_t *msg_buf)
3829{
3830 struct sir_update_session_param *msg;
3831 tpPESession session;
3832
3833 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003834 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303835 return;
3836 }
3837
3838 msg = (struct sir_update_session_param *) msg_buf;
3839
3840 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
3841 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003842 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303843 msg->session_id);
3844 return;
3845 }
3846
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003847 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303848 msg->param_type, msg->param_val);
3849 switch (msg->param_type) {
3850 case SIR_PARAM_SSID_HIDDEN:
3851 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
3852 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303853 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
3854 session->ignore_assoc_disallowed = msg->param_val;
3855 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303856 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003857 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303858 break;
3859 }
3860}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003861
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003862/*
3863 Update the beacon Interval dynamically if beaconInterval is different in MCC
3864 */
3865static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3866{
3867 tpSirChangeBIParams pChangeBIParams;
3868 tpPESession psessionEntry;
3869 uint8_t sessionId = 0;
3870 tUpdateBeaconParams beaconParams;
3871
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003872 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003873
3874 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003875 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003876 return;
3877 }
3878
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303879 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003880 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
3881
3882 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08003883 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003884 &sessionId);
3885 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003886 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003887 return;
3888 }
3889
3890 /*Update sessionEntry Beacon Interval */
3891 if (psessionEntry->beaconParams.beaconInterval !=
3892 pChangeBIParams->beaconInterval) {
3893 psessionEntry->beaconParams.beaconInterval =
3894 pChangeBIParams->beaconInterval;
3895 }
3896
3897 /*Update sch beaconInterval */
3898 if (pMac->sch.schObject.gSchBeaconInterval !=
3899 pChangeBIParams->beaconInterval) {
3900 pMac->sch.schObject.gSchBeaconInterval =
3901 pChangeBIParams->beaconInterval;
3902
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003903 pe_debug("LIM send update BeaconInterval Indication: %d",
3904 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003905
3906 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
3907 /* Update beacon */
3908 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3909
3910 beaconParams.bssIdx = psessionEntry->bssIdx;
3911 /* Set change in beacon Interval */
3912 beaconParams.beaconInterval =
3913 pChangeBIParams->beaconInterval;
3914 beaconParams.paramChangeBitmap =
3915 PARAM_BCN_INTERVAL_CHANGED;
3916 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
3917 }
3918 }
3919
3920 return;
3921} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
3922
3923#ifdef QCA_HT_2040_COEX
3924static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
3925 uint32_t *pMsgBuf)
3926{
3927 tpSirSetHT2040Mode pSetHT2040Mode;
3928 tpPESession psessionEntry;
3929 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003930 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003931 tUpdateVHTOpMode *pHtOpMode = NULL;
3932 uint16_t staId = 0;
3933 tpDphHashNode pStaDs = NULL;
3934
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003935 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003936 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003937 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003938 return;
3939 }
3940
3941 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
3942
3943 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08003944 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003945 &sessionId);
3946 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003947 pe_debug("Session does not exist for given BSSID");
3948 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003949 return;
3950 }
3951
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003952 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003953 pSetHT2040Mode->cbMode);
3954 /*Update sessionEntry HT related fields */
3955 switch (pSetHT2040Mode->cbMode) {
3956 case PHY_SINGLE_CHANNEL_CENTERED:
3957 psessionEntry->htSecondaryChannelOffset =
3958 PHY_SINGLE_CHANNEL_CENTERED;
3959 psessionEntry->htRecommendedTxWidthSet = 0;
3960 if (pSetHT2040Mode->obssEnabled)
3961 psessionEntry->htSupportedChannelWidthSet
3962 = eHT_CHANNEL_WIDTH_40MHZ;
3963 else
3964 psessionEntry->htSupportedChannelWidthSet
3965 = eHT_CHANNEL_WIDTH_20MHZ;
3966 break;
3967 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
3968 psessionEntry->htSecondaryChannelOffset =
3969 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3970 psessionEntry->htRecommendedTxWidthSet = 1;
3971 break;
3972 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
3973 psessionEntry->htSecondaryChannelOffset =
3974 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3975 psessionEntry->htRecommendedTxWidthSet = 1;
3976 break;
3977 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003978 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003979 return;
3980 }
3981
3982 /* Update beacon */
3983 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3984 lim_send_beacon_ind(pMac, psessionEntry);
3985
3986 /* update OP Mode for each associated peer */
3987 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
3988 pStaDs = dph_get_hash_entry(pMac, staId,
3989 &psessionEntry->dph.dphHashTable);
3990 if (NULL == pStaDs)
3991 continue;
3992
3993 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303994 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003995 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003996 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003997 return;
3998 }
3999 pHtOpMode->opMode =
4000 (psessionEntry->htSecondaryChannelOffset ==
4001 PHY_SINGLE_CHANNEL_CENTERED) ?
4002 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4003 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304004 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004005 sizeof(tSirMacAddr));
4006 pHtOpMode->smesessionId = sessionId;
4007
4008 msg.type = WMA_UPDATE_OP_MODE;
4009 msg.reserved = 0;
4010 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004011 if (!QDF_IS_STATUS_SUCCESS
4012 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
4013 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304014 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004015 return;
4016 }
Jeff Johnson47d75242018-05-12 15:58:53 -07004017 pe_debug("Notified FW about OP mode: %d for staId=%d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004018 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004019
4020 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004021 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004022 }
4023
4024 return;
4025}
4026#endif
4027
4028/* -------------------------------------------------------------------- */
4029/**
4030 * __lim_process_report_message
4031 *
4032 * FUNCTION: Processes the next received Radio Resource Management message
4033 *
4034 * LOGIC:
4035 *
4036 * ASSUMPTIONS:
4037 *
4038 * NOTE:
4039 *
4040 * @param None
4041 * @return None
4042 */
4043
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004044static void __lim_process_report_message(tpAniSirGlobal pMac,
4045 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004046{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004047 switch (pMsg->type) {
4048 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4049 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4050 break;
4051 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004052 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004053 break;
4054 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004055 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004056 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004057}
4058
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004059/* -------------------------------------------------------------------- */
4060/**
4061 * lim_send_set_max_tx_power_req
4062 *
4063 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4064 *
4065 * LOGIC:
4066 *
4067 * ASSUMPTIONS:
4068 *
4069 * NOTE:
4070 *
4071 * @param txPower txPower to be set.
4072 * @param pSessionEntry session entry.
4073 * @return None
4074 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004075QDF_STATUS
Amar Singhala297bfa2015-10-15 15:07:29 -07004076lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004077 tpPESession pSessionEntry)
4078{
4079 tpMaxTxPowerParams pMaxTxParams = NULL;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004080 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004081 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004082
4083 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004084 pe_err("Invalid parameters");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004085 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004086 }
4087
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304088 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004089 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004090 pe_err("Unable to allocate memory for pMaxTxParams");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004091 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004092
4093 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004094 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304095 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304096 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304097 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004098 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304099 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004100
4101 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4102 msgQ.bodyptr = pMaxTxParams;
4103 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004104 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004105 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4106 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004107 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004108 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304109 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004110 }
4111 return retCode;
4112}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004113
4114/**
4115 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4116 *
4117 * @mac_ctx: Pointer to Global MAC structure
4118 * @msg_buf: pointer to the SME message buffer
4119 *
4120 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4121 * from SME. It Register this information within PE.
4122 *
4123 * Return: None
4124 */
4125static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4126 uint32_t *msg_buf)
4127{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304128 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004129 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4130 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4131 struct mgmt_frm_reg_info *next = NULL;
4132 bool match = false;
4133
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004134 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004135 sme_req->registerFrame, sme_req->frameType,
4136 sme_req->matchLen);
4137 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304138 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304139 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4140 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304141 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004142
4143 while (lim_mgmt_regn != NULL) {
4144 if (lim_mgmt_regn->frameType != sme_req->frameType)
4145 goto skip_match;
4146 if (sme_req->matchLen) {
4147 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304148 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004149 sme_req->matchData,
4150 lim_mgmt_regn->matchLen))) {
4151 /* found match! */
4152 match = true;
4153 break;
4154 }
4155 } else {
4156 /* found match! */
4157 match = true;
4158 break;
4159 }
4160skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304161 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304162 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004163 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304164 (qdf_list_node_t *)lim_mgmt_regn,
4165 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304166 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004167 lim_mgmt_regn = next;
4168 next = NULL;
4169 }
4170 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304171 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004172 if (QDF_STATUS_SUCCESS ==
4173 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004174 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004175 (qdf_list_node_t *)lim_mgmt_regn))
4176 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304177 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004178 }
4179
4180 if (sme_req->registerFrame) {
4181 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304182 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004183 sme_req->matchLen);
4184 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004185 lim_mgmt_regn->frameType = sme_req->frameType;
4186 lim_mgmt_regn->matchLen = sme_req->matchLen;
4187 lim_mgmt_regn->sessionId = sme_req->sessionId;
4188 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304189 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004190 sme_req->matchData,
4191 sme_req->matchLen);
4192 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304193 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004194 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304195 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004196 gLimMgmtFrameRegistratinQueue,
4197 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304198 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004199 &mac_ctx->lim.lim_frame_register_lock);
4200 }
4201 }
4202 return;
4203}
4204
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004205static void
4206__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4207{
4208 tpSirResetAPCapsChange pResetCapsChange;
4209 tpPESession psessionEntry;
4210 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004211
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004212 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004213 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004214 return;
4215 }
4216
4217 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4218 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004219 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4220 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004221 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004222 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004223 return;
4224 }
4225
4226 psessionEntry->limSentCapsChangeNtf = false;
4227 return;
4228}
4229
4230/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304231 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4232 * indication callback in PE.
4233 * @mac_ptr: Mac pointer
4234 * @msg_buf: Msg pointer containing the callback
4235 *
4236 * This function is used save the Management frame
4237 * indication callback in PE.
4238 *
4239 * Return: None
4240 */
4241static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4242 uint32_t *msg_buf)
4243{
4244 struct sir_sme_mgmt_frame_cb_req *sme_req =
4245 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4246
4247 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004248 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304249 return;
4250 }
4251 if (sme_req->callback)
4252 mac_ctx->mgmt_frame_ind_cb =
4253 (sir_mgmt_frame_ind_callback)sme_req->callback;
4254 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004255 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304256}
4257
4258/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304259 *__lim_process_send_disassoc_frame: function processes disassoc frame
4260 * @mac_ctx: pointer to mac context
4261 * @msg_buf: message buffer
4262 *
4263 * function processes disassoc request received from SME
4264 *
4265 * return: none
4266 */
4267static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4268 uint32_t *msg_buf)
4269{
4270 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004271 QDF_STATUS status;
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304272 tpPESession session_entry = NULL;
4273 uint8_t sme_session_id;
4274 uint16_t sme_trans_id;
4275
4276 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004277 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304278 return;
4279 }
4280
4281 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4282 &sme_trans_id);
4283
4284 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4285 &sme_send_disassoc_frame_req,
4286 (uint8_t *)msg_buf);
4287
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004288 if ((QDF_STATUS_E_FAILURE == status) ||
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304289 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4290 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004291 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304292 return;
4293 }
4294
4295 session_entry = pe_find_session_by_sme_session_id(
4296 mac_ctx, sme_session_id);
4297 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004298 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304299 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4300 return;
4301 }
4302
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004303 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 +05304304 sme_send_disassoc_frame_req.msg_type,
4305 sme_send_disassoc_frame_req.length,
4306 sme_send_disassoc_frame_req.session_id,
4307 sme_send_disassoc_frame_req.trans_id,
4308 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4309 sme_send_disassoc_frame_req.reason,
4310 sme_send_disassoc_frame_req.wait_for_ack);
4311
4312 lim_send_disassoc_mgmt_frame(mac_ctx,
4313 sme_send_disassoc_frame_req.reason,
4314 sme_send_disassoc_frame_req.peer_mac,
4315 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4316}
4317
4318/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004319 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4320 * @mac_ctx: Pointer to Global MAC structure
4321 * @pdev_id: pdev id to set the IE.
4322 * @nss: Nss values to prepare the HT IE.
4323 *
4324 * Prepares the HT IE with self capabilities for different
4325 * Nss values and sends the set HT IE req to FW.
4326 *
4327 * Return: None
4328 */
4329static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4330 uint8_t nss)
4331{
4332 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004333 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004334 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004335 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004336 tHtCaps *p_ht_cap;
4337 int i;
4338
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004339 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004340 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4341 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004342 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004343 return;
4344 }
4345 ie_params->nss = i;
4346 ie_params->pdev_id = pdev_id;
4347 ie_params->ie_type = DOT11_HT_IE;
4348 /* 2 for IE len and EID */
4349 ie_params->ie_len = 2 + sizeof(tHtCaps);
4350 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4351 if (NULL == ie_params->ie_ptr) {
4352 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004353 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004354 return;
4355 }
4356 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4357 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4358 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4359 ie_params->ie_len);
4360
4361 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004362 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4363 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004364 if (NULL == p_ie) {
4365 qdf_mem_free(ie_params->ie_ptr);
4366 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004367 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004368 return;
4369 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004370 p_ht_cap = (tHtCaps *)&p_ie[2];
4371 p_ht_cap->supportedMCSSet[1] = 0;
4372 p_ht_cap->txSTBC = 0;
4373 }
4374
4375 msg.type = WMA_SET_PDEV_IE_REQ;
4376 msg.bodyptr = ie_params;
4377 msg.bodyval = 0;
4378
4379 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004380 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004381 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004382 qdf_mem_free(ie_params->ie_ptr);
4383 qdf_mem_free(ie_params);
4384 return;
4385 }
4386 }
4387}
4388
4389/**
4390 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4391 * @mac_ctx: Pointer to Global MAC structure
4392 * @pdev_id: pdev id to set the IE.
4393 * @nss: Nss values to prepare the VHT IE.
4394 *
4395 * Prepares the VHT IE with self capabilities for different
4396 * Nss values and sends the set VHT IE req to FW.
4397 *
4398 * Return: None
4399 */
4400static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4401 uint8_t nss)
4402{
4403 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004404 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004405 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004406 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004407 tSirMacVHTCapabilityInfo *vht_cap;
4408 int i;
4409 tSirVhtMcsInfo *vht_mcs;
4410
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004411 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004412 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4413 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004414 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004415 return;
4416 }
4417 ie_params->nss = i;
4418 ie_params->pdev_id = pdev_id;
4419 ie_params->ie_type = DOT11_VHT_IE;
4420 /* 2 for IE len and EID */
4421 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4422 sizeof(tSirVhtMcsInfo);
4423 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4424 if (NULL == ie_params->ie_ptr) {
4425 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004426 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004427 return;
4428 }
4429 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4430 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4431 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4432 ie_params->ie_len);
4433
4434 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004435 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4436 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004437 if (NULL == p_ie) {
4438 qdf_mem_free(ie_params->ie_ptr);
4439 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004440 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004441 return;
4442 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004443 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4444 vht_cap->txSTBC = 0;
4445 vht_mcs =
4446 (tSirVhtMcsInfo *)&p_ie[2 +
4447 sizeof(tSirMacVHTCapabilityInfo)];
4448 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4449 vht_mcs->rxHighest =
4450 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4451 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4452 vht_mcs->txHighest =
4453 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4454 }
4455 msg.type = WMA_SET_PDEV_IE_REQ;
4456 msg.bodyptr = ie_params;
4457 msg.bodyval = 0;
4458
4459 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004460 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004461 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004462 qdf_mem_free(ie_params->ie_ptr);
4463 qdf_mem_free(ie_params);
4464 return;
4465 }
4466 }
4467}
4468
4469/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004470 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4471 * @mac_ctx: Pointer to Global MAC structure
4472 * @msg_buf: Pointer to the SME message buffer
4473 *
4474 * This function is called by limProcessMessageQueue(). This function sets the
4475 * VDEV IEs to the FW.
4476 *
4477 * Return: None
4478 */
4479static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4480 uint32_t *msg_buf)
4481{
4482 struct sir_set_vdev_ies_per_band *p_msg =
4483 (struct sir_set_vdev_ies_per_band *)msg_buf;
4484
4485 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004486 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004487 return;
4488 }
4489
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004490 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004491 p_msg->vdev_id);
4492 /* intentionally using NULL here so that self capabilty are sent */
4493 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4494 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004495 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004496}
4497
4498/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004499 * lim_process_set_pdev_IEs() - process the set pdev IE req
4500 * @mac_ctx: Pointer to Global MAC structure
4501 * @msg_buf: Pointer to the SME message buffer
4502 *
4503 * This function is called by limProcessMessageQueue(). This
4504 * function sets the PDEV IEs to the FW.
4505 *
4506 * Return: None
4507 */
4508static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4509{
4510 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4511
4512 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4513
4514 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004515 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004516 return;
4517 }
4518
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004519 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004520 ht_vht_cfg->nss);
4521 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4522
4523 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4524 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4525 ht_vht_cfg->nss);
4526}
4527
4528/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304529 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4530 *
4531 * access policy
4532 * @mac_ctx: pointer to mac context
4533 * @msg: message buffer
4534 *
4535 * function processes vendor IE and access policy from SME and updates PE
4536 *
4537 * session entry
4538 *
4539 * return: none
4540*/
4541static void lim_process_sme_update_access_policy_vendor_ie(
4542 tpAniSirGlobal mac_ctx,
4543 uint32_t *msg)
4544{
4545 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4546 struct sPESession *pe_session_entry;
Pragaspathi Thilagaraj9b7a1162018-05-07 16:28:13 +05304547 uint16_t num_bytes;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304548
4549 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004550 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304551 return;
4552 }
4553 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4554 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4555 update_vendor_ie->sme_session_id);
4556
4557 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004558 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304559 update_vendor_ie->sme_session_id);
4560 return;
4561 }
4562 if (pe_session_entry->access_policy_vendor_ie)
4563 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4564
4565 num_bytes = update_vendor_ie->ie[1] + 2;
4566 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4567
4568 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004569 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304570 return;
4571 }
4572 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4573 &update_vendor_ie->ie[0], num_bytes);
4574
4575 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4576}
4577
4578/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004579 * lim_process_sme_req_messages()
4580 *
4581 ***FUNCTION:
4582 * This function is called by limProcessMessageQueue(). This
4583 * function processes SME request messages from HDD or upper layer
4584 * application.
4585 *
4586 ***LOGIC:
4587 *
4588 ***ASSUMPTIONS:
4589 *
4590 ***NOTE:
4591 *
4592 * @param pMac Pointer to Global MAC structure
4593 * @param msgType Indicates the SME message type
4594 * @param *pMsgBuf A pointer to the SME message buffer
4595 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4596 * false - if pMsgBuf is not to be freed.
4597 */
4598
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004599bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4600 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004601{
Jeff Johnson33142e62018-05-06 17:58:36 -07004602 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 -08004603 uint32_t *pMsgBuf = pMsg->bodyptr;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004604
4605 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004606 lim_msg_str(pMsg->type), pMsg->type,
4607 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4608 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004609
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004610 /* If no insert NOA required then execute the code below */
4611
4612 switch (pMsg->type) {
4613 case eWNI_SME_SYS_READY_IND:
4614 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4615 break;
4616
4617 case eWNI_SME_START_BSS_REQ:
4618 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4619 break;
4620
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004621 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4622 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4623 break;
4624 case eWNI_SME_JOIN_REQ:
4625 __lim_process_sme_join_req(pMac, pMsgBuf);
4626 break;
4627
4628 case eWNI_SME_REASSOC_REQ:
4629 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4630 break;
4631
4632 case eWNI_SME_DISASSOC_REQ:
4633 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4634 break;
4635
4636 case eWNI_SME_DISASSOC_CNF:
4637 case eWNI_SME_DEAUTH_CNF:
4638 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4639 break;
4640
4641 case eWNI_SME_DEAUTH_REQ:
4642 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4643 break;
4644
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304645 case eWNI_SME_SEND_DISASSOC_FRAME:
4646 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4647 break;
4648
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004649 case eWNI_SME_SETCONTEXT_REQ:
4650 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4651 break;
4652
4653 case eWNI_SME_STOP_BSS_REQ:
4654 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4655 break;
4656
4657 case eWNI_SME_ASSOC_CNF:
4658 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004659 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004660 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4661 pMsgBuf);
4662 break;
4663
4664 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004665 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004666 __lim_process_sme_addts_req(pMac, pMsgBuf);
4667 break;
4668
4669 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004670 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004671 __lim_process_sme_delts_req(pMac, pMsgBuf);
4672 break;
4673
4674 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004675 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004676 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4677 break;
4678
4679 case eWNI_SME_GET_STATISTICS_REQ:
4680 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4681 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4682 bufConsumed = false;
4683 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004684#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004685 case eWNI_SME_GET_TSM_STATS_REQ:
4686 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4687 bufConsumed = false;
4688 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004689#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004690 case eWNI_SME_GET_ASSOC_STAS_REQ:
4691 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4692 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304693 case eWNI_SME_SESSION_UPDATE_PARAM:
4694 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004695 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304696 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4697 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4698 bufConsumed = false;
4699 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004700 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4701 /* Update the beaconInterval */
4702 __lim_process_sme_change_bi(pMac, pMsgBuf);
4703 break;
4704
4705#ifdef QCA_HT_2040_COEX
4706 case eWNI_SME_SET_HT_2040_MODE:
4707 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4708 break;
4709#endif
4710
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004711 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4712 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4713 __lim_process_report_message(pMac, pMsg);
4714 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004715
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004716 case eWNI_SME_FT_PRE_AUTH_REQ:
4717 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4718 break;
4719 case eWNI_SME_FT_UPDATE_KEY:
4720 lim_process_ft_update_key(pMac, pMsgBuf);
4721 break;
4722
4723 case eWNI_SME_FT_AGGR_QOS_REQ:
4724 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4725 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004726
4727 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4728 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4729 break;
4730#ifdef FEATURE_WLAN_TDLS
4731 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4732 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4733 break;
4734 case eWNI_SME_TDLS_ADD_STA_REQ:
4735 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4736 break;
4737 case eWNI_SME_TDLS_DEL_STA_REQ:
4738 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4739 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004740#endif
4741 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4742 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4743 break;
4744
4745 case eWNI_SME_CHANNEL_CHANGE_REQ:
4746 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4747 break;
4748
4749 case eWNI_SME_START_BEACON_REQ:
4750 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4751 break;
4752
4753 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4754 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4755 break;
4756
4757 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4758 lim_process_update_add_ies(pMac, pMsgBuf);
4759 break;
4760
4761 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4762 lim_process_modify_add_ies(pMac, pMsgBuf);
4763 break;
4764 case eWNI_SME_SET_HW_MODE_REQ:
4765 lim_process_set_hw_mode(pMac, pMsgBuf);
4766 break;
4767 case eWNI_SME_NSS_UPDATE_REQ:
4768 lim_process_nss_update_request(pMac, pMsgBuf);
4769 break;
4770 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4771 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4772 break;
4773 case eWNI_SME_SET_IE_REQ:
4774 lim_process_set_ie_req(pMac, pMsgBuf);
4775 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304776 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4777 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
4778 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304779 case eWNI_SME_EXT_CHANGE_CHANNEL:
4780 lim_process_ext_change_channel(pMac, pMsgBuf);
4781 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08004782 case eWNI_SME_SET_ANTENNA_MODE_REQ:
4783 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
4784 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004785 case eWNI_SME_PDEV_SET_HT_VHT_IE:
4786 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07004787 break;
4788 case eWNI_SME_SET_VDEV_IES_PER_BAND:
4789 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
4790 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304791 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
4792 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
4793 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07004794 case eWNI_SME_UPDATE_CONFIG:
4795 lim_process_sme_update_config(pMac,
4796 (struct update_config *)pMsgBuf);
4797 break;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004798 case eWNI_SME_SET_ADDBA_ACCEPT:
4799 lim_process_sme_set_addba_accept(pMac,
4800 (struct sme_addba_accept *)pMsgBuf);
4801 break;
Arif Hussaineb8ba362018-03-07 19:15:13 -08004802 case eWNI_SME_UPDATE_EDCA_PROFILE:
4803 lim_process_sme_update_edca_params(pMac, pMsg->bodyval);
4804 break;
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07004805 case WNI_SME_UPDATE_MU_EDCA_PARAMS:
4806 lim_process_sme_update_mu_edca_params(pMac, pMsg->bodyval);
4807 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004808 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304809 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004810 pMsg->bodyptr = NULL;
4811 break;
4812 } /* switch (msgType) */
4813
4814 return bufConsumed;
4815} /*** end lim_process_sme_req_messages() ***/
4816
4817/**
4818 * lim_process_sme_start_beacon_req()
4819 *
4820 ***FUNCTION:
4821 * This function is called by limProcessMessageQueue(). This
4822 * function processes SME request messages from HDD or upper layer
4823 * application.
4824 *
4825 ***LOGIC:
4826 *
4827 ***ASSUMPTIONS:
4828 *
4829 ***NOTE:
4830 *
4831 * @param pMac Pointer to Global MAC structure
4832 * @param msgType Indicates the SME message type
4833 * @param *pMsgBuf A pointer to the SME message buffer
4834 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4835 * false - if pMsgBuf is not to be freed.
4836 */
4837static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
4838{
4839 tpSirStartBeaconIndication pBeaconStartInd;
4840 tpPESession psessionEntry;
4841 uint8_t sessionId; /* PE sessionID */
4842
4843 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004844 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004845 return;
4846 }
4847
4848 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
4849 psessionEntry = pe_find_session_by_bssid(pMac,
4850 pBeaconStartInd->bssid,
4851 &sessionId);
4852 if (psessionEntry == NULL) {
4853 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004854 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004855 return;
4856 }
4857
4858 if (pBeaconStartInd->beaconStartStatus == true) {
4859 /*
4860 * Currently this Indication comes from SAP
4861 * to start Beacon Tx on a DFS channel
4862 * since beaconing has to be done on DFS
4863 * channel only after CAC WAIT is completed.
4864 * On a DFS Channel LIM does not start beacon
4865 * Tx right after the WMA_ADD_BSS_RSP.
4866 */
4867 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05304868 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004869 FL("Start Beacon with ssid %s Ch %d"),
4870 psessionEntry->ssId.ssId,
4871 psessionEntry->currentOperChannel);
4872 lim_send_beacon_ind(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08004873 lim_enable_obss_detection_config(pMac, psessionEntry);
Arif Hussain05fb4872018-01-03 16:02:55 -08004874 lim_send_obss_color_collision_cfg(pMac, psessionEntry,
4875 OBSS_COLOR_COLLISION_DETECTION);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004876 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004877 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004878 return;
4879 }
4880}
4881
4882/**
4883 * lim_process_sme_channel_change_request() - process sme ch change req
4884 *
4885 * @mac_ctx: Pointer to Global MAC structure
4886 * @msg_buf: pointer to the SME message buffer
4887 *
4888 * This function is called to process SME_CHANNEL_CHANGE_REQ message
4889 *
4890 * Return: None
4891 */
4892static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
4893 uint32_t *msg_buf)
4894{
4895 tpSirChanChangeRequest ch_change_req;
4896 tpPESession session_entry;
4897 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07004898 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004899 uint32_t val = 0;
4900
4901 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004902 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004903 return;
4904 }
4905 ch_change_req = (tpSirChanChangeRequest)msg_buf;
4906
4907 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
4908 ch_change_req->targetChannel);
4909
4910 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
4911 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004912 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004913 return;
4914 }
4915
4916 session_entry = pe_find_session_by_bssid(mac_ctx,
4917 ch_change_req->bssid, &session_id);
4918 if (session_entry == NULL) {
4919 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004920 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004921 return;
4922 }
4923
Manjunathappa Prakash34fda792018-02-07 18:23:42 -08004924 if ((session_entry->currentOperChannel ==
4925 ch_change_req->targetChannel) &&
4926 (session_entry->ch_width == ch_change_req->ch_width)) {
4927 pe_err("Target channel and mode is same as current channel and mode channel %d and mode %d",
4928 session_entry->currentOperChannel, session_entry->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004929 return;
4930 }
4931
4932 if (LIM_IS_AP_ROLE(session_entry))
4933 session_entry->channelChangeReasonCode =
4934 LIM_SWITCH_CHANNEL_SAP_DFS;
4935 else
4936 session_entry->channelChangeReasonCode =
4937 LIM_SWITCH_CHANNEL_OPERATION;
4938
Bala Venkateshb39ed152017-12-26 19:35:27 +05304939 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d, nw_type %d, dot11mode %d",
4940 session_entry->currentOperChannel,
4941 ch_change_req->targetChannel,
4942 ch_change_req->ch_width,
4943 ch_change_req->nw_type,
4944 ch_change_req->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004945
4946 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004947 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004948 session_entry->ch_center_freq_seg0 =
4949 ch_change_req->center_freq_seg_0;
4950 session_entry->ch_center_freq_seg1 =
4951 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004952 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004953 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004954 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004955 session_entry->htRecommendedTxWidthSet =
4956 session_entry->htSupportedChannelWidthSet;
4957 session_entry->currentOperChannel =
4958 ch_change_req->targetChannel;
4959 session_entry->limRFBand =
4960 lim_get_rf_band(session_entry->currentOperChannel);
Vignesh Viswanathan153ae932018-04-11 14:24:13 +05304961
4962 /* Update the global beacon filter */
4963 lim_update_bcn_probe_filter(mac_ctx, session_entry);
4964
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004965 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08004966 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004967 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004968 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004969 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004970 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004971 }
4972
4973 session_entry->lim11hEnable = val;
4974 session_entry->dot11mode = ch_change_req->dot11mode;
Bala Venkateshb39ed152017-12-26 19:35:27 +05304975 session_entry->nwType = ch_change_req->nw_type;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304976 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004977 &ch_change_req->operational_rateset,
4978 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304979 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004980 &ch_change_req->extended_rateset,
4981 sizeof(session_entry->extRateSet));
4982 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
4983 session_entry->ch_center_freq_seg0,
4984 session_entry->ch_center_freq_seg1,
4985 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07004986 max_tx_pwr, session_entry->peSessionId,
4987 ch_change_req->cac_duration_ms,
4988 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004989}
4990
4991/******************************************************************************
4992* lim_start_bss_update_add_ie_buffer()
4993*
4994***FUNCTION:
4995* This function checks the src buffer and its length and then malloc for
4996* dst buffer update the same
4997*
4998***LOGIC:
4999*
5000***ASSUMPTIONS:
5001*
5002***NOTE:
5003*
5004* @param pMac Pointer to Global MAC structure
5005* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5006* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5007* @param *pSrcData_buff A pointer of uint8_t src buffer
5008* @param srcDataLen src buffer length
5009******************************************************************************/
5010
5011static void
5012lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5013 uint8_t **pDstData_buff,
5014 uint16_t *pDstDataLen,
5015 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5016{
5017
5018 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5019 *pDstDataLen = srcDataLen;
5020
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305021 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005022
5023 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005024 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005025 return;
5026 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305027 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005028 } else {
5029 *pDstData_buff = NULL;
5030 *pDstDataLen = 0;
5031 }
5032}
5033
5034/******************************************************************************
5035* lim_update_add_ie_buffer()
5036*
5037***FUNCTION:
5038* This function checks the src buffer and length if src buffer length more
5039* than dst buffer length then free the dst buffer and malloc for the new src
5040* length, and update the dst buffer and length. But if dst buffer is bigger
5041* than src buffer length then it just update the dst buffer and length
5042*
5043***LOGIC:
5044*
5045***ASSUMPTIONS:
5046*
5047***NOTE:
5048*
5049* @param pMac Pointer to Global MAC structure
5050* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5051* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5052* @param *pSrcData_buff A pointer of uint8_t src buffer
5053* @param srcDataLen src buffer length
5054******************************************************************************/
5055
5056static void
5057lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5058 uint8_t **pDstData_buff,
5059 uint16_t *pDstDataLen,
5060 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5061{
5062
5063 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005064 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005065 return;
5066 }
5067
5068 if (srcDataLen > *pDstDataLen) {
5069 *pDstDataLen = srcDataLen;
5070 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305071 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005072 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305073 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005074
5075 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005076 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005077 *pDstDataLen = 0;
5078 return;
5079 }
5080 }
5081
5082 /* copy the content of buffer into dst buffer
5083 */
5084 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305085 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005086
5087}
5088
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005089/**
5090 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5091 * @pMac : Pointer to Global MAC structure
5092 * @pDstData_buff : A pointer to pointer of dst buffer
5093 * @pDstDataLen : A pointer to pointer of dst buffer length
5094 * @pModifyIE : A pointer to tSirModifyIE
5095 *
5096 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5097 *
5098 * Return:
5099 * True or false depending upon whether IE is updated or not
5100 */
5101static bool
5102lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5103 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5104{
Hong Shi1553d692016-09-28 12:16:19 +08005105 int32_t oui_length;
5106 uint8_t *ibss_ie = NULL;
5107 uint8_t *vendor_ie;
5108#define MAC_VENDOR_OUI "\x00\x16\x32"
5109#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005110
5111 ibss_ie = pModifyIE->pIEBuffer;
5112 oui_length = pModifyIE->oui_length;
5113
5114 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005115 pe_err("Invalid set IBSS vendor IE command length %d",
5116 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005117 return false;
5118 }
5119
Hong Shi1553d692016-09-28 12:16:19 +08005120 /*
5121 * Why replace only beacon OUI data here:
5122 * 1. other ie (such as wpa) shall not be overwritten here.
5123 * 2. per spec, beacon oui ie might be set twice and original one
5124 * shall be updated.
5125 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005126 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005127 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5128 if (vendor_ie) {
5129 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5130 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5131 pModifyIE->ieBufferlength);
5132 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005133 uint16_t new_length;
5134 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005135
Naveen Rawat668dee32017-09-29 14:39:40 -07005136 /*
5137 * check for uint16 overflow before using sum of two numbers as
5138 * length of size to malloc
5139 */
5140 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5141 pe_err("U16 overflow due to %d + %d",
5142 pModifyIE->ieBufferlength, *pDstDataLen);
5143 return false;
5144 }
5145
5146 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5147 new_ptr = qdf_mem_malloc(new_length);
Hong Shi1553d692016-09-28 12:16:19 +08005148 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005149 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005150 return false;
5151 }
5152 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5153 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5154 pModifyIE->ieBufferlength);
5155 qdf_mem_free(*pDstData_buff);
5156 *pDstDataLen = new_length;
5157 *pDstData_buff = new_ptr;
5158 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005159 return true;
5160}
5161
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005162/*
5163* lim_process_modify_add_ies() - process modify additional IE req.
5164*
5165* @mac_ctx: Pointer to Global MAC structure
5166* @msg_buf: pointer to the SME message buffer
5167*
5168* This function update the PE buffers for additional IEs.
5169*
5170* Return: None
5171*/
5172static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5173 uint32_t *msg_buf)
5174{
5175 tpSirModifyIEsInd modify_add_ies;
5176 tpPESession session_entry;
5177 uint8_t session_id;
5178 bool ret = false;
5179 tSirAddIeParams *add_ie_params;
5180
5181 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005182 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005183 return;
5184 }
5185
5186 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5187 /* Incoming message has smeSession, use BSSID to find PE session */
5188 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005189 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005190
5191 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005192 pe_err("Session not found for given bssid"
5193 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005194 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005195 goto end;
5196 }
5197 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5198 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5199 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005200 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005201 modify_add_ies->modifyIE.pIEBuffer,
5202 modify_add_ies->modifyIE.ieBufferlength,
5203 modify_add_ies->modifyIE.ieID,
5204 modify_add_ies->modifyIE.ieIDLen,
5205 modify_add_ies->updateType);
5206 goto end;
5207 }
5208 add_ie_params = &session_entry->addIeParams;
5209 switch (modify_add_ies->updateType) {
5210 case eUPDATE_IE_PROBE_RESP:
5211 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005212 if (LIM_IS_IBSS_ROLE(session_entry)) {
5213 lim_update_ibss_prop_add_ies(mac_ctx,
5214 &add_ie_params->probeRespData_buff,
5215 &add_ie_params->probeRespDataLen,
5216 &modify_add_ies->modifyIE);
5217 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005218 break;
5219 case eUPDATE_IE_ASSOC_RESP:
5220 /* assoc resp IE */
5221 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305222 QDF_TRACE(QDF_MODULE_ID_PE,
5223 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005224 "assoc resp add ie not present %d"),
5225 add_ie_params->assocRespDataLen);
5226 }
5227 /* search through the buffer and modify the IE */
5228 break;
5229 case eUPDATE_IE_PROBE_BCN:
5230 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005231 if (LIM_IS_IBSS_ROLE(session_entry)) {
5232 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5233 &add_ie_params->probeRespBCNData_buff,
5234 &add_ie_params->probeRespBCNDataLen,
5235 &modify_add_ies->modifyIE);
5236 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005237 if (ret == true && modify_add_ies->modifyIE.notify) {
5238 lim_handle_param_update(mac_ctx,
5239 modify_add_ies->updateType);
5240 }
5241 break;
5242 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005243 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005244 modify_add_ies->updateType);
5245 break;
5246 }
5247end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305248 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005249 modify_add_ies->modifyIE.pIEBuffer = NULL;
5250}
5251
5252/*
5253* lim_process_update_add_ies() - process additional IE update req
5254*
5255* @mac_ctx: Pointer to Global MAC structure
5256* @msg_buf: pointer to the SME message buffer
5257*
5258* This function update the PE buffers for additional IEs.
5259*
5260* Return: None
5261*/
5262static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5263 uint32_t *msg_buf)
5264{
5265 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5266 uint8_t session_id;
5267 tpPESession session_entry;
5268 tSirAddIeParams *addn_ie;
5269 uint16_t new_length = 0;
5270 uint8_t *new_ptr = NULL;
5271 tSirUpdateIE *update_ie;
5272
5273 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005274 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005275 return;
5276 }
5277 update_ie = &update_add_ies->updateIE;
5278 /* incoming message has smeSession, use BSSID to find PE session */
5279 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005280 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005281
5282 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005283 pe_err("Session not found for given bssid"
5284 MAC_ADDRESS_STR,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005285 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005286 goto end;
5287 }
5288 addn_ie = &session_entry->addIeParams;
5289 /* if len is 0, upper layer requested freeing of buffer */
5290 if (0 == update_ie->ieBufferlength) {
5291 switch (update_add_ies->updateType) {
5292 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305293 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005294 addn_ie->probeRespData_buff = NULL;
5295 addn_ie->probeRespDataLen = 0;
5296 break;
5297 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305298 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005299 addn_ie->assocRespData_buff = NULL;
5300 addn_ie->assocRespDataLen = 0;
5301 break;
5302 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305303 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005304 addn_ie->probeRespBCNData_buff = NULL;
5305 addn_ie->probeRespBCNDataLen = 0;
5306
5307 if (update_ie->notify)
5308 lim_handle_param_update(mac_ctx,
5309 update_add_ies->updateType);
5310 break;
5311 default:
5312 break;
5313 }
5314 return;
5315 }
5316 switch (update_add_ies->updateType) {
5317 case eUPDATE_IE_PROBE_RESP:
5318 if (update_ie->append) {
5319 /*
5320 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005321 * with combined length.
5322 * Multiple back to back append commands
5323 * can lead to a huge length.So, check
5324 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005325 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005326 if (addn_ie->probeRespDataLen >
5327 (USHRT_MAX - update_ie->ieBufferlength)) {
5328 pe_err("IE Length overflow, curr:%d, new:%d",
5329 addn_ie->probeRespDataLen,
5330 update_ie->ieBufferlength);
5331 goto end;
5332 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005333 new_length = update_ie->ieBufferlength +
5334 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305335 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005336 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005337 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005338 goto end;
5339 }
5340 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305341 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005342 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305343 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005344 update_ie->pAdditionIEBuffer,
5345 update_ie->ieBufferlength);
5346 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305347 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005348 /* adjust length accordingly */
5349 addn_ie->probeRespDataLen = new_length;
5350 /* save refernece of local buffer in PE session */
5351 addn_ie->probeRespData_buff = new_ptr;
5352 goto end;
5353 }
5354 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5355 &addn_ie->probeRespDataLen,
5356 update_ie->pAdditionIEBuffer,
5357 update_ie->ieBufferlength);
5358 break;
5359 case eUPDATE_IE_ASSOC_RESP:
5360 /* assoc resp IE */
5361 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5362 &addn_ie->assocRespDataLen,
5363 update_ie->pAdditionIEBuffer,
5364 update_ie->ieBufferlength);
5365 break;
5366 case eUPDATE_IE_PROBE_BCN:
5367 /* probe resp Bcn IE */
5368 lim_update_add_ie_buffer(mac_ctx,
5369 &addn_ie->probeRespBCNData_buff,
5370 &addn_ie->probeRespBCNDataLen,
5371 update_ie->pAdditionIEBuffer,
5372 update_ie->ieBufferlength);
5373 if (update_ie->notify)
5374 lim_handle_param_update(mac_ctx,
5375 update_add_ies->updateType);
5376 break;
5377 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005378 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005379 break;
5380 }
5381end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305382 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005383 update_ie->pAdditionIEBuffer = NULL;
5384}
5385
5386/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305387 * send_extended_chan_switch_action_frame()- function to send ECSA
5388 * action frame for each sta connected to SAP/GO and AP in case of
5389 * STA .
5390 * @mac_ctx: pointer to global mac structure
5391 * @new_channel: new channel to switch to.
5392 * @ch_bandwidth: BW of channel to calculate op_class
5393 * @session_entry: pe session
5394 *
5395 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5396 *
5397 * Return: void
5398 */
5399
5400static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5401 uint16_t new_channel, uint8_t ch_bandwidth,
5402 tpPESession session_entry)
5403{
5404 uint16_t op_class;
5405 uint8_t switch_mode = 0, i;
5406 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005407 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305408
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005409 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305410 mac_ctx->scan.countryCodeCurrent,
5411 new_channel,
5412 ch_bandwidth);
5413
5414 if (LIM_IS_AP_ROLE(session_entry) &&
5415 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005416 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305417
gaoleze2920bd2017-03-21 17:38:42 +08005418 switch_count = session_entry->gLimChannelSwitch.switchCount;
5419
Abhishek Singh518323d2015-10-19 17:42:01 +05305420 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005421 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305422 psta =
5423 session_entry->dph.dphHashTable.pDphNodeArray + i;
5424 if (psta && psta->added)
5425 lim_send_extended_chan_switch_action_frame(
5426 mac_ctx,
5427 psta->staAddr,
5428 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005429 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305430 }
5431 } else if (LIM_IS_STA_ROLE(session_entry)) {
5432 lim_send_extended_chan_switch_action_frame(mac_ctx,
5433 session_entry->bssId,
5434 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005435 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305436 }
5437
5438}
5439
gaolez76d2a162017-03-21 19:23:58 +08005440void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5441 uint16_t new_channel,
5442 uint8_t ch_bandwidth,
5443 tpPESession session_entry)
5444{
5445 uint16_t op_class;
5446 uint8_t switch_mode = 0, i;
5447 uint8_t switch_count;
5448 tpDphHashNode psta;
5449 tpDphHashNode dph_node_array_ptr;
5450
5451 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5452
5453 op_class = wlan_reg_dmn_get_opclass_from_channel(
5454 mac_ctx->scan.countryCodeCurrent,
5455 new_channel, ch_bandwidth);
5456
5457 if (LIM_IS_AP_ROLE(session_entry) &&
5458 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5459 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5460
5461 switch_count = session_entry->gLimChannelSwitch.switchCount;
5462
5463 if (LIM_IS_AP_ROLE(session_entry)) {
5464 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5465 psta = dph_node_array_ptr + i;
5466 if (!(psta && psta->added))
5467 continue;
5468 if (session_entry->lim_non_ecsa_cap_num == 0)
5469 lim_send_extended_chan_switch_action_frame
5470 (mac_ctx, psta->staAddr, switch_mode,
5471 op_class, new_channel, switch_count,
5472 session_entry);
5473 else
5474 lim_send_channel_switch_mgmt_frame
5475 (mac_ctx, psta->staAddr, switch_mode,
5476 new_channel, switch_count,
5477 session_entry);
5478 }
5479 } else if (LIM_IS_STA_ROLE(session_entry)) {
5480 lim_send_extended_chan_switch_action_frame
5481 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5482 new_channel, switch_count, session_entry);
5483 }
5484}
5485
5486/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005487 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5488 *
5489 * @mac_ctx: Pointer to Global MAC structure
5490 * @msg_buf: pointer to the SME message buffer
5491 *
5492 * This function processes SME request messages from HDD or upper layer
5493 * application.
5494 *
5495 * Return: None
5496 */
5497static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5498 uint32_t *msg_buf)
5499{
5500 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5501 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005502 uint8_t session_id;
5503 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005504 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005505
5506 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005507 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005508 return;
5509 }
5510
5511 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5512 session_entry = pe_find_session_by_bssid(mac_ctx,
5513 dfs_csa_ie_req->bssid, &session_id);
5514 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005515 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005516 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5517 return;
5518 }
5519
5520 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005521 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005522 GET_LIM_SYSTEM_ROLE(session_entry));
5523 return;
5524 }
5525
5526 /* target channel */
5527 session_entry->gLimChannelSwitch.primaryChannel =
5528 dfs_csa_ie_req->targetChannel;
5529
5530 /* Channel switch announcement needs to be included in beacon */
5531 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005532 session_entry->gLimChannelSwitch.switchCount =
5533 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005534 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005535 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305536 session_entry->gLimChannelSwitch.sec_ch_offset =
5537 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005538 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005539 session_entry->gLimChannelSwitch.switchMode =
5540 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005541
5542 /*
5543 * Validate if SAP is operating HT or VHT mode and set the Channel
5544 * Switch Wrapper element with the Wide Band Switch subelement.
5545 */
5546 if (true != session_entry->vhtCapability)
5547 goto skip_vht;
5548
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005549 /* Now encode the Wider Ch BW element depending on the ch width */
5550 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005551 switch (dfs_csa_ie_req->ch_params.ch_width) {
5552 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005553 /*
5554 * Wide channel BW sublement in channel wrapper element is not
5555 * required in case of 20 Mhz operation. Currently It is set
5556 * only set in case of 40/80 Mhz Operation.
5557 */
5558 session_entry->dfsIncludeChanWrapperIe = false;
5559 wider_bw_ch_switch->newChanWidth =
5560 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5561 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005562 case CH_WIDTH_40MHZ:
5563 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005564 wider_bw_ch_switch->newChanWidth =
5565 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5566 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005567 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005568 session_entry->dfsIncludeChanWrapperIe = true;
5569 wider_bw_ch_switch->newChanWidth =
5570 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5571 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005572 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005573 session_entry->dfsIncludeChanWrapperIe = true;
5574 wider_bw_ch_switch->newChanWidth =
5575 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5576 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005577 case CH_WIDTH_80P80MHZ:
5578 session_entry->dfsIncludeChanWrapperIe = true;
5579 wider_bw_ch_switch->newChanWidth =
5580 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005581 /*
5582 * This is not applicable for 20/40/80 Mhz.
5583 * Only used when we support 80+80 Mhz operation.
5584 * In case of 80+80 Mhz, this parameter indicates
5585 * center channel frequency index of 80 Mhz channel of
5586 * frequency segment 1.
5587 */
5588 wider_bw_ch_switch->newCenterChanFreq1 =
5589 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005590 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005591 default:
5592 session_entry->dfsIncludeChanWrapperIe = false;
5593 /*
5594 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5595 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5596 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005597 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005598 break;
5599 }
5600 /* Fetch the center channel based on the channel width */
5601 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005602 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005603skip_vht:
5604 /* Send CSA IE request from here */
5605 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005606 QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005607 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005608 return;
5609 }
5610
5611 /*
5612 * First beacon update request is sent here, the remaining updates are
5613 * done when the FW responds back after sending the first beacon after
5614 * the template update
5615 */
5616 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305617
5618 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5619 ch_offset = BW80;
5620 else
5621 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5622
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005623 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305624 session_entry->gLimChannelSwitch.switchCount,
5625 session_entry->gLimChannelSwitch.primaryChannel,
5626 session_entry->gLimChannelSwitch.ch_width,
5627 session_entry->dfsIncludeChanWrapperIe,
5628 ch_offset);
5629
gaolez76d2a162017-03-21 19:23:58 +08005630 /* Send ECSA/CSA Action frame after updating the beacon */
5631 if (CHAN_HOP_ALL_BANDS_ENABLE)
5632 lim_send_chan_switch_action_frame(mac_ctx,
5633 session_entry->gLimChannelSwitch.primaryChannel,
5634 ch_offset, session_entry);
5635 else
5636 send_extended_chan_switch_action_frame(mac_ctx,
5637 session_entry->gLimChannelSwitch.primaryChannel,
5638 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005639}
5640
5641/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305642 * lim_process_ext_change_channel()- function to send ECSA
5643 * action frame for STA/CLI .
5644 * @mac_ctx: pointer to global mac structure
5645 * @msg: params from sme for new channel.
5646 *
5647 * This function is called to send ECSA frame for STA/CLI.
5648 *
5649 * Return: void
5650 */
5651
5652static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5653 uint32_t *msg)
5654{
5655 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5656 (struct sir_sme_ext_cng_chan_req *) msg;
5657 tpPESession session_entry = NULL;
5658
5659 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005660 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305661 return;
5662 }
5663 session_entry =
5664 pe_find_session_by_sme_session_id(mac_ctx,
5665 ext_chng_channel->session_id);
5666 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005667 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305668 ext_chng_channel->session_id);
5669 return;
5670 }
5671 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005672 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305673 return;
5674 }
5675 send_extended_chan_switch_action_frame(mac_ctx,
5676 ext_chng_channel->new_channel,
5677 0, session_entry);
5678}
5679
5680/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005681 * lim_process_nss_update_request() - process sme nss update req
5682 *
5683 * @mac_ctx: Pointer to Global MAC structure
5684 * @msg_buf: pointer to the SME message buffer
5685 *
5686 * This function processes SME request messages from HDD or upper layer
5687 * application.
5688 *
5689 * Return: None
5690 */
5691static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5692 uint32_t *msg_buf)
5693{
5694 struct sir_nss_update_request *nss_update_req_ptr;
5695 tpPESession session_entry = NULL;
5696
5697 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005698 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005699 return;
5700 }
5701
5702 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305703 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005704 nss_update_req_ptr->vdev_id);
5705 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005706 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005707 nss_update_req_ptr->vdev_id);
5708 return;
5709 }
5710
5711 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005712 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005713 GET_LIM_SYSTEM_ROLE(session_entry));
5714 return;
5715 }
5716
5717 /* populate nss field in the beacon */
5718 session_entry->gLimOperatingMode.present = 1;
5719 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05305720 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
5721
5722 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
5723 (session_entry->ch_width > CH_WIDTH_80MHZ))
5724 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
5725
5726 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
5727
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005728 /* Send nss update request from here */
5729 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005730 QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005731 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005732 return;
5733 }
5734
5735 lim_send_beacon_ind(mac_ctx, session_entry);
5736}
5737
5738/**
5739 * lim_process_set_ie_req() - process sme set IE request
5740 *
5741 * @mac_ctx: Pointer to Global MAC structure
5742 * @msg_buf: pointer to the SME message buffer
5743 *
5744 * This function processes SME request messages from HDD or upper layer
5745 * application.
5746 *
5747 * Return: None
5748 */
5749static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5750{
5751 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305752 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005753
5754 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005755 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005756 return;
5757 }
5758
5759 msg = (struct send_extcap_ie *)msg_buf;
5760 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305761 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005762 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005763
5764}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005765
5766#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Arif Hussain05fb4872018-01-03 16:02:55 -08005767
5768/**
5769 * obss_color_collision_process_color_disable() - Disable bss color
5770 * @mac_ctx: Pointer to Global MAC structure
5771 * @session: pointer to session
5772 *
5773 * This function will disbale bss color.
5774 *
5775 * Return: None
5776 */
5777static void obss_color_collision_process_color_disable(tpAniSirGlobal mac_ctx,
5778 tpPESession session)
5779{
5780 tUpdateBeaconParams beacon_params;
5781
5782 if (!session) {
5783 pe_err("Invalid session");
5784 return;
5785 }
5786
5787 if (session->valid && !LIM_IS_AP_ROLE(session)) {
5788 pe_err("Invalid SystemRole %d",
5789 GET_LIM_SYSTEM_ROLE(session));
5790 return;
5791 }
5792
5793 if (session->bss_color_changing == 1) {
5794 pe_warn("%d: color change in progress", session->smeSessionId);
5795 /* Continue color collision detection */
5796 lim_send_obss_color_collision_cfg(mac_ctx, session,
5797 OBSS_COLOR_COLLISION_DETECTION);
5798 return;
5799 }
5800
5801 if (session->he_op.bss_col_disabled == 1) {
5802 pe_warn("%d: bss color already disabled",
5803 session->smeSessionId);
5804 /* Continue free color detection */
5805 lim_send_obss_color_collision_cfg(mac_ctx, session,
5806 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5807 return;
5808 }
5809
5810 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5811 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5812 session->he_op.bss_col_disabled = 1;
Arif Hussain05fb4872018-01-03 16:02:55 -08005813 beacon_params.bss_color_disabled = 1;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005814 beacon_params.bss_color = session->he_op.bss_color;
Arif Hussain05fb4872018-01-03 16:02:55 -08005815
5816 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005817 QDF_STATUS_SUCCESS) {
Arif Hussain05fb4872018-01-03 16:02:55 -08005818 pe_err("Unable to set op mode IE in beacon");
5819 return;
5820 }
5821
5822 lim_send_beacon_params(mac_ctx, &beacon_params, session);
5823 lim_send_obss_color_collision_cfg(mac_ctx, session,
5824 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5825}
5826
5827/**
5828 * obss_color_collision_process_color_change() - Process bss color change
5829 * @mac_ctx: Pointer to Global MAC structure
5830 * @session: pointer to session
5831 * @obss_color_info: obss color collision/free slot indication info
5832 *
5833 * This function selects new color ib case of bss color collision.
5834 *
5835 * Return: None
5836 */
5837static void obss_color_collision_process_color_change(tpAniSirGlobal mac_ctx,
5838 tpPESession session,
5839 struct wmi_obss_color_collision_info *obss_color_info)
5840{
5841 int i, num_bss_color = 0;
5842 uint32_t bss_color_bitmap;
5843 uint8_t bss_color_index_array[MAX_BSS_COLOR_VALUE];
5844 uint32_t rand_byte = 0;
5845 struct sir_set_he_bss_color he_bss_color;
5846 bool is_color_collision = false;
5847
5848
5849 if (session->bss_color_changing == 1) {
5850 pe_err("%d: color change in progress", session->smeSessionId);
5851 return;
5852 }
5853
5854 if (!session->he_op.bss_col_disabled) {
5855 if (session->he_op.bss_color < 32)
5856 is_color_collision = (obss_color_info->
5857 obss_color_bitmap_bit0to31 >>
5858 session->he_op.bss_color) & 0x01;
5859 else
5860 is_color_collision = (obss_color_info->
5861 obss_color_bitmap_bit32to63 >>
5862 (session->he_op.bss_color -
Arif Hussain9e8c5612018-04-12 16:35:48 -07005863 32)) & 0x01;
Arif Hussain05fb4872018-01-03 16:02:55 -08005864 if (!is_color_collision) {
5865 pe_err("%d: color collision not found, curr_color: %d",
5866 session->smeSessionId,
5867 session->he_op.bss_color);
5868 return;
5869 }
5870 }
5871
5872 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit0to31;
5873
5874 /* Skip color zero */
5875 bss_color_bitmap = bss_color_bitmap >> 1;
5876 for (i = 0; (i < 31) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5877 if (!(bss_color_bitmap & 0x01)) {
5878 bss_color_index_array[num_bss_color] = i + 1;
5879 num_bss_color++;
5880 }
5881 bss_color_bitmap = bss_color_bitmap >> 1;
5882 }
5883
5884 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit32to63;
5885 for (i = 0; (i < 32) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5886 if (!(bss_color_bitmap & 0x01)) {
5887 bss_color_index_array[num_bss_color] = i + 32;
5888 num_bss_color++;
5889 }
5890 bss_color_bitmap = bss_color_bitmap >> 1;
5891 }
5892
5893 if (num_bss_color) {
5894 qdf_get_random_bytes((void *) &rand_byte, 1);
5895 i = (rand_byte + qdf_mc_timer_get_system_ticks()) %
5896 num_bss_color;
5897 pe_debug("New bss color = %d", bss_color_index_array[i]);
5898 he_bss_color.session_id = obss_color_info->vdev_id;
5899 he_bss_color.bss_color = bss_color_index_array[i];
5900 lim_process_set_he_bss_color(mac_ctx,
5901 (uint32_t *)&he_bss_color);
5902 } else {
5903 pe_err("Unable to find bss color from bitmasp");
5904 if (obss_color_info->evt_type ==
5905 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY &&
5906 session->obss_color_collision_dec_evt ==
5907 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
5908 /* In dot11BSSColorCollisionAPPeriod and
5909 * timer expired, time to disable bss color.
5910 */
5911 obss_color_collision_process_color_disable(mac_ctx,
5912 session);
5913 else
5914 /*
5915 * Enter dot11BSSColorCollisionAPPeriod period.
5916 */
5917 lim_send_obss_color_collision_cfg(mac_ctx, session,
5918 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY);
5919 }
5920}
5921
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005922void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5923{
5924 struct sir_set_he_bss_color *bss_color;
5925 tpPESession session_entry = NULL;
5926 tUpdateBeaconParams beacon_params;
5927
5928 if (!msg_buf) {
5929 pe_err("Buffer is Pointing to NULL");
5930 return;
5931 }
5932
5933 bss_color = (struct sir_set_he_bss_color *)msg_buf;
5934 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5935 bss_color->session_id);
5936 if (!session_entry) {
5937 pe_err("Session not found for given session_id %d",
5938 bss_color->session_id);
5939 return;
5940 }
5941
5942 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5943 pe_err("Invalid SystemRole %d",
5944 GET_LIM_SYSTEM_ROLE(session_entry));
5945 return;
5946 }
5947
5948 if (bss_color->bss_color == session_entry->he_op.bss_color) {
5949 pe_err("No change in BSS color, current BSS color %d",
5950 bss_color->bss_color);
5951 return;
5952 }
5953 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5954 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5955 session_entry->he_op.bss_col_disabled = 1;
5956 session_entry->he_bss_color_change.countdown =
5957 BSS_COLOR_SWITCH_COUNTDOWN;
5958 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005959 beacon_params.bss_color_disabled = 1;
5960 beacon_params.bss_color = session_entry->he_op.bss_color;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005961 session_entry->bss_color_changing = 1;
5962
5963 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005964 QDF_STATUS_SUCCESS) {
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005965 pe_err("Unable to set op mode IE in beacon");
5966 return;
5967 }
5968
5969 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
Arif Hussain05fb4872018-01-03 16:02:55 -08005970 lim_send_obss_color_collision_cfg(mac_ctx, session_entry,
5971 OBSS_COLOR_COLLISION_DETECTION_DISABLE);
5972}
5973
5974void lim_send_obss_color_collision_cfg(tpAniSirGlobal mac_ctx,
5975 tpPESession session,
5976 enum wmi_obss_color_collision_evt_type
5977 event_type)
5978{
5979 struct wmi_obss_color_collision_cfg_param *cfg_param;
5980 struct scheduler_msg msg = {0};
5981
5982 if (!session) {
5983 pe_err("Invalid session");
5984 return;
5985 }
5986
5987 if (!session->he_capable ||
5988 !session->is_session_obss_color_collision_det_enabled) {
5989 pe_debug("%d: obss color det not enabled, he_cap:%d, sup:%d:%d",
5990 session->smeSessionId, session->he_capable,
5991 session->is_session_obss_color_collision_det_enabled,
5992 mac_ctx->lim.global_obss_color_collision_det_offload);
5993 return;
5994 }
5995
5996 cfg_param = qdf_mem_malloc(sizeof(*cfg_param));
5997 if (!cfg_param) {
5998 pe_err("Failed to allocate memory");
5999 return;
6000 }
6001
6002 pe_debug("%d: sending event:%d", session->smeSessionId, event_type);
6003 qdf_mem_zero(cfg_param, sizeof(*cfg_param));
6004 cfg_param->vdev_id = session->smeSessionId;
6005 cfg_param->evt_type = event_type;
6006 if (LIM_IS_AP_ROLE(session))
6007 cfg_param->detection_period_ms =
6008 OBSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS;
6009 else
6010 cfg_param->detection_period_ms =
6011 OBSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS;
6012
6013 cfg_param->scan_period_ms = OBSS_COLOR_COLLISION_SCAN_PERIOD_MS;
6014 if (event_type == OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6015 cfg_param->free_slot_expiry_time_ms =
6016 OBSS_COLOR_COLLISION_FREE_SLOT_EXPIRY_MS;
6017
6018 msg.type = WMA_OBSS_COLOR_COLLISION_REQ;
6019 msg.bodyptr = cfg_param;
6020 msg.reserved = 0;
6021
6022 if (QDF_IS_STATUS_ERROR(scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
6023 pe_err("Failed to post WMA_OBSS_COLOR_COLLISION_REQ to WMA");
6024 qdf_mem_free(cfg_param);
6025 } else {
6026 session->obss_color_collision_dec_evt = event_type;
6027 }
6028}
6029
6030void lim_process_obss_color_collision_info(tpAniSirGlobal mac_ctx,
6031 uint32_t *msg_buf)
6032{
6033 struct wmi_obss_color_collision_info *obss_color_info;
6034 tpPESession session;
6035
6036 if (!msg_buf) {
6037 pe_err("Buffer is Pointing to NULL");
6038 return;
6039 }
6040
6041 obss_color_info = (struct wmi_obss_color_collision_info *)msg_buf;
6042 session = pe_find_session_by_sme_session_id(mac_ctx,
6043 obss_color_info->vdev_id);
6044 if (!session) {
6045 pe_err("Session not found for given session_id %d",
6046 obss_color_info->vdev_id);
6047 return;
6048 }
6049
6050 pe_debug("vdev_id:%d, evt:%d:%d, 0to31:0x%x, 32to63:0x%x, cap:%d:%d:%d",
6051 obss_color_info->vdev_id,
6052 obss_color_info->evt_type,
6053 session->obss_color_collision_dec_evt,
6054 obss_color_info->obss_color_bitmap_bit0to31,
6055 obss_color_info->obss_color_bitmap_bit32to63,
6056 session->he_capable,
6057 session->is_session_obss_color_collision_det_enabled,
6058 mac_ctx->lim.global_obss_color_collision_det_offload);
6059
6060 if (!session->he_capable ||
6061 !session->is_session_obss_color_collision_det_enabled) {
6062 return;
6063 }
6064
6065 switch (obss_color_info->evt_type) {
6066 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
6067 pe_err("%d: FW disabled obss color det. he_cap:%d, sup:%d:%d",
6068 session->smeSessionId, session->he_capable,
6069 session->is_session_obss_color_collision_det_enabled,
6070 mac_ctx->lim.global_obss_color_collision_det_offload);
6071 session->is_session_obss_color_collision_det_enabled = false;
6072 return;
6073 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
6074 case OBSS_COLOR_COLLISION_DETECTION:
6075 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
6076 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6077 pe_debug("Invalid System Role %d",
6078 GET_LIM_SYSTEM_ROLE(session));
6079 return;
6080 }
6081
6082 if (session->obss_color_collision_dec_evt !=
6083 obss_color_info->evt_type) {
6084 pe_debug("%d: Wrong event: %d, skiping",
6085 obss_color_info->vdev_id,
6086 obss_color_info->evt_type);
6087 return;
6088 }
6089 obss_color_collision_process_color_change(mac_ctx, session,
6090 obss_color_info);
6091 break;
6092 default:
6093 pe_err("%d: Invalid event type %d",
6094 obss_color_info->vdev_id, obss_color_info->evt_type);
6095 return;
6096 }
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006097}
6098#endif