blob: 8e106b552ce67606ddaa00337e308acda75a43d6 [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;
Vignesh Viswanathan3d478032018-08-02 20:18:53 +0530472 pMac->lim.stop_roaming_callback = ready_req->stop_roaming_cb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800473 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700474
475 pe_debug("sending WMA_SYS_READY_IND msg to HAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800476 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
477
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700478 if (QDF_STATUS_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700479 pe_err("wma_post_ctrl_msg failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800480 return true;
481 }
482 return false;
483}
484
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800485/**
486 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
487 *@mac_ctx: Pointer to Global MAC structure
488 *@session: A pointer to session entry
489 *@sme_start_bss_req: Start BSS Request from upper layers.
490 *
491 * This function is used to configure the start bss parameters
492 * in to the session.
493 *
494 * Return: None.
495 */
496static void
497lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
498 tpSirSmeStartBssReq sme_start_bss_req)
499{
500 session->limSystemRole = eLIM_AP_ROLE;
501 session->privacy = sme_start_bss_req->privacy;
502 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
503 session->authType = sme_start_bss_req->authType;
504 /* Store the DTIM period */
505 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
506 /* Enable/disable UAPSD */
507 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530508 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800509 session->proxyProbeRspEn = 0;
510 } else {
511 /*
512 * To detect PBC overlap in SAP WPS mode,
513 * Host handles Probe Requests.
514 */
515 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
516 session->proxyProbeRspEn = 1;
517 else
518 session->proxyProbeRspEn = 0;
519 }
520 session->ssidHidden = sme_start_bss_req->ssidHidden;
521 session->wps_state = sme_start_bss_req->wps_state;
522 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530523 session->vendor_vht_sap =
524 sme_start_bss_req->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800525 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
526 &session->shortSlotTimeSupported);
527 session->isCoalesingInIBSSAllowed =
528 sme_start_bss_req->isCoalesingInIBSSAllowed;
529
Jiachao Wu712d4fd2017-08-23 16:52:34 +0800530 session->beacon_tx_rate = sme_start_bss_req->beacon_tx_rate;
531
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800532}
533
534/**
Arif Hussain53cf5692018-04-05 16:35:54 -0700535 * lim_clear_he_tx_stbc() - Clear tx stbc for a given session
536 * @session: Session
537 *
538 * Clear tx stbc for a given session
539 *
540 * Return: None
541 */
542#ifdef WLAN_FEATURE_11AX
543static void lim_clear_he_tx_stbc(tpPESession session)
544{
545 if (session) {
546 session->he_config.tx_stbc_lt_80mhz = 0;
547 session->he_config.tx_stbc_gt_80mhz = 0;
548 }
549}
550#else
551static void lim_clear_he_tx_stbc(tpPESession session)
552{}
553#endif
554
555/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800556 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
557 *@mac_ctx: Pointer to Global MAC structure
558 *@msg_buf: A pointer to the SME message buffer
559 *
560 * This function is called to process SME_START_BSS_REQ message
561 * from HDD or upper layer application.
562 *
563 * Return: None
564 */
565static void
566__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
567{
568 uint16_t size;
569 uint32_t val = 0;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700570 QDF_STATUS ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800571 tSirMacChanNum channel_number;
572 tLimMlmStartReq *mlm_start_req = NULL;
573 tpSirSmeStartBssReq sme_start_bss_req = NULL;
574 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
575 /* Flag Used in case of IBSS to Auto generate BSSID. */
576 uint32_t auto_gen_bssid = false;
577 uint8_t session_id;
578 tpPESession session = NULL;
Krunal Sonib37bb352016-12-20 14:12:21 -0800579 uint8_t sme_session_id = 0xFF;
580 uint16_t sme_transaction_id = 0xFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800581 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700582 struct vdev_type_nss *vdev_type_nss;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700583 QDF_STATUS cfg_get_wmi_dfs_master_param = QDF_STATUS_SUCCESS;
gaurank kathpaliad88ef882018-08-14 15:20:11 +0530584 struct policy_mgr_hw_mode_params hw_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800585
586/* FEATURE_WLAN_DIAG_SUPPORT */
587#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
588 /*
589 * Since the session is not created yet, sending NULL.
590 * The response should have the correct state.
591 */
592 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
593 NULL, 0, 0);
594#endif /* FEATURE_WLAN_DIAG_SUPPORT */
595
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700596 pe_debug("Received START_BSS_REQ");
Krunal Sonib37bb352016-12-20 14:12:21 -0800597 size = sizeof(tSirSmeStartBssReq);
598 sme_start_bss_req = qdf_mem_malloc(size);
599 if (NULL == sme_start_bss_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700600 pe_err("Allocate Memory fail for LimStartBssReq");
Krunal Sonib37bb352016-12-20 14:12:21 -0800601 /* Send failure response to host */
602 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
603 goto free;
604 }
605 qdf_mem_copy(sme_start_bss_req, msg_buf, sizeof(tSirSmeStartBssReq));
606 sme_session_id = sme_start_bss_req->sessionId;
607 sme_transaction_id = sme_start_bss_req->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800608
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800609 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
610 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800611 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
612 sme_start_bss_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700613 pe_warn("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800614 ret_code = eSIR_SME_INVALID_PARAMETERS;
615 goto free;
616 }
617
618 /*
619 * This is the place where PE is going to create a session.
620 * If session is not existed, then create a new session
621 */
622 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800623 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800624 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700625 pe_warn("Session Already exists for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800626 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
627 session = NULL;
628 goto free;
629 } else {
630 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800631 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800632 &session_id, mac_ctx->lim.maxStation,
633 sme_start_bss_req->bssType);
634 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700635 pe_warn("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800636 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
637 goto free;
638 }
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +0530639
640 /* Update the beacon/probe filter in mac_ctx */
641 lim_set_bcn_probe_filter(mac_ctx, session,
642 &sme_start_bss_req->ssId,
643 sme_start_bss_req->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800644 }
645
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700646 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
647 /* Probe resp add ie */
648 lim_start_bss_update_add_ie_buffer(mac_ctx,
649 &session->addIeParams.probeRespData_buff,
650 &session->addIeParams.probeRespDataLen,
651 sme_start_bss_req->addIeParams.
652 probeRespData_buff,
653 sme_start_bss_req->addIeParams.
654 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800655
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700656 /* Probe Beacon add ie */
657 lim_start_bss_update_add_ie_buffer(mac_ctx,
658 &session->addIeParams.probeRespBCNData_buff,
659 &session->addIeParams.probeRespBCNDataLen,
660 sme_start_bss_req->addIeParams.
661 probeRespBCNData_buff,
662 sme_start_bss_req->addIeParams.
663 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800664
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700665 /* Assoc resp IE */
666 lim_start_bss_update_add_ie_buffer(mac_ctx,
667 &session->addIeParams.assocRespData_buff,
668 &session->addIeParams.assocRespDataLen,
669 sme_start_bss_req->addIeParams.
670 assocRespData_buff,
671 sme_start_bss_req->addIeParams.
672 assocRespDataLen);
673 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800674 /* Store the session related params in newly created session */
675 session->pLimStartBssReq = sme_start_bss_req;
676
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800677 /* Store SME session Id in sessionTable */
678 session->smeSessionId = sme_start_bss_req->sessionId;
679
680 session->transactionId = sme_start_bss_req->transactionId;
681
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530682 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800683 &(sme_start_bss_req->htConfig),
684 sizeof(session->htConfig));
685
Sandeep Puligilla98917432016-06-10 13:50:28 -0700686 qdf_mem_copy(&(session->vht_config),
687 &(sme_start_bss_req->vht_config),
688 sizeof(session->vht_config));
689
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800690 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800691 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800692
693 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530694 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800695 (uint8_t *) &sme_start_bss_req->ssId,
696 (sme_start_bss_req->ssId.length + 1));
697
698 session->bssType = sme_start_bss_req->bssType;
699
700 session->nwType = sme_start_bss_req->nwType;
701
702 session->beaconParams.beaconInterval =
703 sme_start_bss_req->beaconInterval;
704
705 /* Store the channel number in session Table */
706 session->currentOperChannel =
707 sme_start_bss_req->channelId;
708
709 /* Store Persona */
710 session->pePersona = sme_start_bss_req->bssPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +0530711 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800712 FL("PE PERSONA=%d"), session->pePersona);
713
714 /* Update the phymode */
715 session->gLimPhyMode = sme_start_bss_req->nwType;
716
717 session->maxTxPower =
718 cfg_get_regulatory_max_transmit_power(mac_ctx,
719 session->currentOperChannel);
720 /* Store the dot 11 mode in to the session Table */
721 session->dot11mode = sme_start_bss_req->dot11mode;
722#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
723 session->cc_switch_mode =
724 sme_start_bss_req->cc_switch_mode;
725#endif
726 session->htCapability =
727 IS_DOT11_MODE_HT(session->dot11mode);
728 session->vhtCapability =
729 IS_DOT11_MODE_VHT(session->dot11mode);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800730
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700731 pe_debug("HT[%d], VHT[%d]",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800732 session->htCapability, session->vhtCapability);
733
734 if (IS_DOT11_MODE_HE(session->dot11mode)) {
735 lim_update_session_he_capable(mac_ctx, session);
736 lim_copy_bss_he_cap(session, sme_start_bss_req);
737 }
738
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739 session->txLdpcIniFeatureEnabled =
740 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800741#ifdef WLAN_FEATURE_11W
742 session->limRmfEnabled =
743 sme_start_bss_req->pmfCapable ? 1 : 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700744 pe_debug("Session RMF enabled: %d", session->limRmfEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800745#endif
746
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530747 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800748 (void *)&sme_start_bss_req->operationalRateSet,
749 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530750 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800751 (void *)&sme_start_bss_req->extendedRateSet,
752 sizeof(tSirMacRateSet));
753
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700754 if (IS_5G_CH(session->currentOperChannel))
755 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
756 else
757 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
758
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800759 switch (sme_start_bss_req->bssType) {
760 case eSIR_INFRA_AP_MODE:
761 lim_configure_ap_start_bss_session(mac_ctx, session,
762 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700763 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700764 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700765 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700766 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800767 break;
768 case eSIR_IBSS_MODE:
769 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
770 lim_get_short_slot_from_phy_mode(mac_ctx, session,
771 session->gLimPhyMode,
772 &session->shortSlotTimeSupported);
773
774 /*
775 * initialize to "OPEN".
776 * will be updated upon key installation
777 */
778 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700779 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800780
781 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700782 case eSIR_NDI_MODE:
783 session->limSystemRole = eLIM_NDI_ROLE;
784 break;
785
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800786
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800787 /*
788 * There is one more mode called auto mode.
789 * which is used no where
790 */
791
792 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
793
794 default:
795 /* not used anywhere...used in scan function */
796 break;
797 }
798
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700799 pe_debug("persona - %d, nss - %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700800 session->pePersona, session->vdev_nss);
801 session->nss = session->vdev_nss;
Kiran Kumar Lokerebc6fb2f2018-05-09 19:04:11 -0700802 if (!mac_ctx->roam.configParam.enable2x2)
803 session->nss = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800804 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700805 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800806 * parsed (Re)Assoc request structure
807 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700808 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800809 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530810 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700811 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800812 if (NULL == session->parsedAssocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700813 pe_warn("AllocateMemory() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800814 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
815 goto free;
816 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800817 }
818
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700819 if (!sme_start_bss_req->channelId &&
820 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700821 pe_err("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800822 ret_code = eSIR_SME_INVALID_PARAMETERS;
823 goto free;
824 }
825 channel_number = sme_start_bss_req->channelId;
826#ifdef QCA_HT_2040_COEX
827 if (sme_start_bss_req->obssEnabled)
828 session->htSupportedChannelWidthSet =
829 session->htCapability;
830 else
831#endif
832 session->htSupportedChannelWidthSet =
833 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
834 session->htSecondaryChannelOffset =
835 sme_start_bss_req->sec_ch_offset;
836 session->htRecommendedTxWidthSet =
837 (session->htSecondaryChannelOffset) ? 1 : 0;
Abhishek Singh4294f802017-08-10 16:37:07 +0530838 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800839 FL("cbMode %u"), sme_start_bss_req->cbMode);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800840 if (lim_is_session_he_capable(session) ||
841 session->vhtCapability || session->htCapability) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800842 chanwidth = sme_start_bss_req->vht_channel_width;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700843 pe_debug("vht_channel_width %u htSupportedChannelWidthSet %d",
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800844 sme_start_bss_req->vht_channel_width,
845 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800846 session->ch_width = chanwidth;
847 if (session->htSupportedChannelWidthSet) {
848 session->ch_center_freq_seg0 =
849 sme_start_bss_req->center_freq_seg0;
850 session->ch_center_freq_seg1 =
851 sme_start_bss_req->center_freq_seg1;
852 } else {
853 session->ch_center_freq_seg0 = 0;
854 session->ch_center_freq_seg1 = 0;
855 }
856 }
gaurank kathpaliad88ef882018-08-14 15:20:11 +0530857 if (policy_mgr_is_hw_dbs_capable(mac_ctx->psoc) &&
858 (policy_mgr_get_current_hw_mode(mac_ctx->psoc, &hw_mode) ==
859 QDF_STATUS_SUCCESS) &&
860 hw_mode.dbs_cap) {
861 session->nss = 1;
862 pe_debug("HW is in DBS mode. Nss set to [%d]",
863 session->nss);
864 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800865 if (session->vhtCapability &&
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800866 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800867 session->nss = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700868 pe_debug("nss set to [%d]", session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800869 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700870 pe_debug("vht su tx bformer %d",
Krunal Soni53993f72016-07-08 18:20:03 -0700871 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800872
873 /* Delete pre-auth list if any */
874 lim_delete_pre_auth_list(mac_ctx);
875
Krunal Soni53993f72016-07-08 18:20:03 -0700876 if (session->nss == 1) {
877 session->vht_config.su_beam_former = 0;
878 session->vht_config.tx_stbc = 0;
879 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530880 session->htConfig.ht_tx_stbc = 0;
Arif Hussain53cf5692018-04-05 16:35:54 -0700881 lim_clear_he_tx_stbc(session);
Krunal Soni53993f72016-07-08 18:20:03 -0700882 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800883 /*
884 * keep the RSN/WPA IE information in PE Session Entry
885 * later will be using this to check when received (Re)Assoc req
886 */
887 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
888 &sme_start_bss_req->rsnIE, session);
889
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700890 if (LIM_IS_AP_ROLE(session) ||
891 LIM_IS_IBSS_ROLE(session) ||
892 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800893 session->gLimProtectionControl =
894 sme_start_bss_req->protEnabled;
895 /*
896 * each byte will have the following info
897 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
898 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
899 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530900 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800901 (void *)&sme_start_bss_req->ht_capab,
902 sizeof(uint16_t));
903 /* Initialize WPS PBC session link list */
904 session->pAPWPSPBCSession = NULL;
905 }
906 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530907 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800908 if (NULL == mlm_start_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700909 pe_err("Allocate Memory failed for mlmStartReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800910 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
911 goto free;
912 }
913
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800914 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530915 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800916 (uint8_t *) &sme_start_bss_req->ssId,
917 sme_start_bss_req->ssId.length + 1);
918 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
919 mlm_start_req->obssProtEnabled =
920 sme_start_bss_req->obssProtEnabled;
921
922 mlm_start_req->bssType = session->bssType;
923
924 /* Fill PE session Id from the session Table */
925 mlm_start_req->sessionId = session->peSessionId;
926
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700927 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
928 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800929 /*
930 * Copy the BSSId from sessionTable to
931 * mlmStartReq struct
932 */
933 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
934 } else {
935 /* ibss mode */
936 mac_ctx->lim.gLimIbssCoalescingHappened = false;
937
938 ret_status = wlan_cfg_get_int(mac_ctx,
939 WNI_CFG_IBSS_AUTO_BSSID,
940 &auto_gen_bssid);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700941 if (ret_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700942 pe_err("Get Auto Gen BSSID fail,Status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800943 ret_status);
Abhishek Singh4294f802017-08-10 16:37:07 +0530944 ret_code = eSIR_LOGE_EXCEPTION;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800945 goto free;
946 }
947
948 if (!auto_gen_bssid) {
949 /*
950 * We're not auto generating BSSID.
951 * Instead, get it from session entry
952 */
953 sir_copy_mac_addr(mlm_start_req->bssId,
954 session->bssId);
955 /*
956 * Start IBSS group BSSID
957 * Auto Generating BSSID.
958 */
959 auto_gen_bssid = ((mlm_start_req->bssId[0] &
960 0x01) ? true : false);
961 }
962
963 if (auto_gen_bssid) {
964 /*
965 * if BSSID is not any uc id.
966 * then use locally generated BSSID.
967 * Autogenerate the BSSID
968 */
969 lim_get_random_bssid(mac_ctx,
970 mlm_start_req->bssId);
971 mlm_start_req->bssId[0] = 0x02;
972
973 /*
974 * Copy randomly generated BSSID
975 * to the session Table
976 */
977 sir_copy_mac_addr(session->bssId,
978 mlm_start_req->bssId);
979 }
980 }
981 /* store the channel num in mlmstart req structure */
982 mlm_start_req->channelNumber = session->currentOperChannel;
983 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
984 mlm_start_req->beaconPeriod =
985 session->beaconParams.beaconInterval;
Arif Hussain671a1902017-03-17 09:08:32 -0700986 mlm_start_req->cac_duration_ms =
987 sme_start_bss_req->cac_duration_ms;
988 mlm_start_req->dfs_regdomain =
989 sme_start_bss_req->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800990 if (LIM_IS_AP_ROLE(session)) {
991 mlm_start_req->dtimPeriod = session->dtimPeriod;
992 mlm_start_req->wps_state = session->wps_state;
993
994 } else {
995 if (wlan_cfg_get_int(mac_ctx,
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700996 WNI_CFG_DTIM_PERIOD, &val) != QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700997 pe_err("could not retrieve DTIM Period");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800998 mlm_start_req->dtimPeriod = (uint8_t) val;
999 }
1000
Karthik Kantamneni22dd0f62018-08-07 14:53:50 +05301001 mlm_start_req->cfParamSet.cfpPeriod =
1002 mac_ctx->mlme_cfg->rates.cfp_period;
1003 mlm_start_req->cfParamSet.cfpMaxDuration =
1004 mac_ctx->mlme_cfg->rates.cfp_max_duration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001005
1006 /*
1007 * this may not be needed anymore now,
1008 * as rateSet is now included in the
1009 * session entry and MLM has session context.
1010 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301011 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012 (void *)&session->rateSet,
1013 sizeof(tSirMacRateSet));
1014
1015 /* Now populate the 11n related parameters */
1016 mlm_start_req->nwType = session->nwType;
1017 mlm_start_req->htCapable = session->htCapability;
1018
1019 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1020 /* Unused */
1021 mlm_start_req->dualCTSProtection =
1022 mac_ctx->lim.gHTDualCTSProtection;
1023 mlm_start_req->txChannelWidthSet =
1024 session->htRecommendedTxWidthSet;
1025
1026 session->limRFBand = lim_get_rf_band(channel_number);
1027
1028 /* Initialize 11h Enable Flag */
1029 session->lim11hEnable = 0;
gaolez76d2a162017-03-21 19:23:58 +08001030 if (mlm_start_req->bssType != eSIR_IBSS_MODE &&
1031 (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001032 BAND_5G == session->limRFBand)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001033 if (wlan_cfg_get_int(mac_ctx,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001034 WNI_CFG_11H_ENABLED, &val) != QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001035 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001036 else
1037 session->lim11hEnable = val;
1038
1039 if (session->lim11hEnable &&
1040 (eSIR_INFRA_AP_MODE ==
1041 mlm_start_req->bssType)) {
1042 cfg_get_wmi_dfs_master_param =
1043 wlan_cfg_get_int(mac_ctx,
1044 WNI_CFG_DFS_MASTER_ENABLED,
1045 &val);
1046 session->lim11hEnable = val;
1047 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001048 if (cfg_get_wmi_dfs_master_param != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001050 pe_err("Get Fail, CFG DFS ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051 }
1052
1053 if (!session->lim11hEnable) {
1054 if (cfg_set_int(mac_ctx,
1055 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001056 QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001057 /*
1058 * Failed to set the CFG param
1059 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1060 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001061 pe_err("Set LOCAL_POWER_CONSTRAINT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001062 }
1063
Jiachao Wu712d4fd2017-08-23 16:52:34 +08001064 mlm_start_req->beacon_tx_rate = session->beacon_tx_rate;
1065
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001066 session->limPrevSmeState = session->limSmeState;
1067 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1068 MTRACE(mac_trace
1069 (mac_ctx, TRACE_CODE_SME_STATE,
1070 session->peSessionId,
1071 session->limSmeState));
1072
1073 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1074 (uint32_t *) mlm_start_req);
1075 return;
1076 } else {
1077
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001078 pe_err("Received unexpected START_BSS_REQ, in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001079 mac_ctx->lim.gLimSmeState);
1080 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001081 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001082 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1083
1084free:
1085 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001086 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001087 session->pLimStartBssReq = NULL;
1088 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001089 if (NULL != sme_start_bss_req)
1090 qdf_mem_free(sme_start_bss_req);
1091 if (NULL != mlm_start_req)
1092 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001093 if (NULL != session) {
1094 pe_delete_session(mac_ctx, session);
1095 session = NULL;
1096 }
1097 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1098 session, sme_session_id, sme_transaction_id);
1099}
1100
1101/**
1102 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1103 *
1104 * @pMac: Global MAC context
1105 * @pMsg: Message pointer
1106 *
1107 * Wrapper for the function __lim_handle_sme_start_bss_request
1108 * This message will be defered until softmac come out of
1109 * scan mode or if we have detected radar on the current
1110 * operating channel.
1111 *
1112 * return true - If we consumed the buffer
1113 * false - If have defered the message.
1114 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001115static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1116 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001117{
1118 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1119 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1120 /**
1121 * If message defered, buffer is not consumed yet.
1122 * So return false
1123 */
1124 return false;
1125 }
1126
1127 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1128 return true;
1129}
1130
1131/**
1132 * lim_get_random_bssid()
1133 *
1134 * FUNCTION:This function is called to process generate the random number for bssid
1135 * This function is called to process SME_SCAN_REQ message
1136 * from HDD or upper layer application.
1137 *
1138 * LOGIC:
1139 *
1140 * ASSUMPTIONS:
1141 *
1142 * NOTE:
1143 * 1. geneartes the unique random number for bssid in ibss
1144 *
1145 * @param pMac Pointer to Global MAC structure
1146 * @param *data Pointer to bssid buffer
1147 * @return None
1148 */
1149void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1150{
1151 uint32_t random[2];
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001152
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001153 random[0] = tx_time_get();
1154 random[0] |= (random[0] << 15);
1155 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301156 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001157}
1158
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001159/**
1160 * __lim_process_clear_dfs_channel_list()
1161 *
1162 ***FUNCTION:
Jeff Johnsonc00ae5b2018-05-06 16:06:35 -07001163 ***Clear DFS channel list when country is changed/acquired.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001164 .*This message is sent from SME.
1165 *
1166 ***LOGIC:
1167 *
1168 ***ASSUMPTIONS:
1169 *
1170 ***NOTE:
1171 *
1172 * @param pMac Pointer to Global MAC structure
1173 * @param *pMsgBuf A pointer to the SME message buffer
1174 * @return None
1175 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001176static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1177 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001178{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301179 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001180}
1181
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301182#ifdef WLAN_FEATURE_SAE
1183
1184/**
1185 * lim_update_sae_config()- This API update SAE session info to csr config
1186 * from join request.
1187 * @session: PE session
1188 * @sme_join_req: pointer to join request
1189 *
1190 * Return: None
1191 */
1192static void lim_update_sae_config(tpPESession session,
1193 tpSirSmeJoinReq sme_join_req)
1194{
1195 session->sae_pmk_cached = sme_join_req->sae_pmk_cached;
1196
1197 pe_debug("pmk_cached %d for BSSID=" MAC_ADDRESS_STR,
1198 session->sae_pmk_cached,
1199 MAC_ADDR_ARRAY(sme_join_req->bssDescription.bssId));
1200}
1201#else
1202static inline void lim_update_sae_config(tpPESession session,
1203 tpSirSmeJoinReq sme_join_req)
1204{}
1205#endif
1206
1207
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001208/**
1209 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1210 * @mac_ctx: Pointer to Global MAC structure
1211 * @msg_buf: A pointer to the SME message buffer
1212 *
1213 * This function is called to process SME_JOIN_REQ message
1214 * from HDD or upper layer application.
1215 *
1216 * Return: None
1217 */
1218static void
1219__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1220{
1221 tpSirSmeJoinReq sme_join_req = NULL;
1222 tLimMlmJoinReq *mlm_join_req;
1223 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1224 uint32_t val = 0;
1225 uint16_t n_size;
1226 uint8_t session_id;
1227 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301228 uint8_t sme_session_id = 0;
1229 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001230 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001231 uint16_t ie_len;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001232 const uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001233 tSirBssDescription *bss_desc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234
Arif Hussain995fcaf2016-07-18 11:28:22 -07001235 if (!mac_ctx || !msg_buf) {
1236 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1237 FL("JOIN REQ with invalid data"));
1238 return;
1239 }
1240
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241/* FEATURE_WLAN_DIAG_SUPPORT */
1242#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1243 /*
1244 * Not sending any session, since it is not created yet.
1245 * The response whould have correct state.
1246 */
1247 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1248#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1249
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001250 /*
1251 * Expect Join request in idle state.
1252 * Reassociate request is expected in link established state.
1253 */
1254
1255 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1256 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1257 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1258 msg_buf);
1259
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301260 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001261 if (NULL == sme_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001262 pe_err("AllocateMemory failed for sme_join_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001263 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301264 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001265 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301266 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001267 n_size);
1268
1269 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1270 /* Received invalid eWNI_SME_JOIN_REQ */
1271 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001272 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001273 sme_join_req->sessionId);
1274 ret_code = eSIR_SME_INVALID_PARAMETERS;
1275 goto end;
1276 }
1277
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001278 /*
1279 * Update the capability here itself as this is used in
1280 * lim_extract_ap_capability() below. If not updated issues
1281 * like not honoring power constraint on 1st association after
1282 * driver loading might occur.
1283 */
1284 lim_update_rrm_capability(mac_ctx, sme_join_req);
1285
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001286 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001287 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001288 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001289 &session_id);
1290
1291 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001292 pe_err("Session(%d) Already exists for BSSID: "
1293 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001294 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001295 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001296 session->limSmeState);
1297
1298 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1299 session->smeSessionId == sme_join_req->sessionId) {
1300 /*
1301 * Received eWNI_SME_JOIN_REQ for same
1302 * BSS as currently associated.
1303 * Log the event and send success
1304 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001305 pe_warn("SessionId: %d", session_id);
1306 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001307 /* Send Join success response to host */
1308 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1309 session = NULL;
1310 goto end;
1311 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001312 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001313 ret_code = eSIR_SME_REFUSED;
1314 session = NULL;
1315 goto end;
1316 }
1317 } else {
1318 /*
1319 * Session Entry does not exist for given BSSId
1320 * Try to Create a new session
1321 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001322 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001323 &session_id, mac_ctx->lim.maxStation,
1324 eSIR_INFRASTRUCTURE_MODE);
1325 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001326 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001327 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1328 goto end;
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301329 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001330 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001331 session_id);
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301332 }
1333
1334 /* Update the beacon/probe filter in mac_ctx */
1335 lim_set_bcn_probe_filter(mac_ctx, session,
1336 &sme_join_req->ssId,
1337 bss_desc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001338 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001339 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001340
1341 /*
1342 * Store Session related parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001343 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001344
1345 /* store the smejoin req handle in session table */
1346 session->pLimJoinReq = sme_join_req;
1347
1348 /* Store SME session Id in sessionTable */
1349 session->smeSessionId = sme_join_req->sessionId;
1350
1351 /* Store SME transaction Id in session Table */
1352 session->transactionId = sme_join_req->transactionId;
1353
1354 /* Store beaconInterval */
1355 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001356 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001357
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301358 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001359 sizeof(session->htConfig));
1360
Sandeep Puligilla98917432016-06-10 13:50:28 -07001361 qdf_mem_copy(&(session->vht_config),
1362 &(sme_join_req->vht_config),
1363 sizeof(session->vht_config));
1364
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001365 /* Copying of bssId is already done, while creating session */
1366 sir_copy_mac_addr(session->selfMacAddr,
1367 sme_join_req->selfMacAddr);
1368 session->bssType = sme_join_req->bsstype;
1369
1370 session->statypeForBss = STA_ENTRY_PEER;
1371 session->limWmeEnabled = sme_join_req->isWMEenabled;
1372 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301373 session->wps_registration = sme_join_req->wps_registration;
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001374 session->he_with_wep_tkip = sme_join_req->he_with_wep_tkip;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001375
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301376 session->enable_bcast_probe_rsp =
1377 sme_join_req->enable_bcast_probe_rsp;
1378
Jeff Johnson179fd8a2018-05-11 14:20:05 -07001379 /* Store vendor specific IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001380 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1382
Naveen Rawat08db88f2017-09-08 15:07:48 -07001383 vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001384 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001385 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001386
1387 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001388 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001389 session->isCiscoVendorAP = true;
1390 } else {
1391 session->isCiscoVendorAP = false;
1392 }
1393
1394 /* Copy the dot 11 mode in to the session table */
1395
1396 session->dot11mode = sme_join_req->dot11mode;
1397#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1398 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1399#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001400 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1402 session->enableHtSmps = sme_join_req->enableHtSmps;
1403 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001404 session->send_smps_action =
1405 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001406 /*
1407 * By default supported NSS 1x1 is set to true
1408 * and later on updated while determining session
1409 * supported rates which is the intersection of
1410 * self and peer rates
1411 */
1412 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301413 /*Store Persona */
1414 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001415 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 -08001416 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001417 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001418 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301419 session->supported_nss_1x1,
1420 session->pePersona,
1421 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001422
1423 /*Store Persona */
1424 session->pePersona = sme_join_req->staPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +05301425 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301426 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d force_24ghz_in_ht20 %d"),
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001427 session->pePersona, sme_join_req->cbMode,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301428 session->nwType, session->dot11mode,
1429 sme_join_req->force_24ghz_in_ht20);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001430
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001431 /* Copy The channel Id to the session Table */
1432 session->currentOperChannel = bss_desc->channelId;
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301433
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001434 session->vhtCapability =
1435 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001436 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301437 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001438 session->vht_config.su_beam_formee =
1439 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001441 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001442 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001443 session->enableVhtpAid =
1444 sme_join_req->enableVhtpAid;
1445 session->enableVhtGid =
1446 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001447 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001448 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001449 }
Krunal Soni53993f72016-07-08 18:20:03 -07001450
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001451 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301452 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001453 session->vht_config.su_beam_formee,
1454 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001455 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001456 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001457 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001458 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301459 session->force_24ghz_in_ht20 =
1460 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001461 /* cbMode is already merged value of peer and self -
1462 * done by csr in csr_get_cb_mode_from_ies */
1463 session->htSupportedChannelWidthSet =
1464 (sme_join_req->cbMode) ? 1 : 0;
1465 session->htRecommendedTxWidthSet =
1466 session->htSupportedChannelWidthSet;
1467 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1468
1469 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1470 session->ch_center_freq_seg0 =
1471 session->currentOperChannel - 2;
1472 session->ch_width = CH_WIDTH_40MHZ;
1473 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1474 sme_join_req->cbMode) {
1475 session->ch_center_freq_seg0 =
1476 session->currentOperChannel + 2;
1477 session->ch_width = CH_WIDTH_40MHZ;
1478 } else {
1479 session->ch_center_freq_seg0 = 0;
1480 session->ch_width = CH_WIDTH_20MHZ;
1481 }
1482
Naveen Rawataeca1b92017-10-16 16:55:31 -07001483 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1484 lim_update_session_he_capable(mac_ctx, session);
1485 lim_copy_join_req_he_cap(session, sme_join_req);
1486 }
1487
1488
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001489 /* Record if management frames need to be protected */
1490#ifdef WLAN_FEATURE_11W
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +05301491 if ((eSIR_ED_AES_128_CMAC ==
1492 sme_join_req->MgmtEncryptionType) ||
1493 (eSIR_ED_AES_GMAC_128 == sme_join_req->MgmtEncryptionType) ||
1494 (eSIR_ED_AES_GMAC_256 == sme_join_req->MgmtEncryptionType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001495 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001496 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001497 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001498#endif
1499
1500#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001501 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001502#endif
1503
1504 /* Copy the SSID from smejoinreq to session entry */
1505 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301506 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001507 session->ssId.length);
1508
1509 /*
1510 * Determin 11r or ESE connection based on input from SME
1511 * which inturn is dependent on the profile the user wants
1512 * to connect to, So input is coming from supplicant
1513 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001514 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001515#ifdef FEATURE_WLAN_ESE
1516 session->isESEconnection = sme_join_req->isESEconnection;
1517#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001518 session->isFastTransitionEnabled =
1519 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001520
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521 session->isFastRoamIniFeatureEnabled =
1522 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001523 session->txLdpcIniFeatureEnabled =
1524 sme_join_req->txLdpcIniFeatureEnabled;
1525
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301526 lim_update_fils_config(session, sme_join_req);
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301527 lim_update_sae_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001528 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1529 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001530 } else {
1531 /*
1532 * Throw an error and return and make
1533 * sure to delete the session.
1534 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001535 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001536 session->bssType);
1537 ret_code = eSIR_SME_INVALID_PARAMETERS;
1538 goto end;
1539 }
1540
1541 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301542 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001543 &sme_join_req->addIEScan, sizeof(tSirAddie));
1544
1545 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301546 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001547 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1548
1549 val = sizeof(tLimMlmJoinReq) +
1550 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301551 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001552 if (NULL == mlm_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001553 pe_err("AllocateMemory failed for mlmJoinReq");
Nitesh Shah0102cac2016-07-13 14:38:30 +05301554 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1555 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001556 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001557
1558 /* PE SessionId is stored as a part of JoinReq */
1559 mlm_join_req->sessionId = session->peSessionId;
1560
1561 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1562 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001563 QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001564 pe_err("couldn't retrieve JoinFailureTimer value"
1565 " setting to default value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001566 mlm_join_req->joinFailureTimeout =
1567 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1568 }
1569
1570 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301571 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001572 (void *)&sme_join_req->operationalRateSet,
1573 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301574 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001575 (void *)&sme_join_req->extendedRateSet,
1576 sizeof(tSirMacRateSet));
1577 /*
1578 * this may not be needed anymore now, as rateSet is now
1579 * included in the session entry and MLM has session context.
1580 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301581 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582 (void *)&session->rateSet,
1583 sizeof(tSirMacRateSet));
1584
1585 session->encryptType = sme_join_req->UCEncryptionType;
1586
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301587 session->supported_nss_1x1 = sme_join_req->supported_nss_1x1;
1588 session->vdev_nss = sme_join_req->vdev_nss;
1589 session->nss = sme_join_req->nss;
1590 session->nss_forced_1x1 = sme_join_req->nss_forced_1x1;
1591
1592 pe_debug("nss %d, vdev_nss %d, supported_nss_1x1 %d",
1593 session->nss,
1594 session->vdev_nss,
1595 session->supported_nss_1x1);
1596
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001597 mlm_join_req->bssDescription.length =
1598 session->pLimJoinReq->bssDescription.length;
1599
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301600 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001601 (uint8_t *)
1602 &session->pLimJoinReq->bssDescription.bssId,
1603 session->pLimJoinReq->bssDescription.length + 2);
1604
1605 session->limCurrentBssCaps =
1606 session->pLimJoinReq->bssDescription.capabilityInfo;
1607
1608 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1609 session->currentOperChannel);
1610 local_power_constraint = reg_max;
1611
1612 lim_extract_ap_capability(mac_ctx,
1613 (uint8_t *)
1614 session->pLimJoinReq->bssDescription.ieFields,
1615 lim_get_ielen_from_bss_description(
1616 &session->pLimJoinReq->bssDescription),
1617 &session->limCurrentBssQosCaps,
1618 &session->limCurrentBssPropCap,
1619 &session->gLimCurrentBssUapsd,
1620 &local_power_constraint, session);
1621
Krunal Soni53993f72016-07-08 18:20:03 -07001622 /*
1623 * Once the AP capabilities are available then set the
1624 * beam forming capabilities accordingly.
1625 */
1626 if (session->nss == 1) {
1627 session->vht_config.su_beam_former = 0;
1628 session->vht_config.tx_stbc = 0;
1629 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301630 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001631 }
1632
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001633 session->maxTxPower = lim_get_max_tx_power(reg_max,
1634 local_power_constraint,
1635 mac_ctx->roam.configParam.nTxPowerCap);
Abhinav Kumard528d192018-03-09 17:31:12 +05301636 session->def_max_tx_pwr = session->maxTxPower;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301637
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001638 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301639 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001640
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301641 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1642 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1643 pe_debug("Update MaxTxPower in join Req to %d",
1644 sme_join_req->powerCap.maxTxPower);
1645 }
1646
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001647 if (session->gLimCurrentBssUapsd) {
1648 session->gUapsdPerAcBitmask =
1649 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001650 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001651 session->gUapsdPerAcBitmask);
1652
1653 /* resetting the dynamic uapsd mask */
1654 session->gUapsdPerAcDeliveryEnableMask = 0;
1655 session->gUapsdPerAcTriggerEnableMask = 0;
1656 }
1657
1658 session->limRFBand =
1659 lim_get_rf_band(session->currentOperChannel);
1660
1661 /* Initialize 11h Enable Flag */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001662 if (BAND_5G == session->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001663 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001664 &val) != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001665 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001666 session->lim11hEnable =
1667 WNI_CFG_11H_ENABLED_STADEF;
1668 } else {
1669 session->lim11hEnable = val;
1670 }
1671 } else {
1672 session->lim11hEnable = 0;
1673 }
1674
1675 /*
1676 * To care of the scenario when STA transitions from
1677 * IBSS to Infrastructure mode.
1678 */
1679 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1680
1681 session->limPrevSmeState = session->limSmeState;
1682 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1683 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1684 session->peSessionId,
1685 session->limSmeState));
1686
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001687 /* Indicate whether spectrum management is enabled */
1688 session->spectrumMgtEnabled =
1689 sme_join_req->spectrumMgtIndicator;
1690
1691 /* Enable the spectrum management if this is a DFS channel */
1692 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001693 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001694 session->currentOperChannel))
1695 session->spectrumMgtEnabled = true;
1696
1697 session->isOSENConnection = sme_join_req->isOSENConnection;
1698
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001699 /* Issue LIM_MLM_JOIN_REQ to MLM */
1700 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1701 (uint32_t *) mlm_join_req);
1702 return;
1703
1704 } else {
1705 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001706 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001707 mac_ctx->lim.gLimSmeState);
1708 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1709 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1710 session = NULL;
1711 goto end;
1712 }
1713
1714end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301715 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1716 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717
1718 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301719 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001720 sme_join_req = NULL;
1721 if (NULL != session)
1722 session->pLimJoinReq = NULL;
1723 }
1724 if (ret_code != eSIR_SME_SUCCESS) {
1725 if (NULL != session) {
1726 pe_delete_session(mac_ctx, session);
1727 session = NULL;
1728 }
1729 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001730 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001731 sme_session_id, ret_code);
1732 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1733 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1734 sme_transaction_id);
1735}
1736
Amar Singhala297bfa2015-10-15 15:07:29 -07001737uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001738 uint8_t iniTxPower)
1739{
1740 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301741 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001742
Anurag Chouhan6d760662016-02-20 16:05:43 +05301743 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001744 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1745 maxTxPower = txPower;
1746 else if (txPower < MIN_TX_PWR_CAP)
1747 maxTxPower = MIN_TX_PWR_CAP;
1748 else
1749 maxTxPower = MAX_TX_PWR_CAP;
1750
1751 return maxTxPower;
1752}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001753
1754/**
1755 * __lim_process_sme_reassoc_req() - process reassoc req
1756 *
1757 * @mac_ctx: Pointer to Global MAC structure
1758 * @msg_buf: pointer to the SME message buffer
1759 *
1760 * This function is called to process SME_REASSOC_REQ message
1761 * from HDD or upper layer application.
1762 *
1763 * Return: None
1764 */
1765
1766static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
1767 uint32_t *msg_buf)
1768{
1769 uint16_t caps;
1770 uint32_t val;
1771 tpSirSmeJoinReq reassoc_req = NULL;
1772 tLimMlmReassocReq *mlm_reassoc_req;
1773 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1774 tpPESession session_entry = NULL;
1775 uint8_t session_id;
1776 uint8_t sme_session_id;
1777 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001778 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001779 uint32_t tele_bcn_en = 0;
1780 uint16_t size;
1781
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001782 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301783 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001785 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001786
1787 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1788 goto end;
1789 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301790 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001791
1792 if (!lim_is_sme_join_req_valid(mac_ctx,
1793 (tpSirSmeJoinReq)reassoc_req)) {
1794 /*
1795 * Received invalid eWNI_SME_REASSOC_REQ
1796 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001797 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001798
1799 ret_code = eSIR_SME_INVALID_PARAMETERS;
1800 goto end;
1801 }
1802
1803 session_entry = pe_find_session_by_bssid(mac_ctx,
1804 reassoc_req->bssDescription.bssId,
1805 &session_id);
1806 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001807 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001808 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
1809 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001810 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001811 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
1812 &sme_session_id, &transaction_id);
1813 session_entry =
1814 pe_find_session_by_sme_session_id(mac_ctx,
1815 sme_session_id);
1816 if (session_entry != NULL)
1817 lim_handle_sme_join_result(mac_ctx,
1818 eSIR_SME_INVALID_PARAMETERS,
1819 eSIR_MAC_UNSPEC_FAILURE_STATUS,
1820 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001821 goto end;
1822 }
1823#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
1824 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001825 session_entry, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1827 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
1828
1829 /* Store the reassoc handle in the session Table */
1830 session_entry->pLimReAssocReq = reassoc_req;
1831
1832 session_entry->dot11mode = reassoc_req->dot11mode;
1833 session_entry->vhtCapability =
1834 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001835
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301836 if (session_entry->vhtCapability) {
1837 if (session_entry->pePersona == QDF_STA_MODE) {
1838 session_entry->vht_config.su_beam_formee =
1839 reassoc_req->vht_config.su_beam_formee;
1840 } else {
1841 reassoc_req->vht_config.su_beam_formee = 0;
1842 }
1843 session_entry->enableVhtpAid =
1844 reassoc_req->enableVhtpAid;
1845 session_entry->enableVhtGid =
1846 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001847 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301848 }
1849
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301850 session_entry->supported_nss_1x1 = reassoc_req->supported_nss_1x1;
1851 session_entry->vdev_nss = reassoc_req->vdev_nss;
1852 session_entry->nss = reassoc_req->nss;
1853 session_entry->nss_forced_1x1 = reassoc_req->nss_forced_1x1;
1854
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001855 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301856 session_entry->vhtCapability,
1857 session_entry->vht_config.su_beam_formee,
1858 session_entry->vht_config.su_beam_former);
1859
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001860 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
1861 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001862 session_entry->send_smps_action =
1863 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001864 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001865 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001866 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001867 session_entry->send_smps_action,
1868 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001869 /*
1870 * Reassociate request is expected
1871 * in link established state only.
1872 */
1873
1874 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001875 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
1876 /*
1877 * May be from 11r FT pre-auth. So lets check it
1878 * before we bail out
1879 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001880 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001881 session_entry->peSessionId);
1882
1883 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301884 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001885 session_entry->limReAssocbssId,
1886 6)) {
1887 lim_print_mac_addr(mac_ctx,
1888 reassoc_req->bssDescription.
1889 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001890 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891 ret_code = eSIR_SME_INVALID_PARAMETERS;
1892 goto end;
1893 }
1894
1895 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
1896 session_entry);
1897 return;
1898 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001899 /*
1900 * Should not have received eWNI_SME_REASSOC_REQ
1901 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001902 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001903 session_entry->limSmeState);
1904 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
1905
1906 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1907 goto end;
1908 }
1909
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301910 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001911 session_entry->pLimReAssocReq->bssDescription.bssId,
1912 sizeof(tSirMacAddr));
1913
1914 session_entry->limReassocChannelId =
1915 session_entry->pLimReAssocReq->bssDescription.channelId;
1916
1917 session_entry->reAssocHtSupportedChannelWidthSet =
1918 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
1919 session_entry->reAssocHtRecommendedTxWidthSet =
1920 session_entry->reAssocHtSupportedChannelWidthSet;
1921 session_entry->reAssocHtSecondaryChannelOffset =
1922 session_entry->pLimReAssocReq->cbMode;
1923
1924 session_entry->limReassocBssCaps =
1925 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
1926 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1927 session_entry->currentOperChannel);
1928 local_pwr_constraint = reg_max;
1929
1930 lim_extract_ap_capability(mac_ctx,
1931 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
1932 lim_get_ielen_from_bss_description(
1933 &session_entry->pLimReAssocReq->bssDescription),
1934 &session_entry->limReassocBssQosCaps,
1935 &session_entry->limReassocBssPropCap,
1936 &session_entry->gLimCurrentBssUapsd,
1937 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05301938 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001939 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301940 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001941 /* Copy the SSID from session entry to local variable */
1942 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301943 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944 reassoc_req->ssId.ssId,
1945 session_entry->limReassocSSID.length);
1946 if (session_entry->gLimCurrentBssUapsd) {
1947 session_entry->gUapsdPerAcBitmask =
1948 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001949 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001950 session_entry->gUapsdPerAcBitmask);
1951 }
1952
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301953 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001954 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001955 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001956
1957 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1958 goto end;
1959 }
1960
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301961 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001962 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
1963
1964 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
1965 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001966 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001967 pe_err("could not retrieve ReassocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001968
1969 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001970 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001971 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301972
1973 lim_update_caps_info_for_bss(mac_ctx, &caps,
1974 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001975 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301976
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001977 mlm_reassoc_req->capabilityInfo = caps;
1978
1979 /* Update PE session_id */
1980 mlm_reassoc_req->sessionId = session_id;
1981
1982 /*
1983 * If telescopic beaconing is enabled, set listen interval to
1984 * WNI_CFG_TELE_BCN_MAX_LI
1985 */
1986 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001987 &tele_bcn_en) != QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001988 pe_err("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001989
1990 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
1991
1992 if (tele_bcn_en) {
1993 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001994 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001995 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001996 } else {
1997 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001998 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001999 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000 }
2001
2002 mlm_reassoc_req->listenInterval = (uint16_t) val;
2003
2004 /* Indicate whether spectrum management is enabled */
2005 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2006
2007 /* Enable the spectrum management if this is a DFS channel */
2008 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002009 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002010 session_entry->currentOperChannel))
2011 session_entry->spectrumMgtEnabled = true;
2012
2013 session_entry->limPrevSmeState = session_entry->limSmeState;
2014 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2015
2016 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2017 session_entry->peSessionId,
2018 session_entry->limSmeState));
2019
2020 lim_post_mlm_message(mac_ctx,
2021 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2022 return;
2023end:
2024 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302025 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002026 if (session_entry)
2027 session_entry->pLimReAssocReq = NULL;
2028 }
2029
2030 if (session_entry) {
2031 /*
2032 * error occurred after we determined the session so extract
2033 * session and transaction info from there
2034 */
2035 sme_session_id = session_entry->smeSessionId;
2036 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002037 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002038 /*
2039 * error occurred before or during the time we determined
2040 * the session so extract the session and transaction info
2041 * from the message
2042 */
2043 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2044 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002045 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002046 /*
2047 * Send Reassoc failure response to host
2048 * (note session_entry may be NULL, but that's OK)
2049 */
2050 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2051 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2052 session_entry, sme_session_id,
2053 transaction_id);
2054}
2055
2056bool send_disassoc_frame = 1;
2057/**
2058 * __lim_process_sme_disassoc_req()
2059 *
2060 ***FUNCTION:
2061 * This function is called to process SME_DISASSOC_REQ message
2062 * from HDD or upper layer application.
2063 *
2064 ***LOGIC:
2065 *
2066 ***ASSUMPTIONS:
2067 *
2068 ***NOTE:
2069 *
2070 * @param pMac Pointer to Global MAC structure
2071 * @param *pMsgBuf A pointer to the SME message buffer
2072 * @return None
2073 */
2074
2075static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2076{
2077 uint16_t disassocTrigger, reasonCode;
2078 tLimMlmDisassocReq *pMlmDisassocReq;
2079 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2080 tSirSmeDisassocReq smeDisassocReq;
2081 tpPESession psessionEntry = NULL;
2082 uint8_t sessionId;
2083 uint8_t smesessionId;
2084 uint16_t smetransactionId;
2085
2086 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002087 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002088 return;
2089 }
2090
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302091 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002092 smesessionId = smeDisassocReq.sessionId;
2093 smetransactionId = smeDisassocReq.transactionId;
2094 if (!lim_is_sme_disassoc_req_valid(pMac,
2095 &smeDisassocReq,
2096 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002097 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002098 if (pMac->lim.gLimRspReqd) {
2099 pMac->lim.gLimRspReqd = false;
2100
2101 retCode = eSIR_SME_INVALID_PARAMETERS;
2102 disassocTrigger = eLIM_HOST_DISASSOC;
2103 goto sendDisassoc;
2104 }
2105
2106 return;
2107 }
2108
2109 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002110 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002111 &sessionId);
2112 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002113 pe_err("session does not exist for given bssId "
2114 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002115 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002116 retCode = eSIR_SME_INVALID_PARAMETERS;
2117 disassocTrigger = eLIM_HOST_DISASSOC;
2118 goto sendDisassoc;
2119 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002120 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2121 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002122 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2123 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002124 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002125
2126#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2127 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2128 0, smeDisassocReq.reasonCode);
2129#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2130
2131 /* Update SME session Id and SME transaction ID */
2132
2133 psessionEntry->smeSessionId = smesessionId;
2134 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002135 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002136 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002137
2138 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2139 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002140 switch (psessionEntry->limSmeState) {
2141 case eLIM_SME_ASSOCIATED_STATE:
2142 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002143 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002144 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002145 psessionEntry->limPrevSmeState =
2146 psessionEntry->limSmeState;
2147 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002148 /* Delete all TDLS peers connected before leaving BSS */
2149 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002150 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2151 psessionEntry->peSessionId,
2152 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002153 break;
2154
2155 case eLIM_SME_WT_DEAUTH_STATE:
2156 /* PE shall still process the DISASSOC_REQ and proceed with
2157 * link tear down even if it had already sent a DEAUTH_IND to
2158 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2159 * its been set when PE entered WT_DEAUTH_STATE.
2160 */
2161 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2162 MTRACE(mac_trace
2163 (pMac, TRACE_CODE_SME_STATE,
2164 psessionEntry->peSessionId,
2165 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002166 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002167 break;
2168
2169 case eLIM_SME_WT_DISASSOC_STATE:
Jeff Johnson47d75242018-05-12 15:58:53 -07002170 /* PE Received a Disassoc frame. Normally it gets DISASSOC_CNF but it
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002171 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2172 * PE can continue processing DISASSOC_REQ and send the response instead
2173 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2174 * for disassoc frame.
2175 *
2176 * It will send a disassoc, which is ok. However, we can use the global flag
2177 * sendDisassoc to not send disassoc frame.
2178 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002179 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002180 break;
2181
2182 case eLIM_SME_JOIN_FAILURE_STATE: {
2183 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002184 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002185 if (pMac->lim.gLimRspReqd) {
2186 retCode = eSIR_SME_SUCCESS;
2187 disassocTrigger = eLIM_HOST_DISASSOC;
2188 goto sendDisassoc;
2189 }
2190 }
2191 break;
2192 default:
2193 /**
2194 * STA is not currently associated.
2195 * Log error and send response to host
2196 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002197 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002198 psessionEntry->limSmeState);
2199 lim_print_sme_state(pMac, LOGE,
2200 psessionEntry->limSmeState);
2201
2202 if (pMac->lim.gLimRspReqd) {
2203 if (psessionEntry->limSmeState !=
2204 eLIM_SME_WT_ASSOC_STATE)
2205 pMac->lim.gLimRspReqd = false;
2206
2207 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2208 disassocTrigger = eLIM_HOST_DISASSOC;
2209 goto sendDisassoc;
2210 }
2211
2212 return;
2213 }
2214
2215 break;
2216
2217 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002218 /* Fall through */
2219 break;
2220
2221 case eLIM_STA_IN_IBSS_ROLE:
2222 default:
2223 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002224 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002225 GET_LIM_SYSTEM_ROLE(psessionEntry));
2226
2227 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2228 disassocTrigger = eLIM_HOST_DISASSOC;
2229 goto sendDisassoc;
2230 } /* end switch (pMac->lim.gLimSystemRole) */
2231
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302232 disassocTrigger = eLIM_HOST_DISASSOC;
2233 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002234
2235 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002236 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002237 send_disassoc_frame = 0;
2238 }
2239 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002240 pe_debug("Sending Disasscoc with disassoc Trigger"
2241 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002242 disassocTrigger, reasonCode);
2243
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302244 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002245 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002246 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002247 return;
2248 }
2249
Anurag Chouhanc5548422016-02-24 18:33:27 +05302250 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002251 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002252
2253 pMlmDisassocReq->reasonCode = reasonCode;
2254 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2255
2256 /* Update PE session ID */
2257 pMlmDisassocReq->sessionId = sessionId;
2258
2259 lim_post_mlm_message(pMac,
2260 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2261 return;
2262
2263sendDisassoc:
2264 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002265 lim_send_sme_disassoc_ntf(pMac,
2266 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002267 retCode,
2268 disassocTrigger,
2269 1, smesessionId, smetransactionId,
2270 psessionEntry);
2271 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002272 lim_send_sme_disassoc_ntf(pMac,
2273 smeDisassocReq.peer_macaddr.bytes,
2274 retCode, disassocTrigger, 1,
2275 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002276
2277} /*** end __lim_process_sme_disassoc_req() ***/
2278
2279/** -----------------------------------------------------------------
2280 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2281
2282 This function is called to process SME_DISASSOC_CNF message
2283 from HDD or upper layer application.
2284
2285 \param pMac - global mac structure
2286 \param pStaDs - station dph hash node
2287 \return none
2288 \sa
2289 ----------------------------------------------------------------- */
2290static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2291{
2292 tSirSmeDisassocCnf smeDisassocCnf;
2293 uint16_t aid;
2294 tpDphHashNode pStaDs;
2295 tpPESession psessionEntry;
2296 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302297 uint32_t *msg = NULL;
2298 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002299
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302300 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002301 sizeof(struct sSirSmeDisassocCnf));
2302
2303 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002304 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002305 &sessionId);
2306 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002307 pe_err("session does not exist for given bssId");
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302308 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302309 smeDisassocCnf.sme_session_id,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302310 eSIR_SME_INVALID_SESSION,
2311 NULL);
2312 if (QDF_IS_STATUS_SUCCESS(status))
2313 lim_send_sme_disassoc_deauth_ntf(pMac,
2314 QDF_STATUS_SUCCESS,
2315 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002316 return;
2317 }
2318
2319 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002320 pe_err("received invalid SME_DISASSOC_CNF message");
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302321 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2322 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302323 eSIR_SME_INVALID_PARAMETERS,
2324 &smeDisassocCnf.bssid.bytes[0]);
2325 if (QDF_IS_STATUS_SUCCESS(status))
2326 lim_send_sme_disassoc_deauth_ntf(pMac,
2327 QDF_STATUS_SUCCESS,
2328 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002329 return;
2330 }
2331#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2332 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2333 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2334 psessionEntry,
2335 (uint16_t) smeDisassocCnf.statusCode, 0);
2336 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2337 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2338 psessionEntry,
2339 (uint16_t) smeDisassocCnf.statusCode, 0);
2340#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2341
2342 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2343 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002344 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2345 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2346 && (psessionEntry->limSmeState !=
2347 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002348 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002349 psessionEntry->limSmeState);
2350 lim_print_sme_state(pMac, LOGE,
2351 psessionEntry->limSmeState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302352 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302353 psessionEntry->smeSessionId,
2354 eSIR_SME_INVALID_STATE,
2355 &smeDisassocCnf.bssid.bytes[0]);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302356 if (QDF_IS_STATUS_SUCCESS(status))
2357 lim_send_sme_disassoc_deauth_ntf(pMac,
2358 QDF_STATUS_SUCCESS,
2359 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002360 return;
2361 }
2362 break;
2363
2364 case eLIM_AP_ROLE:
2365 /* Fall through */
2366 break;
2367
2368 case eLIM_STA_IN_IBSS_ROLE:
2369 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002370 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002371 GET_LIM_SYSTEM_ROLE(psessionEntry));
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302372 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2373 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302374 eSIR_SME_INVALID_STATE,
2375 &smeDisassocCnf.bssid.bytes[0]);
2376 if (QDF_IS_STATUS_SUCCESS(status))
2377 lim_send_sme_disassoc_deauth_ntf(pMac,
2378 QDF_STATUS_SUCCESS,
2379 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002380 return;
2381 }
2382
2383 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2384 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2385 LIM_IS_AP_ROLE(psessionEntry)) {
2386 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002387 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002388 &psessionEntry->dph.dphHashTable);
2389 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002390 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2391 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002392 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302393 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302394 psessionEntry->smeSessionId,
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05302395 eSIR_SME_INVALID_PARAMETERS,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302396 &smeDisassocCnf.bssid.bytes[0]);
2397 if (QDF_IS_STATUS_SUCCESS(status))
2398 lim_send_sme_disassoc_deauth_ntf(pMac,
2399 QDF_STATUS_SUCCESS,
2400 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002401 return;
2402 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302403
2404 if ((pStaDs->mlmStaContext.mlmState ==
2405 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2406 (pStaDs->mlmStaContext.mlmState ==
Arif Hussain5fa13782018-05-10 11:29:52 -07002407 eLIM_MLM_WT_DEL_BSS_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002408 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002409 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302410 pStaDs->mlmStaContext.mlmState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302411 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302412 psessionEntry->smeSessionId,
2413 eSIR_SME_SUCCESS,
2414 NULL);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302415 if (QDF_IS_STATUS_SUCCESS(status))
2416 lim_send_sme_disassoc_deauth_ntf(pMac,
2417 QDF_STATUS_SUCCESS,
2418 (uint32_t *)msg);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302419 return;
2420 }
2421
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002422 /* Delete FT session if there exists one */
2423 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002424 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2425
2426 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002427 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002428 }
2429
2430 return;
2431}
2432
2433/**
2434 * __lim_process_sme_deauth_req() - process sme deauth req
2435 * @mac_ctx: Pointer to Global MAC structure
2436 * @msg_buf: pointer to the SME message buffer
2437 *
2438 * This function is called to process SME_DEAUTH_REQ message
2439 * from HDD or upper layer application.
2440 *
2441 * Return: None
2442 */
2443
2444static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2445 uint32_t *msg_buf)
2446{
2447 uint16_t deauth_trigger, reason_code;
2448 tLimMlmDeauthReq *mlm_deauth_req;
2449 tSirSmeDeauthReq sme_deauth_req;
2450 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2451 tpPESession session_entry;
2452 uint8_t session_id; /* PE sessionId */
2453 uint8_t sme_session_id;
2454 uint16_t sme_transaction_id;
2455
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302456 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002457 sme_session_id = sme_deauth_req.sessionId;
2458 sme_transaction_id = sme_deauth_req.transactionId;
2459
2460 /*
2461 * We need to get a session first but we don't even know
2462 * if the message is correct.
2463 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002464 session_entry = pe_find_session_by_bssid(mac_ctx,
2465 sme_deauth_req.bssid.bytes,
2466 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002467 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002468 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002469 ret_code = eSIR_SME_INVALID_PARAMETERS;
2470 deauth_trigger = eLIM_HOST_DEAUTH;
2471 goto send_deauth;
2472 }
2473
2474 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2475 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002476 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002477 mac_ctx->lim.gLimRspReqd = false;
2478
2479 ret_code = eSIR_SME_INVALID_PARAMETERS;
2480 deauth_trigger = eLIM_HOST_DEAUTH;
2481 goto send_deauth;
2482 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002483 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2484 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002485 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2486 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002487 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002488#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2489 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2490 session_entry, 0, sme_deauth_req.reasonCode);
2491#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2492
2493 /* Update SME session ID and Transaction ID */
2494 session_entry->smeSessionId = sme_session_id;
2495 session_entry->transactionId = sme_transaction_id;
2496
2497 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2498 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002499 switch (session_entry->limSmeState) {
2500 case eLIM_SME_ASSOCIATED_STATE:
2501 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302502 /* Delete all TDLS peers connected before leaving BSS */
2503 lim_delete_tdls_peers(mac_ctx, session_entry);
Abhinav Kumarac12c762018-05-02 13:51:02 +05302504 /* fallthrough */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002505 case eLIM_SME_WT_ASSOC_STATE:
2506 case eLIM_SME_JOIN_FAILURE_STATE:
2507 case eLIM_SME_IDLE_STATE:
2508 session_entry->limPrevSmeState =
2509 session_entry->limSmeState;
2510 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2511 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2512 session_entry->peSessionId,
2513 session_entry->limSmeState));
2514 /* Send Deauthentication request to MLM below */
2515 break;
2516 case eLIM_SME_WT_DEAUTH_STATE:
2517 case eLIM_SME_WT_DISASSOC_STATE:
2518 /*
Jeff Johnson47d75242018-05-12 15:58:53 -07002519 * PE Received a Deauth/Disassoc frame. Normally it get
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002520 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2521 * Which means host is also trying to disconnect.
2522 * PE can continue processing DEAUTH_REQ and send
2523 * the response instead of failing the request.
2524 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2525 * was sent for deauth/disassoc frame.
2526 */
2527 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002528 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002529 break;
2530 default:
2531 /*
2532 * STA is not in a state to deauthenticate with
2533 * peer. Log error and send response to host.
2534 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002535 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002536 session_entry->limSmeState);
2537 lim_print_sme_state(mac_ctx, LOGE,
2538 session_entry->limSmeState);
2539
2540 if (mac_ctx->lim.gLimRspReqd) {
2541 mac_ctx->lim.gLimRspReqd = false;
2542
2543 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2544 deauth_trigger = eLIM_HOST_DEAUTH;
2545
wadesong42968e92017-06-08 14:11:21 +08002546 /*
2547 * here we received deauth request from AP so
2548 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2549 * have ISSUED delSta then mlm state should be
2550 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2551 * delBSS rsp then mlm state should be
2552 * eLIM_MLM_IDLE_STATE so the below condition
2553 * captures the state where delSta not done
2554 * and firmware still in connected state.
2555 */
2556 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002557 eLIM_SME_WT_DEAUTH_STATE &&
2558 session_entry->limMlmState !=
2559 eLIM_MLM_IDLE_STATE &&
2560 session_entry->limMlmState !=
2561 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002562 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002563 goto send_deauth;
2564 }
2565 return;
2566 }
2567 break;
2568
2569 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002570 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002571 if (mac_ctx->lim.gLimRspReqd) {
2572 mac_ctx->lim.gLimRspReqd = false;
2573 ret_code = eSIR_SME_INVALID_PARAMETERS;
2574 deauth_trigger = eLIM_HOST_DEAUTH;
2575 goto send_deauth;
2576 }
2577 return;
2578 case eLIM_AP_ROLE:
2579 break;
2580 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002581 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002582 GET_LIM_SYSTEM_ROLE(session_entry));
2583 if (mac_ctx->lim.gLimRspReqd) {
2584 mac_ctx->lim.gLimRspReqd = false;
2585 ret_code = eSIR_SME_INVALID_PARAMETERS;
2586 deauth_trigger = eLIM_HOST_DEAUTH;
2587 goto send_deauth;
2588 }
2589 return;
2590 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2591
2592 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2593 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002594 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002595 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2596 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2597 } else {
2598 deauth_trigger = eLIM_HOST_DEAUTH;
2599 reason_code = sme_deauth_req.reasonCode;
2600 }
2601
2602 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302603 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002604 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002605 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606 if (mac_ctx->lim.gLimRspReqd) {
2607 mac_ctx->lim.gLimRspReqd = false;
2608 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2609 deauth_trigger = eLIM_HOST_DEAUTH;
2610 goto send_deauth;
2611 }
2612 return;
2613 }
2614
Anurag Chouhanc5548422016-02-24 18:33:27 +05302615 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002616 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002617
2618 mlm_deauth_req->reasonCode = reason_code;
2619 mlm_deauth_req->deauthTrigger = deauth_trigger;
2620
2621 /* Update PE session Id */
2622 mlm_deauth_req->sessionId = session_id;
2623
2624 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2625 (uint32_t *)mlm_deauth_req);
2626 return;
2627
2628send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002629 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2630 ret_code, deauth_trigger, 1,
2631 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002632}
2633
2634/**
2635 * __lim_process_sme_set_context_req()
2636 *
2637 * @mac_ctx: Pointer to Global MAC structure
2638 * @msg_buf: pointer to the SME message buffer
2639 *
2640 * This function is called to process SME_SETCONTEXT_REQ message
2641 * from HDD or upper layer application.
2642 *
2643 * Return: None
2644 */
2645
2646static void
2647__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2648{
2649 tpSirSmeSetContextReq set_context_req;
2650 tLimMlmSetKeysReq *mlm_set_key_req;
2651 tpPESession session_entry;
2652 uint8_t session_id; /* PE sessionID */
2653 uint8_t sme_session_id;
2654 uint16_t sme_transaction_id;
2655
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002656 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002657 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002658 return;
2659 }
2660
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302661 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002662 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002663 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002664 return;
2665 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302666 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002667 sizeof(struct sSirSmeSetContextReq));
2668 sme_session_id = set_context_req->sessionId;
2669 sme_transaction_id = set_context_req->transactionId;
2670
2671 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002672 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002673 goto end;
2674 }
2675
2676 if (set_context_req->keyMaterial.numKeys >
2677 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002678 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002679 set_context_req->keyMaterial.numKeys);
2680 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002681 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002682 eSIR_SME_INVALID_PARAMETERS, NULL,
2683 sme_session_id, sme_transaction_id);
2684 goto end;
2685 }
2686
2687 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002688 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002689 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002690 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002691 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002692 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002693 eSIR_SME_INVALID_PARAMETERS, NULL,
2694 sme_session_id, sme_transaction_id);
2695 goto end;
2696 }
2697#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2698 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2699 session_entry, 0, 0);
2700#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2701
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002702 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002703 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2704 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002705 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002706 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2707 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302708 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002709 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002710 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002711 goto end;
2712 }
2713 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2714 mlm_set_key_req->numKeys =
2715 set_context_req->keyMaterial.numKeys;
2716 if (mlm_set_key_req->numKeys >
2717 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002718 pe_err("no.of keys exceeded max num of default keys limit");
Jingxiang Ge4168a232018-01-03 18:47:15 +08002719 qdf_mem_free(mlm_set_key_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002720 goto end;
2721 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302722 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002723 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002724
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302725 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002726 (uint8_t *) &set_context_req->keyMaterial.key,
2727 sizeof(tSirKeys) *
2728 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2729 numKeys : 1));
2730
2731 mlm_set_key_req->sessionId = session_id;
2732 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002733 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002734 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002735
2736 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2737 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2738 LIM_IS_AP_ROLE(session_entry)) {
2739 if (set_context_req->keyMaterial.key[0].keyLength) {
2740 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002741
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002742 key_id =
2743 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302744 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002745 &session_entry->WEPKeyMaterial[key_id],
2746 (uint8_t *) &set_context_req->keyMaterial,
2747 sizeof(tSirKeyMaterial));
2748 } else {
2749 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002750
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002751 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2752 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302753 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002754 &mlm_set_key_req->key[i],
2755 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2756 sizeof(tSirKeys));
2757 }
2758 }
2759 }
2760 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2761 (uint32_t *) mlm_set_key_req);
2762 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002763 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002764 GET_LIM_SYSTEM_ROLE(session_entry),
2765 session_entry->limSmeState);
2766 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2767
2768 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002769 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002770 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2771 session_entry, sme_session_id,
2772 sme_transaction_id);
2773 }
2774end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302775 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002776 return;
2777}
2778
2779/**
2780 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2781 *
2782 * @mac_ctx: Pointer to Global MAC structure
2783 * @msg_buf: pointer to the SME message buffer
2784 *
2785 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2786 * from HDD or upper layer application.
2787 *
2788 * Return: None
2789 */
2790
Jeff Johnson801f1532016-10-07 07:54:50 -07002791static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2792 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002793{
2794 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2795 tpDphHashNode sta_ds = NULL;
2796 tpPESession session_entry = NULL;
2797 tSap_Event sap_event;
2798 tpWLAN_SAPEventCB sap_event_cb = NULL;
2799 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2800 uint8_t session_id = CSR_SESSION_ID_INVALID;
2801 uint8_t assoc_id = 0;
2802 uint8_t sta_cnt = 0;
2803
2804 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002805 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002806 return;
2807 }
2808
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302809 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002810 sizeof(struct sSirSmeGetAssocSTAsReq));
2811 /*
2812 * Get Associated stations from PE.
2813 * Find PE session Entry
2814 */
2815 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08002816 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002817 &session_id);
2818 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002819 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002820 goto lim_assoc_sta_end;
2821 }
2822
2823 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002824 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002825 session_entry->limSmeState,
2826 GET_LIM_SYSTEM_ROLE(session_entry));
2827 goto lim_assoc_sta_end;
2828 }
2829 /* Retrieve values obtained in the request message */
2830 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
2831 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2832
2833 if (NULL == assoc_sta_tmp)
2834 goto lim_assoc_sta_end;
2835 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
2836 assoc_id++) {
2837 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
2838 &session_entry->dph.dphHashTable);
2839 if (NULL == sta_ds)
2840 continue;
2841 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302842 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002843 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302844 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002845 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
2846 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
2847
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302848 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002849 (uint8_t *)&sta_ds->supportedRates,
2850 sizeof(tSirSupportedRates));
2851 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
2852 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
2853 assoc_sta_tmp->Support40Mhz =
2854 sta_ds->htDsssCckRate40MHzSupport;
2855
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002856 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002857 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002858 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002859 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002860 pe_debug("Association Id: %d Station Index: %d",
2861 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002862 assoc_sta_tmp++;
2863 sta_cnt++;
2864 }
2865 }
2866lim_assoc_sta_end:
2867 /*
2868 * Call hdd callback with sap event to send the list of
2869 * associated stations from PE
2870 */
2871 if (sap_event_cb != NULL) {
2872 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
2873 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302874 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002875 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
2876 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
2877 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2878 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
2879 }
2880}
2881
2882/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002883 * __lim_counter_measures()
2884 *
2885 * FUNCTION:
2886 * This function is called to "implement" MIC counter measure
2887 * and is *temporary* only
2888 *
2889 * LOGIC: on AP, disassoc all STA associated thru TKIP,
2890 * we don't do the proper STA disassoc sequence since the
Jeff Johnsond460e842018-05-11 13:25:53 -07002891 * BSS will be stopped anyway
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002892 *
2893 ***ASSUMPTIONS:
2894 *
2895 ***NOTE:
2896 *
2897 * @param pMac Pointer to Global MAC structure
2898 * @return None
2899 */
2900
2901static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
2902{
2903 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002904
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002905 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002906 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
2907 mac, psessionEntry, false);
2908};
2909
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002910static void
2911__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2912{
2913 tSirSmeStopBssReq stopBssReq;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002914 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002915 tLimSmeStates prevState;
2916 tpPESession psessionEntry;
2917 uint8_t smesessionId;
2918 uint8_t sessionId;
2919 uint16_t smetransactionId;
2920 uint8_t i = 0;
2921 tpDphHashNode pStaDs = NULL;
2922
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302923 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002924 smesessionId = stopBssReq.sessionId;
2925 smetransactionId = stopBssReq.transactionId;
2926
2927 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002928 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929 /* Send Stop BSS response to host */
2930 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2931 eSIR_SME_INVALID_PARAMETERS, smesessionId,
2932 smetransactionId);
2933 return;
2934 }
2935
2936 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08002937 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002938 &sessionId);
2939 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002940 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002941 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2942 eSIR_SME_INVALID_PARAMETERS, smesessionId,
2943 smetransactionId);
2944 return;
2945 }
2946#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2947 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
2948 0, 0);
2949#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2950
2951 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
2952 LIM_IS_STA_ROLE(psessionEntry)) {
2953 /**
2954 * Should not have received STOP_BSS_REQ in states
2955 * other than 'normal' state or on STA in Infrastructure
2956 * mode. Log error and return response to host.
2957 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002958 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002959 psessionEntry->limSmeState,
2960 GET_LIM_SYSTEM_ROLE(psessionEntry));
2961 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
2962 /* / Send Stop BSS response to host */
2963 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2964 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
2965 smetransactionId);
2966 return;
2967 }
2968
2969 if (LIM_IS_AP_ROLE(psessionEntry))
2970 lim_wpspbc_close(pMac, psessionEntry);
2971
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002972 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002973 stopBssReq.reasonCode);
2974
2975 prevState = psessionEntry->limSmeState;
2976
2977 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
2978 MTRACE(mac_trace
2979 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
2980 psessionEntry->limSmeState));
2981
2982 /* Update SME session Id and Transaction Id */
2983 psessionEntry->smeSessionId = smesessionId;
2984 psessionEntry->transactionId = smetransactionId;
2985
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002986 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
2987 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
2988 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002989 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002990
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002991 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
2992 /* Send disassoc all stations associated thru TKIP */
2993 __lim_counter_measures(pMac, psessionEntry);
2994 else
2995 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002996 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
2997 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002998 }
2999
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003000 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3001 /* Free the buffer allocated in START_BSS_REQ */
3002 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3003 psessionEntry->addIeParams.probeRespDataLen = 0;
3004 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003005
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003006 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3007 psessionEntry->addIeParams.assocRespDataLen = 0;
3008 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003009
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003010 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3011 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3012 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003013
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003014 /*
3015 * lim_del_bss is also called as part of coalescing,
3016 * when we send DEL BSS followed by Add Bss msg.
3017 */
3018 pMac->lim.gLimIbssCoalescingHappened = false;
3019 }
Sandeep Puligillaa894ffc2018-06-01 15:33:36 -07003020 for (i = 1; i < psessionEntry->dph.dphHashTable.size; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003021 pStaDs =
3022 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3023 if (NULL == pStaDs)
3024 continue;
3025 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003026 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003027 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3028 pStaDs->assocId, psessionEntry);
3029 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3030 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003031 pe_err("lim_del_sta failed with Status: %d", status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303032 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003033 }
3034 }
3035 /* send a delBss to HAL and wait for a response */
3036 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3037
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003038 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003039 pe_err("delBss failed for bss %d", psessionEntry->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003040 psessionEntry->limSmeState = prevState;
3041
3042 MTRACE(mac_trace
3043 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3044 psessionEntry->limSmeState));
3045
3046 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3047 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3048 smetransactionId);
3049 }
3050}
3051
3052/**
3053 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3054 * @pMac: Global MAC context
3055 * @pMsg: Message from SME
3056 *
3057 * Wrapper for the function __lim_handle_sme_stop_bss_request
3058 * This message will be defered until softmac come out of
3059 * scan mode. Message should be handled even if we have
3060 * detected radar in the current operating channel.
3061 *
3062 * Return: true - If we consumed the buffer
3063 * false - If have defered the message.
3064 */
3065
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003066static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3067 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003068{
3069 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3070 /**
3071 * If message defered, buffer is not consumed yet.
3072 * So return false
3073 */
3074 return false;
3075 }
3076 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3077 return true;
3078} /*** end __lim_process_sme_stop_bss_req() ***/
3079
3080void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3081 uint32_t body, tpPESession psessionEntry)
3082{
3083
3084 (void)body;
3085 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3086 lim_ibss_delete(pMac, psessionEntry);
3087 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3088 lim_delete_pre_auth_list(pMac);
3089 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3090 psessionEntry->smeSessionId,
3091 psessionEntry->transactionId);
3092 return;
3093}
3094
3095/**
3096 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3097 *
3098 * @mac_ctx: pointer to mac context
3099 * @msg_type: message type
3100 * @msg_buf: pointer to the SME message buffer
3101 *
3102 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3103 * in BTAMP AP.
3104 *
3105 * Return: None
3106 */
3107
3108void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3109 uint32_t *msg_buf)
3110{
3111 tSirSmeAssocCnf assoc_cnf;
3112 tpDphHashNode sta_ds = NULL;
3113 tpPESession session_entry = NULL;
3114 uint8_t session_id;
3115 tpSirAssocReq assoc_req;
3116
3117 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003118 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003119 goto end;
3120 }
3121
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303122 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003123 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003124 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003125 goto end;
3126 }
3127
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003128 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003129 &session_id);
3130 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003131 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003132 goto end;
3133 }
3134
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003135 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003136 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3137 (session_entry->limSmeState !=
3138 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003139 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003140 msg_type, session_entry->limSmeState,
3141 GET_LIM_SYSTEM_ROLE(session_entry));
3142 goto end;
3143 }
3144 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3145 &session_entry->dph.dphHashTable);
3146 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003147 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003148 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303149 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003150
3151 /*
3152 * send a DISASSOC_IND message to WSM to make sure
3153 * the state in WSM and LIM is the same
3154 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003155 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003156 eSIR_SME_STA_NOT_ASSOCIATED,
3157 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3158 session_entry->smeSessionId,
3159 session_entry->transactionId,
3160 session_entry);
3161 goto end;
3162 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303163 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003164 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303165 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003166 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003167 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303168 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003169 goto end;
3170 }
3171
3172 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3173 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3174 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3175 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3176 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003177 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3178 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003179 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303180 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003181 goto end;
3182 }
3183 /*
3184 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3185 * has been received
3186 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003187 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003188 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3189 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3190
3191 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3192 /*
3193 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3194 * when it had received Assoc Request frame. Now, PE just needs
3195 * to send association rsp frame to the requesting BTAMP-STA.
3196 */
3197 sta_ds->mlmStaContext.mlmState =
3198 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003199 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003200 sta_ds->assocId);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003201 lim_send_assoc_rsp_mgmt_frame(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003202 sta_ds->assocId, sta_ds->staAddr,
3203 sta_ds->mlmStaContext.subType, sta_ds,
3204 session_entry);
3205 goto end;
3206 } else {
3207 /*
3208 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3209 * to be associated since the HAL sta entry is created for
3210 * denied STA we need to remove this HAL entry.
3211 * So to do that set updateContext to 1
3212 */
3213 if (!sta_ds->mlmStaContext.updateContext)
3214 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003215 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003216 assoc_cnf.statusCode, sta_ds->assocId);
3217 lim_reject_association(mac_ctx, sta_ds->staAddr,
3218 sta_ds->mlmStaContext.subType,
3219 true, sta_ds->mlmStaContext.authType,
3220 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003221 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003222 session_entry);
3223 }
3224end:
3225 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3226 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3227 assoc_req = (tpSirAssocReq)
3228 session_entry->parsedAssocReq[sta_ds->assocId];
3229 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303230 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003231 assoc_req->assocReqFrame = NULL;
3232 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303233 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003234 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3235 }
3236}
3237
3238static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3239{
3240 tpDphHashNode pStaDs;
3241 tSirMacAddr peerMac;
3242 tpSirAddtsReq pSirAddts;
3243 uint32_t timeout;
3244 tpPESession psessionEntry;
3245 uint8_t sessionId; /* PE sessionId */
3246 uint8_t smesessionId;
3247 uint16_t smetransactionId;
3248
3249 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003250 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003251 return;
3252 }
3253
3254 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3255 &smetransactionId);
3256
3257 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3258
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003259 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3260 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003261 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003262 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003263 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303264 NULL, pSirAddts->req.tspec,
3265 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003266 return;
3267 }
3268#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3269 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3270 0);
3271#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3272
3273 /* if sta
3274 * - verify assoc state
3275 * - send addts request to ap
3276 * - wait for addts response from ap
3277 * if ap, just ignore with error log
3278 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003279 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3280 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3281 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003282
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003283 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003284 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303285 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003286 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003287
3288 pStaDs =
3289 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3290 &psessionEntry->dph.dphHashTable);
3291
3292 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003293 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303294 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003295 }
3296
3297 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3298 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003299 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303300 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003301 }
3302
3303 pSirAddts->req.wsmTspecPresent = 0;
3304 pSirAddts->req.wmeTspecPresent = 0;
3305 pSirAddts->req.lleTspecPresent = 0;
3306
3307 if ((pStaDs->wsmEnabled) &&
3308 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3309 SIR_MAC_ACCESSPOLICY_EDCA))
3310 pSirAddts->req.wsmTspecPresent = 1;
3311 else if (pStaDs->wmeEnabled)
3312 pSirAddts->req.wmeTspecPresent = 1;
3313 else if (pStaDs->lleEnabled)
3314 pSirAddts->req.lleTspecPresent = 1;
3315 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003316 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303317 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003318 }
3319
3320 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3321 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003322 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003323 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303324 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003325 }
3326
3327 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003328 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003329 pMac->lim.gLimAddtsReq.req.dialogToken,
3330 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3331 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3332 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303333 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003334 }
3335
3336 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3337
3338 /* save the addts request */
3339 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303340 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003341 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3342
3343 /* ship out the message now */
3344 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3345 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303346 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003347 /* start a timer to wait for the response */
3348 if (pSirAddts->timeout)
3349 timeout = pSirAddts->timeout;
3350 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003351 QDF_STATUS_SUCCESS) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303352 pe_debug("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003353 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303354 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003355 }
3356
3357 timeout = SYS_MS_TO_TICKS(timeout);
3358 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3359 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003360 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303361 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003362 }
3363 pMac->lim.gLimAddtsRspTimerCount++;
3364 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3365 pMac->lim.gLimAddtsRspTimerCount) !=
3366 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003367 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303368 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003369 }
3370 MTRACE(mac_trace
3371 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3372 eLIM_ADDTS_RSP_TIMER));
3373
3374 /* add the sessionId to the timer object */
3375 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3376 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3377 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003378 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303379 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003380 }
3381 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303382
3383send_failure_addts_rsp:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003384 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303385 psessionEntry, pSirAddts->req.tspec,
3386 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003387}
3388
3389static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3390{
3391 tSirMacAddr peerMacAddr;
3392 uint8_t ac;
3393 tSirMacTSInfo *pTsinfo;
3394 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3395 tpDphHashNode pStaDs = NULL;
3396 tpPESession psessionEntry;
3397 uint8_t sessionId;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003398 uint32_t status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003399 uint8_t smesessionId;
3400 uint16_t smetransactionId;
3401
3402 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3403 &smetransactionId);
3404
3405 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003406 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003407 &sessionId);
3408 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003409 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003410 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003411 goto end;
3412 }
3413#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3414 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3415 0);
3416#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3417
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003418 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003419 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003420 pe_err("lim_validate_delts_req failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003421 status = QDF_STATUS_E_FAILURE;
3422 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_E_FAILURE, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003423 smesessionId, smetransactionId);
3424 return;
3425 }
3426
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003427 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3428 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003429 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3430
3431 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3432 pDeltsReq->req.wmeTspecPresent,
3433 &pDeltsReq->req.tsinfo,
3434 &pDeltsReq->req.tspec, psessionEntry);
3435
3436 pTsinfo =
3437 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3438 tsinfo : &pDeltsReq->req.tsinfo;
3439
3440 /* We've successfully send DELTS frame to AP. Update the
3441 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3442 * is no longer trigger enabled or delivery enabled
3443 */
3444 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3445 pTsinfo, CLEAR_UAPSD_MASK);
3446
3447 /* We're deleting the TSPEC, so this particular AC is no longer
3448 * admitted. PE needs to downgrade the EDCA
3449 * parameters(for the AC for which TS is being deleted) to the
3450 * next best AC for which ACM is not enabled, and send the
3451 * updated values to HAL.
3452 */
3453 ac = upToAc(pTsinfo->traffic.userPrio);
3454
3455 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3456 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3457 ~(1 << ac);
3458 } else if (pTsinfo->traffic.direction ==
3459 SIR_MAC_DIRECTION_DNLINK) {
3460 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3461 ~(1 << ac);
3462 } else if (pTsinfo->traffic.direction ==
3463 SIR_MAC_DIRECTION_BIDIR) {
3464 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3465 ~(1 << ac);
3466 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3467 ~(1 << ac);
3468 }
3469
3470 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3471 psessionEntry);
3472
3473 pStaDs =
3474 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3475 &psessionEntry->dph.dphHashTable);
3476 if (pStaDs != NULL) {
3477 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003478 pStaDs->bssId, false);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003479 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003480 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003481 pe_err("Self entry missing in Hash Table");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003482 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003483 }
3484#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003485 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003486#endif
3487
3488 /* send an sme response back */
3489end:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003490 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_SUCCESS, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003491 smesessionId, smetransactionId);
3492}
3493
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303494void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003495{
3496 /* fetch the sessionEntry based on the sessionId */
3497 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003498
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003499 psessionEntry = pe_find_session_by_session_id(pMac,
3500 pMac->lim.limTimers.gLimAddtsRspTimer.
3501 sessionId);
3502 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003503 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003504 return;
3505 }
3506
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003507 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003508 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003509 GET_LIM_SYSTEM_ROLE(psessionEntry));
3510 pMac->lim.gLimAddtsSent = false;
3511 return;
3512 }
3513
3514 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003515 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003516 return;
3517 }
3518
3519 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003520 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003521 pMac->lim.gLimAddtsRspTimerCount);
3522 return;
3523 }
3524 /* this a real response timeout */
3525 pMac->lim.gLimAddtsSent = false;
3526 pMac->lim.gLimAddtsRspTimerCount++;
3527
3528 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3529 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3530 psessionEntry->smeSessionId,
3531 psessionEntry->transactionId);
3532}
3533
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003534#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003535/**
3536 * __lim_process_sme_get_statistics_request()
3537 *
3538 ***FUNCTION:
3539 *
3540 *
3541 ***NOTE:
3542 *
3543 * @param pMac Pointer to Global MAC structure
3544 * @param *pMsgBuf A pointer to the SME message buffer
3545 * @return None
3546 */
3547static void
3548__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3549{
3550 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003551 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003552
3553 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3554
3555 msgQ.type = WMA_GET_STATISTICS_REQ;
3556
3557 msgQ.reserved = 0;
3558 msgQ.bodyptr = pMsgBuf;
3559 msgQ.bodyval = 0;
3560 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3561
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003562 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303563 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003564 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003565 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003566 return;
3567 }
3568
3569 return;
3570}
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003571#else
3572static void __lim_process_sme_get_statistics_request(
3573 struct sAniSirGlobal *mac_ctx, uint32_t *pMsgBuf) {}
3574#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003575
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003576#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003577/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003578 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003579 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003580 * @pMac: Pointer to Global MAC structure
3581 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003582 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003583 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003584 */
3585static void
3586__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3587{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003588 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003589
3590 msgQ.type = WMA_TSM_STATS_REQ;
3591 msgQ.reserved = 0;
3592 msgQ.bodyptr = pMsgBuf;
3593 msgQ.bodyval = 0;
3594 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3595
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003596 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303597 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003599 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003600 return;
3601 }
3602}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003603#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003604
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08003605static void lim_process_sme_set_addba_accept(tpAniSirGlobal mac_ctx,
3606 struct sme_addba_accept *msg)
3607{
3608 if (!msg) {
3609 pe_err("Msg Buffer is NULL");
3610 return;
3611 }
3612 if (!msg->addba_accept)
3613 mac_ctx->reject_addba_req = 1;
3614 else
3615 mac_ctx->reject_addba_req = 0;
3616}
3617
Arif Hussaineb8ba362018-03-07 19:15:13 -08003618static void lim_process_sme_update_edca_params(tpAniSirGlobal mac_ctx,
3619 uint32_t sme_session_id)
3620{
3621 tpPESession pe_session;
3622 tpDphHashNode sta_ds_ptr;
3623
3624 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3625 if (!pe_session) {
3626 pe_err("Session does not exist: sme_id %d", sme_session_id);
3627 return;
3628 }
3629 pe_session->gLimEdcaParamsActive[EDCA_AC_BE].no_ack =
3630 mac_ctx->no_ack_policy_cfg[EDCA_AC_BE];
3631 pe_session->gLimEdcaParamsActive[EDCA_AC_BK].no_ack =
3632 mac_ctx->no_ack_policy_cfg[EDCA_AC_BK];
3633 pe_session->gLimEdcaParamsActive[EDCA_AC_VI].no_ack =
3634 mac_ctx->no_ack_policy_cfg[EDCA_AC_VI];
3635 pe_session->gLimEdcaParamsActive[EDCA_AC_VO].no_ack =
3636 mac_ctx->no_ack_policy_cfg[EDCA_AC_VO];
3637 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3638 &pe_session->dph.dphHashTable);
3639 if (sta_ds_ptr)
3640 lim_send_edca_params(mac_ctx,
3641 pe_session->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003642 sta_ds_ptr->bssId, false);
Arif Hussaineb8ba362018-03-07 19:15:13 -08003643 else
3644 pe_err("Self entry missing in Hash Table");
3645}
3646
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07003647static void lim_process_sme_update_mu_edca_params(tpAniSirGlobal mac_ctx,
3648 uint32_t sme_session_id)
3649{
3650 tpPESession pe_session;
3651 tpDphHashNode sta_ds_ptr;
3652
3653 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3654 if (!pe_session) {
3655 pe_err("Session does not exist: sme_id %d", sme_session_id);
3656 return;
3657 }
3658 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3659 &pe_session->dph.dphHashTable);
3660 if (sta_ds_ptr)
3661 lim_send_edca_params(mac_ctx, mac_ctx->usr_mu_edca_params,
3662 sta_ds_ptr->bssId, true);
3663 else
3664 pe_err("Self entry missing in Hash Table");
3665}
3666
Naveen Rawat8029a402017-06-01 10:54:19 -07003667static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3668 struct update_config *msg)
3669{
3670 tpPESession pe_session;
3671
3672 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3673 if (msg == NULL) {
3674 pe_err("Buffer is Pointing to NULL");
3675 return;
3676 }
3677
3678 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3679 msg->sme_session_id);
3680 if (pe_session == NULL) {
3681 pe_warn("Session does not exist for given BSSID");
3682 return;
3683 }
3684
3685 switch (msg->capab) {
3686 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3687 pe_session->htConfig.ht_rx_ldpc = msg->value;
3688 break;
3689 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3690 pe_session->htConfig.ht_tx_stbc = msg->value;
3691 break;
3692 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3693 pe_session->htConfig.ht_rx_stbc = msg->value;
3694 break;
3695 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3696 pe_session->htConfig.ht_sgi20 = msg->value;
3697 break;
3698 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3699 pe_session->htConfig.ht_sgi40 = msg->value;
3700 break;
3701 }
3702
3703 if (LIM_IS_AP_ROLE(pe_session)) {
3704 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3705 lim_send_beacon_ind(mac_ctx, pe_session);
3706 }
3707}
3708
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003709void
3710lim_send_vdev_restart(tpAniSirGlobal pMac,
3711 tpPESession psessionEntry, uint8_t sessionId)
3712{
3713 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003714 struct scheduler_msg msgQ = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003715 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003716
3717 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003718 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003719 return;
3720 }
3721
3722 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303723 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003724 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003725 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003726 return;
3727 }
3728
3729 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3730 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003731 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003732
3733 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3734 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3735 msgQ.bodyval = 0;
3736
3737 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003738 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003739 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303740 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003741 }
3742}
3743
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303744/**
3745 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3746 * @mac_ctx: Pointer to Global MAC structure
3747 * @msg_buf: Pointer to SME message buffer
3748 *
3749 * Return: None
3750 */
3751static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3752 uint32_t *msg_buf)
3753{
3754 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003755 struct scheduler_msg wma_msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003756 QDF_STATUS status;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303757 tSirRoamOffloadScanReq *req_buffer;
3758 uint16_t local_ie_len;
3759 uint8_t *local_ie_buf;
3760
3761 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3762 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3763 req_buffer->sessionId);
3764
3765 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3766 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003767 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303768 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303769 return;
3770 }
3771
3772 local_ie_len = req_buffer->assoc_ie.length;
3773 /* Update ext cap IE if present */
3774 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003775 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3776 local_ie_buf, &local_ie_len)) {
3777 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003778 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3779 req_buffer->assoc_ie.length = local_ie_len;
3780 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3781 local_ie_buf, local_ie_len);
3782 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303783 }
3784 qdf_mem_free(local_ie_buf);
3785
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303786 if (pe_session)
3787 lim_update_fils_rik(pe_session, req_buffer);
3788
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303789 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3790 wma_msg.bodyptr = req_buffer;
3791
3792 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003793 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003794 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303795 qdf_mem_free(req_buffer);
3796 }
3797}
3798
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303799/*
3800 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3801 * @mac_ctx: Pointer to global mac context
3802 * @session: Pointer to PE session
3803 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3804 * 1 - Disable broadcast SSID
3805 *
3806 * Return: None
3807 */
3808static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3809 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003810{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003811 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003812 session->ssidHidden, ssid_hidden);
3813
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003814 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303815 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003816 } else {
3817 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05303818 return;
3819 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003820
3821 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303822 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003823
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003824 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303825}
3826
3827/**
3828 * __lim_process_sme_session_update - process SME session update msg
3829 *
3830 * @mac_ctx: Pointer to global mac context
3831 * @msg_buf: Pointer to the received message buffer
3832 *
3833 * Return: None
3834 */
3835static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
3836 uint32_t *msg_buf)
3837{
3838 struct sir_update_session_param *msg;
3839 tpPESession session;
3840
3841 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003842 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303843 return;
3844 }
3845
3846 msg = (struct sir_update_session_param *) msg_buf;
3847
3848 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
3849 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003850 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303851 msg->session_id);
3852 return;
3853 }
3854
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003855 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303856 msg->param_type, msg->param_val);
3857 switch (msg->param_type) {
3858 case SIR_PARAM_SSID_HIDDEN:
3859 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
3860 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303861 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
3862 session->ignore_assoc_disallowed = msg->param_val;
3863 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303864 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003865 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303866 break;
3867 }
3868}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003869
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003870/*
3871 Update the beacon Interval dynamically if beaconInterval is different in MCC
3872 */
3873static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3874{
3875 tpSirChangeBIParams pChangeBIParams;
3876 tpPESession psessionEntry;
3877 uint8_t sessionId = 0;
3878 tUpdateBeaconParams beaconParams;
3879
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003880 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003881
3882 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003883 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003884 return;
3885 }
3886
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303887 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003888 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
3889
3890 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08003891 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003892 &sessionId);
3893 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003894 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003895 return;
3896 }
3897
3898 /*Update sessionEntry Beacon Interval */
3899 if (psessionEntry->beaconParams.beaconInterval !=
3900 pChangeBIParams->beaconInterval) {
3901 psessionEntry->beaconParams.beaconInterval =
3902 pChangeBIParams->beaconInterval;
3903 }
3904
3905 /*Update sch beaconInterval */
3906 if (pMac->sch.schObject.gSchBeaconInterval !=
3907 pChangeBIParams->beaconInterval) {
3908 pMac->sch.schObject.gSchBeaconInterval =
3909 pChangeBIParams->beaconInterval;
3910
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003911 pe_debug("LIM send update BeaconInterval Indication: %d",
3912 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003913
3914 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
3915 /* Update beacon */
3916 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3917
3918 beaconParams.bssIdx = psessionEntry->bssIdx;
3919 /* Set change in beacon Interval */
3920 beaconParams.beaconInterval =
3921 pChangeBIParams->beaconInterval;
3922 beaconParams.paramChangeBitmap =
3923 PARAM_BCN_INTERVAL_CHANGED;
3924 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
3925 }
3926 }
3927
3928 return;
3929} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
3930
3931#ifdef QCA_HT_2040_COEX
3932static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
3933 uint32_t *pMsgBuf)
3934{
3935 tpSirSetHT2040Mode pSetHT2040Mode;
3936 tpPESession psessionEntry;
3937 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003938 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003939 tUpdateVHTOpMode *pHtOpMode = NULL;
3940 uint16_t staId = 0;
3941 tpDphHashNode pStaDs = NULL;
3942
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003943 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003944 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003945 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003946 return;
3947 }
3948
3949 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
3950
3951 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08003952 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003953 &sessionId);
3954 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003955 pe_debug("Session does not exist for given BSSID");
3956 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003957 return;
3958 }
3959
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003960 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003961 pSetHT2040Mode->cbMode);
3962 /*Update sessionEntry HT related fields */
3963 switch (pSetHT2040Mode->cbMode) {
3964 case PHY_SINGLE_CHANNEL_CENTERED:
3965 psessionEntry->htSecondaryChannelOffset =
3966 PHY_SINGLE_CHANNEL_CENTERED;
3967 psessionEntry->htRecommendedTxWidthSet = 0;
3968 if (pSetHT2040Mode->obssEnabled)
3969 psessionEntry->htSupportedChannelWidthSet
3970 = eHT_CHANNEL_WIDTH_40MHZ;
3971 else
3972 psessionEntry->htSupportedChannelWidthSet
3973 = eHT_CHANNEL_WIDTH_20MHZ;
3974 break;
3975 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
3976 psessionEntry->htSecondaryChannelOffset =
3977 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3978 psessionEntry->htRecommendedTxWidthSet = 1;
3979 break;
3980 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
3981 psessionEntry->htSecondaryChannelOffset =
3982 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3983 psessionEntry->htRecommendedTxWidthSet = 1;
3984 break;
3985 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003986 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003987 return;
3988 }
3989
3990 /* Update beacon */
3991 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3992 lim_send_beacon_ind(pMac, psessionEntry);
3993
3994 /* update OP Mode for each associated peer */
3995 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
3996 pStaDs = dph_get_hash_entry(pMac, staId,
3997 &psessionEntry->dph.dphHashTable);
3998 if (NULL == pStaDs)
3999 continue;
4000
4001 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304002 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004003 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004004 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004005 return;
4006 }
4007 pHtOpMode->opMode =
4008 (psessionEntry->htSecondaryChannelOffset ==
4009 PHY_SINGLE_CHANNEL_CENTERED) ?
4010 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4011 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304012 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004013 sizeof(tSirMacAddr));
4014 pHtOpMode->smesessionId = sessionId;
4015
4016 msg.type = WMA_UPDATE_OP_MODE;
4017 msg.reserved = 0;
4018 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004019 if (!QDF_IS_STATUS_SUCCESS
4020 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
4021 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304022 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004023 return;
4024 }
Jeff Johnson47d75242018-05-12 15:58:53 -07004025 pe_debug("Notified FW about OP mode: %d for staId=%d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004026 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004027
4028 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004029 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004030 }
4031
4032 return;
4033}
4034#endif
4035
4036/* -------------------------------------------------------------------- */
4037/**
4038 * __lim_process_report_message
4039 *
4040 * FUNCTION: Processes the next received Radio Resource Management message
4041 *
4042 * LOGIC:
4043 *
4044 * ASSUMPTIONS:
4045 *
4046 * NOTE:
4047 *
4048 * @param None
4049 * @return None
4050 */
4051
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004052static void __lim_process_report_message(tpAniSirGlobal pMac,
4053 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004054{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004055 switch (pMsg->type) {
4056 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4057 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4058 break;
4059 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004060 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004061 break;
4062 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004063 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004064 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004065}
4066
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004067/* -------------------------------------------------------------------- */
4068/**
4069 * lim_send_set_max_tx_power_req
4070 *
4071 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4072 *
4073 * LOGIC:
4074 *
4075 * ASSUMPTIONS:
4076 *
4077 * NOTE:
4078 *
4079 * @param txPower txPower to be set.
4080 * @param pSessionEntry session entry.
4081 * @return None
4082 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004083QDF_STATUS
Amar Singhala297bfa2015-10-15 15:07:29 -07004084lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004085 tpPESession pSessionEntry)
4086{
4087 tpMaxTxPowerParams pMaxTxParams = NULL;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004088 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004089 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004090
4091 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004092 pe_err("Invalid parameters");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004093 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004094 }
4095
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304096 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004097 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004098 pe_err("Unable to allocate memory for pMaxTxParams");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004099 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004100
4101 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004102 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304103 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304104 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304105 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004106 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304107 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004108
4109 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4110 msgQ.bodyptr = pMaxTxParams;
4111 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004112 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004113 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4114 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004115 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004116 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304117 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004118 }
4119 return retCode;
4120}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004121
4122/**
4123 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4124 *
4125 * @mac_ctx: Pointer to Global MAC structure
4126 * @msg_buf: pointer to the SME message buffer
4127 *
4128 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4129 * from SME. It Register this information within PE.
4130 *
4131 * Return: None
4132 */
4133static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4134 uint32_t *msg_buf)
4135{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304136 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004137 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4138 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4139 struct mgmt_frm_reg_info *next = NULL;
4140 bool match = false;
4141
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004142 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004143 sme_req->registerFrame, sme_req->frameType,
4144 sme_req->matchLen);
4145 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304146 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304147 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4148 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304149 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004150
4151 while (lim_mgmt_regn != NULL) {
4152 if (lim_mgmt_regn->frameType != sme_req->frameType)
4153 goto skip_match;
4154 if (sme_req->matchLen) {
4155 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304156 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004157 sme_req->matchData,
4158 lim_mgmt_regn->matchLen))) {
4159 /* found match! */
4160 match = true;
4161 break;
4162 }
4163 } else {
4164 /* found match! */
4165 match = true;
4166 break;
4167 }
4168skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304169 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304170 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004171 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304172 (qdf_list_node_t *)lim_mgmt_regn,
4173 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304174 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004175 lim_mgmt_regn = next;
4176 next = NULL;
4177 }
4178 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304179 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004180 if (QDF_STATUS_SUCCESS ==
4181 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004182 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004183 (qdf_list_node_t *)lim_mgmt_regn))
4184 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304185 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004186 }
4187
4188 if (sme_req->registerFrame) {
4189 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304190 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004191 sme_req->matchLen);
4192 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004193 lim_mgmt_regn->frameType = sme_req->frameType;
4194 lim_mgmt_regn->matchLen = sme_req->matchLen;
4195 lim_mgmt_regn->sessionId = sme_req->sessionId;
4196 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304197 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004198 sme_req->matchData,
4199 sme_req->matchLen);
4200 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304201 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004202 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304203 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004204 gLimMgmtFrameRegistratinQueue,
4205 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304206 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004207 &mac_ctx->lim.lim_frame_register_lock);
4208 }
4209 }
4210 return;
4211}
4212
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004213static void
4214__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4215{
4216 tpSirResetAPCapsChange pResetCapsChange;
4217 tpPESession psessionEntry;
4218 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004219
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004220 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004221 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004222 return;
4223 }
4224
4225 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4226 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004227 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4228 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004229 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004230 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004231 return;
4232 }
4233
4234 psessionEntry->limSentCapsChangeNtf = false;
4235 return;
4236}
4237
4238/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304239 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4240 * indication callback in PE.
4241 * @mac_ptr: Mac pointer
4242 * @msg_buf: Msg pointer containing the callback
4243 *
4244 * This function is used save the Management frame
4245 * indication callback in PE.
4246 *
4247 * Return: None
4248 */
4249static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4250 uint32_t *msg_buf)
4251{
4252 struct sir_sme_mgmt_frame_cb_req *sme_req =
4253 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4254
4255 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004256 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304257 return;
4258 }
4259 if (sme_req->callback)
4260 mac_ctx->mgmt_frame_ind_cb =
4261 (sir_mgmt_frame_ind_callback)sme_req->callback;
4262 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004263 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304264}
4265
4266/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304267 *__lim_process_send_disassoc_frame: function processes disassoc frame
4268 * @mac_ctx: pointer to mac context
4269 * @msg_buf: message buffer
4270 *
4271 * function processes disassoc request received from SME
4272 *
4273 * return: none
4274 */
4275static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4276 uint32_t *msg_buf)
4277{
4278 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004279 QDF_STATUS status;
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304280 tpPESession session_entry = NULL;
4281 uint8_t sme_session_id;
4282 uint16_t sme_trans_id;
4283
4284 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004285 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304286 return;
4287 }
4288
4289 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4290 &sme_trans_id);
4291
4292 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4293 &sme_send_disassoc_frame_req,
4294 (uint8_t *)msg_buf);
4295
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004296 if ((QDF_STATUS_E_FAILURE == status) ||
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304297 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4298 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004299 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304300 return;
4301 }
4302
4303 session_entry = pe_find_session_by_sme_session_id(
4304 mac_ctx, sme_session_id);
4305 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004306 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304307 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4308 return;
4309 }
4310
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004311 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 +05304312 sme_send_disassoc_frame_req.msg_type,
4313 sme_send_disassoc_frame_req.length,
4314 sme_send_disassoc_frame_req.session_id,
4315 sme_send_disassoc_frame_req.trans_id,
4316 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4317 sme_send_disassoc_frame_req.reason,
4318 sme_send_disassoc_frame_req.wait_for_ack);
4319
4320 lim_send_disassoc_mgmt_frame(mac_ctx,
4321 sme_send_disassoc_frame_req.reason,
4322 sme_send_disassoc_frame_req.peer_mac,
4323 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4324}
4325
4326/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004327 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4328 * @mac_ctx: Pointer to Global MAC structure
4329 * @pdev_id: pdev id to set the IE.
4330 * @nss: Nss values to prepare the HT IE.
4331 *
4332 * Prepares the HT IE with self capabilities for different
4333 * Nss values and sends the set HT IE req to FW.
4334 *
4335 * Return: None
4336 */
4337static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4338 uint8_t nss)
4339{
4340 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004341 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004342 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004343 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004344 tHtCaps *p_ht_cap;
4345 int i;
4346
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004347 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004348 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4349 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004350 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004351 return;
4352 }
4353 ie_params->nss = i;
4354 ie_params->pdev_id = pdev_id;
4355 ie_params->ie_type = DOT11_HT_IE;
4356 /* 2 for IE len and EID */
4357 ie_params->ie_len = 2 + sizeof(tHtCaps);
4358 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4359 if (NULL == ie_params->ie_ptr) {
4360 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004361 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004362 return;
4363 }
4364 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4365 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4366 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4367 ie_params->ie_len);
4368
4369 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004370 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4371 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004372 if (NULL == p_ie) {
4373 qdf_mem_free(ie_params->ie_ptr);
4374 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004375 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004376 return;
4377 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004378 p_ht_cap = (tHtCaps *)&p_ie[2];
4379 p_ht_cap->supportedMCSSet[1] = 0;
4380 p_ht_cap->txSTBC = 0;
4381 }
4382
4383 msg.type = WMA_SET_PDEV_IE_REQ;
4384 msg.bodyptr = ie_params;
4385 msg.bodyval = 0;
4386
4387 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004388 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004389 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004390 qdf_mem_free(ie_params->ie_ptr);
4391 qdf_mem_free(ie_params);
4392 return;
4393 }
4394 }
4395}
4396
4397/**
4398 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4399 * @mac_ctx: Pointer to Global MAC structure
4400 * @pdev_id: pdev id to set the IE.
4401 * @nss: Nss values to prepare the VHT IE.
4402 *
4403 * Prepares the VHT IE with self capabilities for different
4404 * Nss values and sends the set VHT IE req to FW.
4405 *
4406 * Return: None
4407 */
4408static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4409 uint8_t nss)
4410{
4411 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004412 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004413 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004414 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004415 tSirMacVHTCapabilityInfo *vht_cap;
4416 int i;
4417 tSirVhtMcsInfo *vht_mcs;
4418
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004419 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004420 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4421 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004422 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004423 return;
4424 }
4425 ie_params->nss = i;
4426 ie_params->pdev_id = pdev_id;
4427 ie_params->ie_type = DOT11_VHT_IE;
4428 /* 2 for IE len and EID */
4429 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4430 sizeof(tSirVhtMcsInfo);
4431 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4432 if (NULL == ie_params->ie_ptr) {
4433 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004434 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004435 return;
4436 }
4437 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4438 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4439 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4440 ie_params->ie_len);
4441
4442 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004443 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4444 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004445 if (NULL == p_ie) {
4446 qdf_mem_free(ie_params->ie_ptr);
4447 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004448 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004449 return;
4450 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004451 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4452 vht_cap->txSTBC = 0;
4453 vht_mcs =
4454 (tSirVhtMcsInfo *)&p_ie[2 +
4455 sizeof(tSirMacVHTCapabilityInfo)];
4456 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4457 vht_mcs->rxHighest =
4458 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4459 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4460 vht_mcs->txHighest =
4461 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4462 }
4463 msg.type = WMA_SET_PDEV_IE_REQ;
4464 msg.bodyptr = ie_params;
4465 msg.bodyval = 0;
4466
4467 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004468 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004469 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004470 qdf_mem_free(ie_params->ie_ptr);
4471 qdf_mem_free(ie_params);
4472 return;
4473 }
4474 }
4475}
4476
4477/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004478 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4479 * @mac_ctx: Pointer to Global MAC structure
4480 * @msg_buf: Pointer to the SME message buffer
4481 *
4482 * This function is called by limProcessMessageQueue(). This function sets the
4483 * VDEV IEs to the FW.
4484 *
4485 * Return: None
4486 */
4487static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4488 uint32_t *msg_buf)
4489{
4490 struct sir_set_vdev_ies_per_band *p_msg =
4491 (struct sir_set_vdev_ies_per_band *)msg_buf;
4492
4493 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004494 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004495 return;
4496 }
4497
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004498 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004499 p_msg->vdev_id);
4500 /* intentionally using NULL here so that self capabilty are sent */
4501 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4502 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004503 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004504}
4505
4506/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004507 * lim_process_set_pdev_IEs() - process the set pdev IE req
4508 * @mac_ctx: Pointer to Global MAC structure
4509 * @msg_buf: Pointer to the SME message buffer
4510 *
4511 * This function is called by limProcessMessageQueue(). This
4512 * function sets the PDEV IEs to the FW.
4513 *
4514 * Return: None
4515 */
4516static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4517{
4518 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4519
4520 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4521
4522 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004523 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004524 return;
4525 }
4526
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004527 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004528 ht_vht_cfg->nss);
4529 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4530
4531 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4532 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4533 ht_vht_cfg->nss);
4534}
4535
4536/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304537 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4538 *
4539 * access policy
4540 * @mac_ctx: pointer to mac context
4541 * @msg: message buffer
4542 *
4543 * function processes vendor IE and access policy from SME and updates PE
4544 *
4545 * session entry
4546 *
4547 * return: none
4548*/
4549static void lim_process_sme_update_access_policy_vendor_ie(
4550 tpAniSirGlobal mac_ctx,
4551 uint32_t *msg)
4552{
4553 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4554 struct sPESession *pe_session_entry;
Pragaspathi Thilagaraj9b7a1162018-05-07 16:28:13 +05304555 uint16_t num_bytes;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304556
4557 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004558 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304559 return;
4560 }
4561 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4562 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4563 update_vendor_ie->sme_session_id);
4564
4565 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004566 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304567 update_vendor_ie->sme_session_id);
4568 return;
4569 }
4570 if (pe_session_entry->access_policy_vendor_ie)
4571 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4572
4573 num_bytes = update_vendor_ie->ie[1] + 2;
4574 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4575
4576 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004577 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304578 return;
4579 }
4580 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4581 &update_vendor_ie->ie[0], num_bytes);
4582
4583 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4584}
4585
4586/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004587 * lim_process_sme_req_messages()
4588 *
4589 ***FUNCTION:
4590 * This function is called by limProcessMessageQueue(). This
4591 * function processes SME request messages from HDD or upper layer
4592 * application.
4593 *
4594 ***LOGIC:
4595 *
4596 ***ASSUMPTIONS:
4597 *
4598 ***NOTE:
4599 *
4600 * @param pMac Pointer to Global MAC structure
4601 * @param msgType Indicates the SME message type
4602 * @param *pMsgBuf A pointer to the SME message buffer
4603 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4604 * false - if pMsgBuf is not to be freed.
4605 */
4606
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004607bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4608 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004609{
Jeff Johnson33142e62018-05-06 17:58:36 -07004610 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 -08004611 uint32_t *pMsgBuf = pMsg->bodyptr;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004612
4613 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004614 lim_msg_str(pMsg->type), pMsg->type,
4615 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4616 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004617
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004618 /* If no insert NOA required then execute the code below */
4619
4620 switch (pMsg->type) {
4621 case eWNI_SME_SYS_READY_IND:
4622 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4623 break;
4624
4625 case eWNI_SME_START_BSS_REQ:
4626 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4627 break;
4628
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004629 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4630 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4631 break;
4632 case eWNI_SME_JOIN_REQ:
4633 __lim_process_sme_join_req(pMac, pMsgBuf);
4634 break;
4635
4636 case eWNI_SME_REASSOC_REQ:
4637 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4638 break;
4639
4640 case eWNI_SME_DISASSOC_REQ:
4641 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4642 break;
4643
4644 case eWNI_SME_DISASSOC_CNF:
4645 case eWNI_SME_DEAUTH_CNF:
4646 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4647 break;
4648
4649 case eWNI_SME_DEAUTH_REQ:
4650 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4651 break;
4652
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304653 case eWNI_SME_SEND_DISASSOC_FRAME:
4654 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4655 break;
4656
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004657 case eWNI_SME_SETCONTEXT_REQ:
4658 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4659 break;
4660
4661 case eWNI_SME_STOP_BSS_REQ:
4662 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4663 break;
4664
4665 case eWNI_SME_ASSOC_CNF:
4666 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004667 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004668 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4669 pMsgBuf);
4670 break;
4671
4672 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004673 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004674 __lim_process_sme_addts_req(pMac, pMsgBuf);
4675 break;
4676
4677 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004678 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004679 __lim_process_sme_delts_req(pMac, pMsgBuf);
4680 break;
4681
4682 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004683 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004684 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4685 break;
4686
4687 case eWNI_SME_GET_STATISTICS_REQ:
4688 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4689 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4690 bufConsumed = false;
4691 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004692#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004693 case eWNI_SME_GET_TSM_STATS_REQ:
4694 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4695 bufConsumed = false;
4696 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004697#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004698 case eWNI_SME_GET_ASSOC_STAS_REQ:
4699 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4700 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304701 case eWNI_SME_SESSION_UPDATE_PARAM:
4702 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004703 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304704 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4705 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4706 bufConsumed = false;
4707 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004708 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4709 /* Update the beaconInterval */
4710 __lim_process_sme_change_bi(pMac, pMsgBuf);
4711 break;
4712
4713#ifdef QCA_HT_2040_COEX
4714 case eWNI_SME_SET_HT_2040_MODE:
4715 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4716 break;
4717#endif
4718
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004719 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4720 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4721 __lim_process_report_message(pMac, pMsg);
4722 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004723
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004724 case eWNI_SME_FT_PRE_AUTH_REQ:
4725 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4726 break;
4727 case eWNI_SME_FT_UPDATE_KEY:
4728 lim_process_ft_update_key(pMac, pMsgBuf);
4729 break;
4730
4731 case eWNI_SME_FT_AGGR_QOS_REQ:
4732 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4733 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004734
4735 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4736 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4737 break;
4738#ifdef FEATURE_WLAN_TDLS
4739 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4740 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4741 break;
4742 case eWNI_SME_TDLS_ADD_STA_REQ:
4743 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4744 break;
4745 case eWNI_SME_TDLS_DEL_STA_REQ:
4746 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4747 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004748#endif
4749 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4750 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4751 break;
4752
4753 case eWNI_SME_CHANNEL_CHANGE_REQ:
4754 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4755 break;
4756
4757 case eWNI_SME_START_BEACON_REQ:
4758 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4759 break;
4760
4761 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4762 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4763 break;
4764
4765 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4766 lim_process_update_add_ies(pMac, pMsgBuf);
4767 break;
4768
4769 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4770 lim_process_modify_add_ies(pMac, pMsgBuf);
4771 break;
4772 case eWNI_SME_SET_HW_MODE_REQ:
4773 lim_process_set_hw_mode(pMac, pMsgBuf);
4774 break;
4775 case eWNI_SME_NSS_UPDATE_REQ:
4776 lim_process_nss_update_request(pMac, pMsgBuf);
4777 break;
4778 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4779 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4780 break;
4781 case eWNI_SME_SET_IE_REQ:
4782 lim_process_set_ie_req(pMac, pMsgBuf);
4783 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304784 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4785 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
4786 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304787 case eWNI_SME_EXT_CHANGE_CHANNEL:
4788 lim_process_ext_change_channel(pMac, pMsgBuf);
4789 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08004790 case eWNI_SME_SET_ANTENNA_MODE_REQ:
4791 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
4792 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004793 case eWNI_SME_PDEV_SET_HT_VHT_IE:
4794 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07004795 break;
4796 case eWNI_SME_SET_VDEV_IES_PER_BAND:
4797 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
4798 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304799 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
4800 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
4801 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07004802 case eWNI_SME_UPDATE_CONFIG:
4803 lim_process_sme_update_config(pMac,
4804 (struct update_config *)pMsgBuf);
4805 break;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004806 case eWNI_SME_SET_ADDBA_ACCEPT:
4807 lim_process_sme_set_addba_accept(pMac,
4808 (struct sme_addba_accept *)pMsgBuf);
4809 break;
Arif Hussaineb8ba362018-03-07 19:15:13 -08004810 case eWNI_SME_UPDATE_EDCA_PROFILE:
4811 lim_process_sme_update_edca_params(pMac, pMsg->bodyval);
4812 break;
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07004813 case WNI_SME_UPDATE_MU_EDCA_PARAMS:
4814 lim_process_sme_update_mu_edca_params(pMac, pMsg->bodyval);
4815 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004816 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304817 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004818 pMsg->bodyptr = NULL;
4819 break;
4820 } /* switch (msgType) */
4821
4822 return bufConsumed;
4823} /*** end lim_process_sme_req_messages() ***/
4824
4825/**
4826 * lim_process_sme_start_beacon_req()
4827 *
4828 ***FUNCTION:
4829 * This function is called by limProcessMessageQueue(). This
4830 * function processes SME request messages from HDD or upper layer
4831 * application.
4832 *
4833 ***LOGIC:
4834 *
4835 ***ASSUMPTIONS:
4836 *
4837 ***NOTE:
4838 *
4839 * @param pMac Pointer to Global MAC structure
4840 * @param msgType Indicates the SME message type
4841 * @param *pMsgBuf A pointer to the SME message buffer
4842 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4843 * false - if pMsgBuf is not to be freed.
4844 */
4845static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
4846{
4847 tpSirStartBeaconIndication pBeaconStartInd;
4848 tpPESession psessionEntry;
4849 uint8_t sessionId; /* PE sessionID */
4850
4851 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004852 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004853 return;
4854 }
4855
4856 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
4857 psessionEntry = pe_find_session_by_bssid(pMac,
4858 pBeaconStartInd->bssid,
4859 &sessionId);
4860 if (psessionEntry == NULL) {
4861 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004862 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004863 return;
4864 }
4865
4866 if (pBeaconStartInd->beaconStartStatus == true) {
4867 /*
4868 * Currently this Indication comes from SAP
4869 * to start Beacon Tx on a DFS channel
4870 * since beaconing has to be done on DFS
4871 * channel only after CAC WAIT is completed.
4872 * On a DFS Channel LIM does not start beacon
4873 * Tx right after the WMA_ADD_BSS_RSP.
4874 */
4875 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05304876 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004877 FL("Start Beacon with ssid %s Ch %d"),
4878 psessionEntry->ssId.ssId,
4879 psessionEntry->currentOperChannel);
4880 lim_send_beacon_ind(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08004881 lim_enable_obss_detection_config(pMac, psessionEntry);
Arif Hussain05fb4872018-01-03 16:02:55 -08004882 lim_send_obss_color_collision_cfg(pMac, psessionEntry,
4883 OBSS_COLOR_COLLISION_DETECTION);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004884 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004885 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004886 return;
4887 }
4888}
4889
4890/**
4891 * lim_process_sme_channel_change_request() - process sme ch change req
4892 *
4893 * @mac_ctx: Pointer to Global MAC structure
4894 * @msg_buf: pointer to the SME message buffer
4895 *
4896 * This function is called to process SME_CHANNEL_CHANGE_REQ message
4897 *
4898 * Return: None
4899 */
4900static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
4901 uint32_t *msg_buf)
4902{
4903 tpSirChanChangeRequest ch_change_req;
4904 tpPESession session_entry;
4905 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07004906 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004907 uint32_t val = 0;
4908
4909 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004910 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004911 return;
4912 }
4913 ch_change_req = (tpSirChanChangeRequest)msg_buf;
4914
4915 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
4916 ch_change_req->targetChannel);
4917
4918 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
4919 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004920 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004921 return;
4922 }
4923
4924 session_entry = pe_find_session_by_bssid(mac_ctx,
4925 ch_change_req->bssid, &session_id);
4926 if (session_entry == NULL) {
4927 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004928 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004929 return;
4930 }
4931
Manjunathappa Prakash34fda792018-02-07 18:23:42 -08004932 if ((session_entry->currentOperChannel ==
4933 ch_change_req->targetChannel) &&
4934 (session_entry->ch_width == ch_change_req->ch_width)) {
4935 pe_err("Target channel and mode is same as current channel and mode channel %d and mode %d",
4936 session_entry->currentOperChannel, session_entry->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004937 return;
4938 }
4939
4940 if (LIM_IS_AP_ROLE(session_entry))
4941 session_entry->channelChangeReasonCode =
4942 LIM_SWITCH_CHANNEL_SAP_DFS;
4943 else
4944 session_entry->channelChangeReasonCode =
4945 LIM_SWITCH_CHANNEL_OPERATION;
4946
Bala Venkateshb39ed152017-12-26 19:35:27 +05304947 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d, nw_type %d, dot11mode %d",
4948 session_entry->currentOperChannel,
4949 ch_change_req->targetChannel,
4950 ch_change_req->ch_width,
4951 ch_change_req->nw_type,
4952 ch_change_req->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004953
4954 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004955 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004956 session_entry->ch_center_freq_seg0 =
4957 ch_change_req->center_freq_seg_0;
4958 session_entry->ch_center_freq_seg1 =
4959 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004960 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004961 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004962 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004963 session_entry->htRecommendedTxWidthSet =
4964 session_entry->htSupportedChannelWidthSet;
4965 session_entry->currentOperChannel =
4966 ch_change_req->targetChannel;
4967 session_entry->limRFBand =
4968 lim_get_rf_band(session_entry->currentOperChannel);
Vignesh Viswanathan153ae932018-04-11 14:24:13 +05304969
4970 /* Update the global beacon filter */
4971 lim_update_bcn_probe_filter(mac_ctx, session_entry);
4972
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004973 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08004974 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004975 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004976 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004977 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004978 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004979 }
4980
4981 session_entry->lim11hEnable = val;
4982 session_entry->dot11mode = ch_change_req->dot11mode;
Bala Venkateshb39ed152017-12-26 19:35:27 +05304983 session_entry->nwType = ch_change_req->nw_type;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304984 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004985 &ch_change_req->operational_rateset,
4986 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304987 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004988 &ch_change_req->extended_rateset,
4989 sizeof(session_entry->extRateSet));
4990 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
4991 session_entry->ch_center_freq_seg0,
4992 session_entry->ch_center_freq_seg1,
4993 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07004994 max_tx_pwr, session_entry->peSessionId,
4995 ch_change_req->cac_duration_ms,
4996 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004997}
4998
4999/******************************************************************************
5000* lim_start_bss_update_add_ie_buffer()
5001*
5002***FUNCTION:
5003* This function checks the src buffer and its length and then malloc for
5004* dst buffer update the same
5005*
5006***LOGIC:
5007*
5008***ASSUMPTIONS:
5009*
5010***NOTE:
5011*
5012* @param pMac Pointer to Global MAC structure
5013* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5014* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5015* @param *pSrcData_buff A pointer of uint8_t src buffer
5016* @param srcDataLen src buffer length
5017******************************************************************************/
5018
5019static void
5020lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5021 uint8_t **pDstData_buff,
5022 uint16_t *pDstDataLen,
5023 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5024{
5025
5026 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5027 *pDstDataLen = srcDataLen;
5028
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305029 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005030
5031 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005032 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005033 return;
5034 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305035 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005036 } else {
5037 *pDstData_buff = NULL;
5038 *pDstDataLen = 0;
5039 }
5040}
5041
5042/******************************************************************************
5043* lim_update_add_ie_buffer()
5044*
5045***FUNCTION:
5046* This function checks the src buffer and length if src buffer length more
5047* than dst buffer length then free the dst buffer and malloc for the new src
5048* length, and update the dst buffer and length. But if dst buffer is bigger
5049* than src buffer length then it just update the dst buffer and length
5050*
5051***LOGIC:
5052*
5053***ASSUMPTIONS:
5054*
5055***NOTE:
5056*
5057* @param pMac Pointer to Global MAC structure
5058* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5059* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5060* @param *pSrcData_buff A pointer of uint8_t src buffer
5061* @param srcDataLen src buffer length
5062******************************************************************************/
5063
5064static void
5065lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5066 uint8_t **pDstData_buff,
5067 uint16_t *pDstDataLen,
5068 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5069{
5070
5071 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005072 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005073 return;
5074 }
5075
5076 if (srcDataLen > *pDstDataLen) {
5077 *pDstDataLen = srcDataLen;
5078 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305079 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005080 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305081 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005082
5083 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005084 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005085 *pDstDataLen = 0;
5086 return;
5087 }
5088 }
5089
5090 /* copy the content of buffer into dst buffer
5091 */
5092 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305093 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005094
5095}
5096
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005097/**
5098 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5099 * @pMac : Pointer to Global MAC structure
5100 * @pDstData_buff : A pointer to pointer of dst buffer
5101 * @pDstDataLen : A pointer to pointer of dst buffer length
5102 * @pModifyIE : A pointer to tSirModifyIE
5103 *
5104 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5105 *
5106 * Return:
5107 * True or false depending upon whether IE is updated or not
5108 */
5109static bool
5110lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5111 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5112{
Hong Shi1553d692016-09-28 12:16:19 +08005113 int32_t oui_length;
5114 uint8_t *ibss_ie = NULL;
5115 uint8_t *vendor_ie;
5116#define MAC_VENDOR_OUI "\x00\x16\x32"
5117#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005118
5119 ibss_ie = pModifyIE->pIEBuffer;
5120 oui_length = pModifyIE->oui_length;
5121
5122 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005123 pe_err("Invalid set IBSS vendor IE command length %d",
5124 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005125 return false;
5126 }
5127
Hong Shi1553d692016-09-28 12:16:19 +08005128 /*
5129 * Why replace only beacon OUI data here:
5130 * 1. other ie (such as wpa) shall not be overwritten here.
5131 * 2. per spec, beacon oui ie might be set twice and original one
5132 * shall be updated.
5133 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005134 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005135 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5136 if (vendor_ie) {
5137 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5138 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5139 pModifyIE->ieBufferlength);
5140 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005141 uint16_t new_length;
5142 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005143
Naveen Rawat668dee32017-09-29 14:39:40 -07005144 /*
5145 * check for uint16 overflow before using sum of two numbers as
5146 * length of size to malloc
5147 */
5148 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5149 pe_err("U16 overflow due to %d + %d",
5150 pModifyIE->ieBufferlength, *pDstDataLen);
5151 return false;
5152 }
5153
5154 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5155 new_ptr = qdf_mem_malloc(new_length);
Hong Shi1553d692016-09-28 12:16:19 +08005156 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005157 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005158 return false;
5159 }
5160 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5161 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5162 pModifyIE->ieBufferlength);
5163 qdf_mem_free(*pDstData_buff);
5164 *pDstDataLen = new_length;
5165 *pDstData_buff = new_ptr;
5166 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005167 return true;
5168}
5169
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005170/*
5171* lim_process_modify_add_ies() - process modify additional IE req.
5172*
5173* @mac_ctx: Pointer to Global MAC structure
5174* @msg_buf: pointer to the SME message buffer
5175*
5176* This function update the PE buffers for additional IEs.
5177*
5178* Return: None
5179*/
5180static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5181 uint32_t *msg_buf)
5182{
5183 tpSirModifyIEsInd modify_add_ies;
5184 tpPESession session_entry;
5185 uint8_t session_id;
5186 bool ret = false;
5187 tSirAddIeParams *add_ie_params;
5188
5189 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005190 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005191 return;
5192 }
5193
5194 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5195 /* Incoming message has smeSession, use BSSID to find PE session */
5196 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005197 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005198
5199 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005200 pe_err("Session not found for given bssid"
5201 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005202 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005203 goto end;
5204 }
5205 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5206 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5207 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005208 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005209 modify_add_ies->modifyIE.pIEBuffer,
5210 modify_add_ies->modifyIE.ieBufferlength,
5211 modify_add_ies->modifyIE.ieID,
5212 modify_add_ies->modifyIE.ieIDLen,
5213 modify_add_ies->updateType);
5214 goto end;
5215 }
5216 add_ie_params = &session_entry->addIeParams;
5217 switch (modify_add_ies->updateType) {
5218 case eUPDATE_IE_PROBE_RESP:
5219 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005220 if (LIM_IS_IBSS_ROLE(session_entry)) {
5221 lim_update_ibss_prop_add_ies(mac_ctx,
5222 &add_ie_params->probeRespData_buff,
5223 &add_ie_params->probeRespDataLen,
5224 &modify_add_ies->modifyIE);
5225 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005226 break;
5227 case eUPDATE_IE_ASSOC_RESP:
5228 /* assoc resp IE */
5229 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305230 QDF_TRACE(QDF_MODULE_ID_PE,
5231 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005232 "assoc resp add ie not present %d"),
5233 add_ie_params->assocRespDataLen);
5234 }
5235 /* search through the buffer and modify the IE */
5236 break;
5237 case eUPDATE_IE_PROBE_BCN:
5238 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005239 if (LIM_IS_IBSS_ROLE(session_entry)) {
5240 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5241 &add_ie_params->probeRespBCNData_buff,
5242 &add_ie_params->probeRespBCNDataLen,
5243 &modify_add_ies->modifyIE);
5244 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005245 if (ret == true && modify_add_ies->modifyIE.notify) {
5246 lim_handle_param_update(mac_ctx,
5247 modify_add_ies->updateType);
5248 }
5249 break;
5250 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005251 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005252 modify_add_ies->updateType);
5253 break;
5254 }
5255end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305256 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005257 modify_add_ies->modifyIE.pIEBuffer = NULL;
5258}
5259
5260/*
5261* lim_process_update_add_ies() - process additional IE update req
5262*
5263* @mac_ctx: Pointer to Global MAC structure
5264* @msg_buf: pointer to the SME message buffer
5265*
5266* This function update the PE buffers for additional IEs.
5267*
5268* Return: None
5269*/
5270static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5271 uint32_t *msg_buf)
5272{
5273 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5274 uint8_t session_id;
5275 tpPESession session_entry;
5276 tSirAddIeParams *addn_ie;
5277 uint16_t new_length = 0;
5278 uint8_t *new_ptr = NULL;
5279 tSirUpdateIE *update_ie;
5280
5281 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005282 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005283 return;
5284 }
5285 update_ie = &update_add_ies->updateIE;
5286 /* incoming message has smeSession, use BSSID to find PE session */
5287 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005288 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005289
5290 if (NULL == session_entry) {
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05305291 pe_debug("Session not found for given bssid"
5292 MAC_ADDRESS_STR,
5293 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005294 goto end;
5295 }
5296 addn_ie = &session_entry->addIeParams;
5297 /* if len is 0, upper layer requested freeing of buffer */
5298 if (0 == update_ie->ieBufferlength) {
5299 switch (update_add_ies->updateType) {
5300 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305301 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005302 addn_ie->probeRespData_buff = NULL;
5303 addn_ie->probeRespDataLen = 0;
5304 break;
5305 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305306 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005307 addn_ie->assocRespData_buff = NULL;
5308 addn_ie->assocRespDataLen = 0;
5309 break;
5310 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305311 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005312 addn_ie->probeRespBCNData_buff = NULL;
5313 addn_ie->probeRespBCNDataLen = 0;
5314
5315 if (update_ie->notify)
5316 lim_handle_param_update(mac_ctx,
5317 update_add_ies->updateType);
5318 break;
5319 default:
5320 break;
5321 }
5322 return;
5323 }
5324 switch (update_add_ies->updateType) {
5325 case eUPDATE_IE_PROBE_RESP:
5326 if (update_ie->append) {
5327 /*
5328 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005329 * with combined length.
5330 * Multiple back to back append commands
5331 * can lead to a huge length.So, check
5332 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005333 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005334 if (addn_ie->probeRespDataLen >
5335 (USHRT_MAX - update_ie->ieBufferlength)) {
5336 pe_err("IE Length overflow, curr:%d, new:%d",
5337 addn_ie->probeRespDataLen,
5338 update_ie->ieBufferlength);
5339 goto end;
5340 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005341 new_length = update_ie->ieBufferlength +
5342 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305343 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005344 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005345 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005346 goto end;
5347 }
5348 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305349 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005350 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305351 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005352 update_ie->pAdditionIEBuffer,
5353 update_ie->ieBufferlength);
5354 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305355 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005356 /* adjust length accordingly */
5357 addn_ie->probeRespDataLen = new_length;
5358 /* save refernece of local buffer in PE session */
5359 addn_ie->probeRespData_buff = new_ptr;
5360 goto end;
5361 }
5362 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5363 &addn_ie->probeRespDataLen,
5364 update_ie->pAdditionIEBuffer,
5365 update_ie->ieBufferlength);
5366 break;
5367 case eUPDATE_IE_ASSOC_RESP:
5368 /* assoc resp IE */
5369 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5370 &addn_ie->assocRespDataLen,
5371 update_ie->pAdditionIEBuffer,
5372 update_ie->ieBufferlength);
5373 break;
5374 case eUPDATE_IE_PROBE_BCN:
5375 /* probe resp Bcn IE */
5376 lim_update_add_ie_buffer(mac_ctx,
5377 &addn_ie->probeRespBCNData_buff,
5378 &addn_ie->probeRespBCNDataLen,
5379 update_ie->pAdditionIEBuffer,
5380 update_ie->ieBufferlength);
5381 if (update_ie->notify)
5382 lim_handle_param_update(mac_ctx,
5383 update_add_ies->updateType);
5384 break;
5385 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005386 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005387 break;
5388 }
5389end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305390 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005391 update_ie->pAdditionIEBuffer = NULL;
5392}
5393
5394/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305395 * send_extended_chan_switch_action_frame()- function to send ECSA
5396 * action frame for each sta connected to SAP/GO and AP in case of
5397 * STA .
5398 * @mac_ctx: pointer to global mac structure
5399 * @new_channel: new channel to switch to.
5400 * @ch_bandwidth: BW of channel to calculate op_class
5401 * @session_entry: pe session
5402 *
5403 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5404 *
5405 * Return: void
5406 */
5407
5408static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5409 uint16_t new_channel, uint8_t ch_bandwidth,
5410 tpPESession session_entry)
5411{
5412 uint16_t op_class;
5413 uint8_t switch_mode = 0, i;
5414 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005415 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305416
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005417 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305418 mac_ctx->scan.countryCodeCurrent,
5419 new_channel,
5420 ch_bandwidth);
5421
5422 if (LIM_IS_AP_ROLE(session_entry) &&
5423 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005424 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305425
gaoleze2920bd2017-03-21 17:38:42 +08005426 switch_count = session_entry->gLimChannelSwitch.switchCount;
5427
Abhishek Singh518323d2015-10-19 17:42:01 +05305428 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005429 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305430 psta =
5431 session_entry->dph.dphHashTable.pDphNodeArray + i;
5432 if (psta && psta->added)
5433 lim_send_extended_chan_switch_action_frame(
5434 mac_ctx,
5435 psta->staAddr,
5436 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005437 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305438 }
5439 } else if (LIM_IS_STA_ROLE(session_entry)) {
5440 lim_send_extended_chan_switch_action_frame(mac_ctx,
5441 session_entry->bssId,
5442 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005443 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305444 }
5445
5446}
5447
gaolez76d2a162017-03-21 19:23:58 +08005448void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5449 uint16_t new_channel,
5450 uint8_t ch_bandwidth,
5451 tpPESession session_entry)
5452{
5453 uint16_t op_class;
5454 uint8_t switch_mode = 0, i;
5455 uint8_t switch_count;
5456 tpDphHashNode psta;
5457 tpDphHashNode dph_node_array_ptr;
5458
5459 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5460
5461 op_class = wlan_reg_dmn_get_opclass_from_channel(
5462 mac_ctx->scan.countryCodeCurrent,
5463 new_channel, ch_bandwidth);
5464
5465 if (LIM_IS_AP_ROLE(session_entry) &&
5466 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5467 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5468
5469 switch_count = session_entry->gLimChannelSwitch.switchCount;
5470
5471 if (LIM_IS_AP_ROLE(session_entry)) {
5472 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5473 psta = dph_node_array_ptr + i;
5474 if (!(psta && psta->added))
5475 continue;
5476 if (session_entry->lim_non_ecsa_cap_num == 0)
5477 lim_send_extended_chan_switch_action_frame
5478 (mac_ctx, psta->staAddr, switch_mode,
5479 op_class, new_channel, switch_count,
5480 session_entry);
5481 else
5482 lim_send_channel_switch_mgmt_frame
5483 (mac_ctx, psta->staAddr, switch_mode,
5484 new_channel, switch_count,
5485 session_entry);
5486 }
5487 } else if (LIM_IS_STA_ROLE(session_entry)) {
5488 lim_send_extended_chan_switch_action_frame
5489 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5490 new_channel, switch_count, session_entry);
5491 }
5492}
5493
5494/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005495 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5496 *
5497 * @mac_ctx: Pointer to Global MAC structure
5498 * @msg_buf: pointer to the SME message buffer
5499 *
5500 * This function processes SME request messages from HDD or upper layer
5501 * application.
5502 *
5503 * Return: None
5504 */
5505static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5506 uint32_t *msg_buf)
5507{
5508 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5509 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005510 uint8_t session_id;
5511 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005512 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005513
5514 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005515 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005516 return;
5517 }
5518
5519 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5520 session_entry = pe_find_session_by_bssid(mac_ctx,
5521 dfs_csa_ie_req->bssid, &session_id);
5522 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005523 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005524 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5525 return;
5526 }
5527
5528 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005529 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005530 GET_LIM_SYSTEM_ROLE(session_entry));
5531 return;
5532 }
5533
5534 /* target channel */
5535 session_entry->gLimChannelSwitch.primaryChannel =
5536 dfs_csa_ie_req->targetChannel;
5537
5538 /* Channel switch announcement needs to be included in beacon */
5539 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005540 session_entry->gLimChannelSwitch.switchCount =
5541 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005542 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005543 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305544 session_entry->gLimChannelSwitch.sec_ch_offset =
5545 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005546 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005547 session_entry->gLimChannelSwitch.switchMode =
5548 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005549
5550 /*
5551 * Validate if SAP is operating HT or VHT mode and set the Channel
5552 * Switch Wrapper element with the Wide Band Switch subelement.
5553 */
5554 if (true != session_entry->vhtCapability)
5555 goto skip_vht;
5556
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005557 /* Now encode the Wider Ch BW element depending on the ch width */
5558 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005559 switch (dfs_csa_ie_req->ch_params.ch_width) {
5560 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005561 /*
5562 * Wide channel BW sublement in channel wrapper element is not
5563 * required in case of 20 Mhz operation. Currently It is set
5564 * only set in case of 40/80 Mhz Operation.
5565 */
5566 session_entry->dfsIncludeChanWrapperIe = false;
5567 wider_bw_ch_switch->newChanWidth =
5568 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5569 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005570 case CH_WIDTH_40MHZ:
5571 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005572 wider_bw_ch_switch->newChanWidth =
5573 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5574 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005575 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005576 session_entry->dfsIncludeChanWrapperIe = true;
5577 wider_bw_ch_switch->newChanWidth =
5578 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5579 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005580 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005581 session_entry->dfsIncludeChanWrapperIe = true;
5582 wider_bw_ch_switch->newChanWidth =
5583 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5584 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005585 case CH_WIDTH_80P80MHZ:
5586 session_entry->dfsIncludeChanWrapperIe = true;
5587 wider_bw_ch_switch->newChanWidth =
5588 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005589 /*
5590 * This is not applicable for 20/40/80 Mhz.
5591 * Only used when we support 80+80 Mhz operation.
5592 * In case of 80+80 Mhz, this parameter indicates
5593 * center channel frequency index of 80 Mhz channel of
5594 * frequency segment 1.
5595 */
5596 wider_bw_ch_switch->newCenterChanFreq1 =
5597 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005598 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005599 default:
5600 session_entry->dfsIncludeChanWrapperIe = false;
5601 /*
5602 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5603 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5604 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005605 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005606 break;
5607 }
5608 /* Fetch the center channel based on the channel width */
5609 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005610 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005611skip_vht:
5612 /* Send CSA IE request from here */
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05305613 lim_send_dfs_chan_sw_ie_update(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305614
5615 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5616 ch_offset = BW80;
5617 else
5618 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5619
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005620 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305621 session_entry->gLimChannelSwitch.switchCount,
5622 session_entry->gLimChannelSwitch.primaryChannel,
5623 session_entry->gLimChannelSwitch.ch_width,
5624 session_entry->dfsIncludeChanWrapperIe,
5625 ch_offset);
5626
gaolez76d2a162017-03-21 19:23:58 +08005627 /* Send ECSA/CSA Action frame after updating the beacon */
5628 if (CHAN_HOP_ALL_BANDS_ENABLE)
5629 lim_send_chan_switch_action_frame(mac_ctx,
5630 session_entry->gLimChannelSwitch.primaryChannel,
5631 ch_offset, session_entry);
5632 else
5633 send_extended_chan_switch_action_frame(mac_ctx,
5634 session_entry->gLimChannelSwitch.primaryChannel,
5635 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005636}
5637
5638/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305639 * lim_process_ext_change_channel()- function to send ECSA
5640 * action frame for STA/CLI .
5641 * @mac_ctx: pointer to global mac structure
5642 * @msg: params from sme for new channel.
5643 *
5644 * This function is called to send ECSA frame for STA/CLI.
5645 *
5646 * Return: void
5647 */
5648
5649static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5650 uint32_t *msg)
5651{
5652 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5653 (struct sir_sme_ext_cng_chan_req *) msg;
5654 tpPESession session_entry = NULL;
5655
5656 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005657 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305658 return;
5659 }
5660 session_entry =
5661 pe_find_session_by_sme_session_id(mac_ctx,
5662 ext_chng_channel->session_id);
5663 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005664 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305665 ext_chng_channel->session_id);
5666 return;
5667 }
5668 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005669 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305670 return;
5671 }
5672 send_extended_chan_switch_action_frame(mac_ctx,
5673 ext_chng_channel->new_channel,
5674 0, session_entry);
5675}
5676
5677/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005678 * lim_process_nss_update_request() - process sme nss update req
5679 *
5680 * @mac_ctx: Pointer to Global MAC structure
5681 * @msg_buf: pointer to the SME message buffer
5682 *
5683 * This function processes SME request messages from HDD or upper layer
5684 * application.
5685 *
5686 * Return: None
5687 */
5688static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5689 uint32_t *msg_buf)
5690{
5691 struct sir_nss_update_request *nss_update_req_ptr;
5692 tpPESession session_entry = NULL;
5693
5694 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005695 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005696 return;
5697 }
5698
5699 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305700 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005701 nss_update_req_ptr->vdev_id);
5702 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005703 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005704 nss_update_req_ptr->vdev_id);
5705 return;
5706 }
5707
5708 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005709 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005710 GET_LIM_SYSTEM_ROLE(session_entry));
5711 return;
5712 }
5713
5714 /* populate nss field in the beacon */
5715 session_entry->gLimOperatingMode.present = 1;
5716 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05305717 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
5718
5719 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
5720 (session_entry->ch_width > CH_WIDTH_80MHZ))
5721 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
5722
5723 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
5724
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005725 /* Send nss update request from here */
5726 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005727 QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005728 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005729 return;
5730 }
5731
5732 lim_send_beacon_ind(mac_ctx, session_entry);
5733}
5734
5735/**
5736 * lim_process_set_ie_req() - process sme set IE request
5737 *
5738 * @mac_ctx: Pointer to Global MAC structure
5739 * @msg_buf: pointer to the SME message buffer
5740 *
5741 * This function processes SME request messages from HDD or upper layer
5742 * application.
5743 *
5744 * Return: None
5745 */
5746static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5747{
5748 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305749 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005750
5751 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005752 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005753 return;
5754 }
5755
5756 msg = (struct send_extcap_ie *)msg_buf;
5757 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305758 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005759 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005760
5761}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005762
5763#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Arif Hussain05fb4872018-01-03 16:02:55 -08005764
5765/**
5766 * obss_color_collision_process_color_disable() - Disable bss color
5767 * @mac_ctx: Pointer to Global MAC structure
5768 * @session: pointer to session
5769 *
5770 * This function will disbale bss color.
5771 *
5772 * Return: None
5773 */
5774static void obss_color_collision_process_color_disable(tpAniSirGlobal mac_ctx,
5775 tpPESession session)
5776{
5777 tUpdateBeaconParams beacon_params;
5778
5779 if (!session) {
5780 pe_err("Invalid session");
5781 return;
5782 }
5783
5784 if (session->valid && !LIM_IS_AP_ROLE(session)) {
5785 pe_err("Invalid SystemRole %d",
5786 GET_LIM_SYSTEM_ROLE(session));
5787 return;
5788 }
5789
5790 if (session->bss_color_changing == 1) {
5791 pe_warn("%d: color change in progress", session->smeSessionId);
5792 /* Continue color collision detection */
5793 lim_send_obss_color_collision_cfg(mac_ctx, session,
5794 OBSS_COLOR_COLLISION_DETECTION);
5795 return;
5796 }
5797
5798 if (session->he_op.bss_col_disabled == 1) {
5799 pe_warn("%d: bss color already disabled",
5800 session->smeSessionId);
5801 /* Continue free color detection */
5802 lim_send_obss_color_collision_cfg(mac_ctx, session,
5803 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5804 return;
5805 }
5806
5807 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5808 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5809 session->he_op.bss_col_disabled = 1;
Arif Hussain05fb4872018-01-03 16:02:55 -08005810 beacon_params.bss_color_disabled = 1;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005811 beacon_params.bss_color = session->he_op.bss_color;
Arif Hussain05fb4872018-01-03 16:02:55 -08005812
5813 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005814 QDF_STATUS_SUCCESS) {
Arif Hussain05fb4872018-01-03 16:02:55 -08005815 pe_err("Unable to set op mode IE in beacon");
5816 return;
5817 }
5818
5819 lim_send_beacon_params(mac_ctx, &beacon_params, session);
5820 lim_send_obss_color_collision_cfg(mac_ctx, session,
5821 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5822}
5823
5824/**
5825 * obss_color_collision_process_color_change() - Process bss color change
5826 * @mac_ctx: Pointer to Global MAC structure
5827 * @session: pointer to session
5828 * @obss_color_info: obss color collision/free slot indication info
5829 *
5830 * This function selects new color ib case of bss color collision.
5831 *
5832 * Return: None
5833 */
5834static void obss_color_collision_process_color_change(tpAniSirGlobal mac_ctx,
5835 tpPESession session,
5836 struct wmi_obss_color_collision_info *obss_color_info)
5837{
5838 int i, num_bss_color = 0;
5839 uint32_t bss_color_bitmap;
5840 uint8_t bss_color_index_array[MAX_BSS_COLOR_VALUE];
5841 uint32_t rand_byte = 0;
5842 struct sir_set_he_bss_color he_bss_color;
5843 bool is_color_collision = false;
5844
5845
5846 if (session->bss_color_changing == 1) {
5847 pe_err("%d: color change in progress", session->smeSessionId);
5848 return;
5849 }
5850
5851 if (!session->he_op.bss_col_disabled) {
5852 if (session->he_op.bss_color < 32)
5853 is_color_collision = (obss_color_info->
5854 obss_color_bitmap_bit0to31 >>
5855 session->he_op.bss_color) & 0x01;
5856 else
5857 is_color_collision = (obss_color_info->
5858 obss_color_bitmap_bit32to63 >>
5859 (session->he_op.bss_color -
Arif Hussain9e8c5612018-04-12 16:35:48 -07005860 32)) & 0x01;
Arif Hussain05fb4872018-01-03 16:02:55 -08005861 if (!is_color_collision) {
5862 pe_err("%d: color collision not found, curr_color: %d",
5863 session->smeSessionId,
5864 session->he_op.bss_color);
5865 return;
5866 }
5867 }
5868
5869 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit0to31;
5870
5871 /* Skip color zero */
5872 bss_color_bitmap = bss_color_bitmap >> 1;
5873 for (i = 0; (i < 31) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5874 if (!(bss_color_bitmap & 0x01)) {
5875 bss_color_index_array[num_bss_color] = i + 1;
5876 num_bss_color++;
5877 }
5878 bss_color_bitmap = bss_color_bitmap >> 1;
5879 }
5880
5881 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit32to63;
5882 for (i = 0; (i < 32) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5883 if (!(bss_color_bitmap & 0x01)) {
5884 bss_color_index_array[num_bss_color] = i + 32;
5885 num_bss_color++;
5886 }
5887 bss_color_bitmap = bss_color_bitmap >> 1;
5888 }
5889
5890 if (num_bss_color) {
5891 qdf_get_random_bytes((void *) &rand_byte, 1);
5892 i = (rand_byte + qdf_mc_timer_get_system_ticks()) %
5893 num_bss_color;
5894 pe_debug("New bss color = %d", bss_color_index_array[i]);
5895 he_bss_color.session_id = obss_color_info->vdev_id;
5896 he_bss_color.bss_color = bss_color_index_array[i];
5897 lim_process_set_he_bss_color(mac_ctx,
5898 (uint32_t *)&he_bss_color);
5899 } else {
5900 pe_err("Unable to find bss color from bitmasp");
5901 if (obss_color_info->evt_type ==
5902 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY &&
5903 session->obss_color_collision_dec_evt ==
5904 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
5905 /* In dot11BSSColorCollisionAPPeriod and
5906 * timer expired, time to disable bss color.
5907 */
5908 obss_color_collision_process_color_disable(mac_ctx,
5909 session);
5910 else
5911 /*
5912 * Enter dot11BSSColorCollisionAPPeriod period.
5913 */
5914 lim_send_obss_color_collision_cfg(mac_ctx, session,
5915 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY);
5916 }
5917}
5918
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005919void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5920{
5921 struct sir_set_he_bss_color *bss_color;
5922 tpPESession session_entry = NULL;
5923 tUpdateBeaconParams beacon_params;
5924
5925 if (!msg_buf) {
5926 pe_err("Buffer is Pointing to NULL");
5927 return;
5928 }
5929
5930 bss_color = (struct sir_set_he_bss_color *)msg_buf;
5931 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5932 bss_color->session_id);
5933 if (!session_entry) {
5934 pe_err("Session not found for given session_id %d",
5935 bss_color->session_id);
5936 return;
5937 }
5938
5939 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5940 pe_err("Invalid SystemRole %d",
5941 GET_LIM_SYSTEM_ROLE(session_entry));
5942 return;
5943 }
5944
5945 if (bss_color->bss_color == session_entry->he_op.bss_color) {
5946 pe_err("No change in BSS color, current BSS color %d",
5947 bss_color->bss_color);
5948 return;
5949 }
5950 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5951 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5952 session_entry->he_op.bss_col_disabled = 1;
5953 session_entry->he_bss_color_change.countdown =
5954 BSS_COLOR_SWITCH_COUNTDOWN;
5955 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005956 beacon_params.bss_color_disabled = 1;
5957 beacon_params.bss_color = session_entry->he_op.bss_color;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005958 session_entry->bss_color_changing = 1;
5959
5960 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005961 QDF_STATUS_SUCCESS) {
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005962 pe_err("Unable to set op mode IE in beacon");
5963 return;
5964 }
5965
5966 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
Arif Hussain05fb4872018-01-03 16:02:55 -08005967 lim_send_obss_color_collision_cfg(mac_ctx, session_entry,
5968 OBSS_COLOR_COLLISION_DETECTION_DISABLE);
5969}
5970
5971void lim_send_obss_color_collision_cfg(tpAniSirGlobal mac_ctx,
5972 tpPESession session,
5973 enum wmi_obss_color_collision_evt_type
5974 event_type)
5975{
5976 struct wmi_obss_color_collision_cfg_param *cfg_param;
5977 struct scheduler_msg msg = {0};
5978
5979 if (!session) {
5980 pe_err("Invalid session");
5981 return;
5982 }
5983
5984 if (!session->he_capable ||
5985 !session->is_session_obss_color_collision_det_enabled) {
5986 pe_debug("%d: obss color det not enabled, he_cap:%d, sup:%d:%d",
5987 session->smeSessionId, session->he_capable,
5988 session->is_session_obss_color_collision_det_enabled,
5989 mac_ctx->lim.global_obss_color_collision_det_offload);
5990 return;
5991 }
5992
5993 cfg_param = qdf_mem_malloc(sizeof(*cfg_param));
5994 if (!cfg_param) {
5995 pe_err("Failed to allocate memory");
5996 return;
5997 }
5998
5999 pe_debug("%d: sending event:%d", session->smeSessionId, event_type);
6000 qdf_mem_zero(cfg_param, sizeof(*cfg_param));
6001 cfg_param->vdev_id = session->smeSessionId;
6002 cfg_param->evt_type = event_type;
6003 if (LIM_IS_AP_ROLE(session))
6004 cfg_param->detection_period_ms =
6005 OBSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS;
6006 else
6007 cfg_param->detection_period_ms =
6008 OBSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS;
6009
6010 cfg_param->scan_period_ms = OBSS_COLOR_COLLISION_SCAN_PERIOD_MS;
6011 if (event_type == OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6012 cfg_param->free_slot_expiry_time_ms =
6013 OBSS_COLOR_COLLISION_FREE_SLOT_EXPIRY_MS;
6014
6015 msg.type = WMA_OBSS_COLOR_COLLISION_REQ;
6016 msg.bodyptr = cfg_param;
6017 msg.reserved = 0;
6018
6019 if (QDF_IS_STATUS_ERROR(scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
6020 pe_err("Failed to post WMA_OBSS_COLOR_COLLISION_REQ to WMA");
6021 qdf_mem_free(cfg_param);
6022 } else {
6023 session->obss_color_collision_dec_evt = event_type;
6024 }
6025}
6026
6027void lim_process_obss_color_collision_info(tpAniSirGlobal mac_ctx,
6028 uint32_t *msg_buf)
6029{
6030 struct wmi_obss_color_collision_info *obss_color_info;
6031 tpPESession session;
6032
6033 if (!msg_buf) {
6034 pe_err("Buffer is Pointing to NULL");
6035 return;
6036 }
6037
6038 obss_color_info = (struct wmi_obss_color_collision_info *)msg_buf;
6039 session = pe_find_session_by_sme_session_id(mac_ctx,
6040 obss_color_info->vdev_id);
6041 if (!session) {
6042 pe_err("Session not found for given session_id %d",
6043 obss_color_info->vdev_id);
6044 return;
6045 }
6046
6047 pe_debug("vdev_id:%d, evt:%d:%d, 0to31:0x%x, 32to63:0x%x, cap:%d:%d:%d",
6048 obss_color_info->vdev_id,
6049 obss_color_info->evt_type,
6050 session->obss_color_collision_dec_evt,
6051 obss_color_info->obss_color_bitmap_bit0to31,
6052 obss_color_info->obss_color_bitmap_bit32to63,
6053 session->he_capable,
6054 session->is_session_obss_color_collision_det_enabled,
6055 mac_ctx->lim.global_obss_color_collision_det_offload);
6056
6057 if (!session->he_capable ||
6058 !session->is_session_obss_color_collision_det_enabled) {
6059 return;
6060 }
6061
6062 switch (obss_color_info->evt_type) {
6063 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
6064 pe_err("%d: FW disabled obss color det. he_cap:%d, sup:%d:%d",
6065 session->smeSessionId, session->he_capable,
6066 session->is_session_obss_color_collision_det_enabled,
6067 mac_ctx->lim.global_obss_color_collision_det_offload);
6068 session->is_session_obss_color_collision_det_enabled = false;
6069 return;
6070 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
6071 case OBSS_COLOR_COLLISION_DETECTION:
6072 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
6073 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6074 pe_debug("Invalid System Role %d",
6075 GET_LIM_SYSTEM_ROLE(session));
6076 return;
6077 }
6078
6079 if (session->obss_color_collision_dec_evt !=
6080 obss_color_info->evt_type) {
6081 pe_debug("%d: Wrong event: %d, skiping",
6082 obss_color_info->vdev_id,
6083 obss_color_info->evt_type);
6084 return;
6085 }
6086 obss_color_collision_process_color_change(mac_ctx, session,
6087 obss_color_info);
6088 break;
6089 default:
6090 pe_err("%d: Invalid event type %d",
6091 obss_color_info->vdev_id, obss_color_info->evt_type);
6092 return;
6093 }
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006094}
6095#endif