blob: b9f76b05a6204f720bf301345fa9184f7ea2c996 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Jingxiang Ge4168a232018-01-03 18:47:15 +08002 * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
19/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020 * This file lim_process_sme_req_messages.cc contains the code
21 * for processing SME request messages.
22 * Author: Chandra Modumudi
23 * Date: 02/11/02
24 * History:-
25 * Date Modified by Modification Information
26 * --------------------------------------------------------------------
27 *
28 */
29
30#include "cds_api.h"
31#include "wni_api.h"
32#include "wni_cfg.h"
33#include "cfg_api.h"
34#include "sir_api.h"
35#include "sch_api.h"
36#include "utils_api.h"
37#include "lim_types.h"
38#include "lim_utils.h"
39#include "lim_assoc_utils.h"
40#include "lim_security_utils.h"
41#include "lim_ser_des_utils.h"
42#include "lim_sme_req_utils.h"
43#include "lim_ibss_peer_mgmt.h"
44#include "lim_admit_control.h"
45#include "dph_hash_table.h"
46#include "lim_send_messages.h"
47#include "lim_api.h"
48#include "wmm_apsd.h"
49#include "sir_mac_prot_def.h"
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -080050#include "rrm_api.h"
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070051#include "nan_datapath.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080052
53#include "sap_api.h"
54
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080055
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080056#include <lim_ft.h>
Naveen Rawat3b6068c2016-04-14 19:01:06 -070057#include "cds_regdomain.h"
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053058#include "lim_process_fils.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070059#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060
61/*
62 * This overhead is time for sending NOA start to host in case of GO/sending
63 * NULL data & receiving ACK in case of P2P Client and starting actual scanning
64 * with init scan req/rsp plus in case of concurrency, taking care of sending
65 * null data and receiving ACK to/from AP/Also SetChannel with calibration
66 * is taking around 7ms .
67 */
68#define SCAN_MESSAGING_OVERHEAD 20 /* in msecs */
69#define JOIN_NOA_DURATION 2000 /* in msecs */
70#define OEM_DATA_NOA_DURATION 60 /* in msecs */
71#define DEFAULT_PASSIVE_MAX_CHANNEL_TIME 110 /* in msecs */
72
73#define CONV_MS_TO_US 1024 /* conversion factor from ms to us */
74
Paul Zhangd2315472017-02-22 10:02:50 +080075#define BEACON_INTERVAL_THRESHOLD 50 /* in msecs */
76#define STA_BURST_SCAN_DURATION 120 /* in msecs */
77
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080078/* SME REQ processing function templates */
79static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080080static bool __lim_process_sme_start_bss_req(tpAniSirGlobal,
81 struct scheduler_msg *pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080082static void __lim_process_sme_join_req(tpAniSirGlobal, uint32_t *);
83static void __lim_process_sme_reassoc_req(tpAniSirGlobal, uint32_t *);
84static void __lim_process_sme_disassoc_req(tpAniSirGlobal, uint32_t *);
85static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal, uint32_t *);
86static void __lim_process_sme_deauth_req(tpAniSirGlobal, uint32_t *);
87static void __lim_process_sme_set_context_req(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080088static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal,
89 struct scheduler_msg *pMsg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053090static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
91 uint32_t *msg_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080092static void lim_process_sme_channel_change_request(tpAniSirGlobal pMac,
93 uint32_t *pMsg);
94static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg);
95static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal pMac, uint32_t *pMsg);
96static void lim_process_nss_update_request(tpAniSirGlobal pMac, uint32_t *pMsg);
97static void lim_process_set_ie_req(tpAniSirGlobal pMac, uint32_t *pMsg);
98
99static void lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
100 uint8_t **pDstData_buff,
101 uint16_t *pDstDataLen,
102 uint8_t *pSrcData_buff,
103 uint16_t srcDataLen);
104
105static void lim_update_add_ie_buffer(tpAniSirGlobal pMac,
106 uint8_t **pDstData_buff,
107 uint16_t *pDstDataLen,
108 uint8_t *pSrcData_buff, uint16_t srcDataLen);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800109static bool lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac,
110 uint8_t **pDstData_buff,
111 uint16_t *pDstDataLen,
112 tSirModifyIE *pModifyIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800113static void lim_process_modify_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
114
115static void lim_process_update_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
116
Abhishek Singh518323d2015-10-19 17:42:01 +0530117static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
118 uint32_t *msg);
119
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800120/**
121 * lim_process_set_hw_mode() - Send set HW mode command to WMA
122 * @mac: Globacl MAC pointer
123 * @msg: Message containing the hw mode index
124 *
125 * Send the set HW mode command to WMA
126 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530127 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800128 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530129static QDF_STATUS lim_process_set_hw_mode(tpAniSirGlobal mac, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800130{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530131 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700132 struct scheduler_msg message = {0};
Tushnim Bhattacharyya66348bd2017-03-09 15:02:10 -0800133 struct policy_mgr_hw_mode *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800134 uint32_t len;
135 struct s_sir_set_hw_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700136 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800137 struct sir_set_hw_mode_resp *param;
138
139 buf = (struct s_sir_set_hw_mode *) msg;
140 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700141 pe_err("Set HW mode param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800142 /* To free the active command list */
143 goto fail;
144 }
145
146 len = sizeof(*req_msg);
147
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530148 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700150 pe_err("qdf_mem_malloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800151 /* Free the active command list
152 * Probably the malloc is going to fail there as well?!
153 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530154 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800155 }
156
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800157 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530158 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159 /* Other parameters are not needed for WMA */
160
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800161 message.bodyptr = req_msg;
162 message.type = SIR_HAL_PDEV_SET_HW_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800163
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700164 pe_debug("Posting SIR_HAL_SOC_SET_HW_MOD to WMA");
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800165 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530166 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700167 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530169 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170 goto fail;
171 }
172 return status;
173fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530174 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800175 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700176 pe_err("HW mode resp failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530177 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800178 }
179 param->status = SET_HW_MODE_STATUS_ECANCELED;
180 param->cfgd_hw_mode_index = 0;
181 param->num_vdev_mac_entries = 0;
182 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
183 resp_msg.bodyptr = param;
184 resp_msg.bodyval = 0;
185 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530186 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800187}
188
189/**
190 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
191 * @mac: Global MAC pointer
192 * @msg: Message containing the dual mac config parameter
193 *
194 * Send the set dual mac config command to WMA
195 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530196 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800197 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530198static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800199 uint32_t *msg)
200{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530201 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700202 struct scheduler_msg message = {0};
Srinivas Girigowdaeb6ecf32018-02-15 17:04:22 -0800203 struct policy_mgr_dual_mac_config *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800204 uint32_t len;
205 struct sir_set_dual_mac_cfg *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700206 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800207 struct sir_dual_mac_config_resp *param;
208
209 buf = (struct sir_set_dual_mac_cfg *) msg;
210 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700211 pe_err("Set Dual mac config is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800212 /* To free the active command list */
213 goto fail;
214 }
215
216 len = sizeof(*req_msg);
217
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530218 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800219 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700220 pe_err("qdf_mem_malloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800221 /* Free the active command list
222 * Probably the malloc is going to fail there as well?!
223 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530224 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225 }
226
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 req_msg->scan_config = buf->set_dual_mac.scan_config;
228 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
229 /* Other parameters are not needed for WMA */
230
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800231 message.bodyptr = req_msg;
232 message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800233
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700234 pe_debug("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235 req_msg->scan_config, req_msg->fw_mode_config);
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800236 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530237 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700238 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800239 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530240 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800241 goto fail;
242 }
243 return status;
244fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530245 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800246 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700247 pe_err("Dual mac config resp failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530248 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249 }
250 param->status = SET_HW_MODE_STATUS_ECANCELED;
251 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
252 resp_msg.bodyptr = param;
253 resp_msg.bodyval = 0;
254 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530255 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800256}
257
258/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800259 * lim_process_set_antenna_mode_req() - Set antenna mode command
260 * to WMA
261 * @mac: Global MAC pointer
262 * @msg: Message containing the antenna mode parameter
263 *
264 * Send the set antenna mode command to WMA
265 *
266 * Return: QDF_STATUS_SUCCESS if message posting is successful
267 */
268static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
269 uint32_t *msg)
270{
271 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700272 struct scheduler_msg message = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800273 struct sir_antenna_mode_param *req_msg;
274 struct sir_set_antenna_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700275 struct scheduler_msg resp_msg = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800276 struct sir_antenna_mode_resp *param;
277
278 buf = (struct sir_set_antenna_mode *) msg;
279 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700280 pe_err("Set antenna mode is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800281 /* To free the active command list */
282 goto fail;
283 }
284
285 req_msg = qdf_mem_malloc(sizeof(*req_msg));
286 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700287 pe_err("qdf_mem_malloc failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800288 return QDF_STATUS_E_NOMEM;
289 }
290
291 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
292 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
293
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800294 message.bodyptr = req_msg;
295 message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800296
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700297 pe_debug("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800298 req_msg->num_rx_chains,
299 req_msg->num_tx_chains);
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800300 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800301 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700302 pe_err("scheduler_post_msg failed!(err=%d)",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800303 status);
304 qdf_mem_free(req_msg);
305 goto fail;
306 }
307 return status;
308fail:
309 param = qdf_mem_malloc(sizeof(*param));
310 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700311 pe_err("antenna mode resp failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800312 return QDF_STATUS_E_NOMEM;
313 }
314 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
315 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
316 resp_msg.bodyptr = param;
317 resp_msg.bodyval = 0;
318 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
319 return QDF_STATUS_SUCCESS;
320}
321
322/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800323 * __lim_is_sme_assoc_cnf_valid()
324 *
325 ***FUNCTION:
326 * This function is called by __lim_process_sme_assoc_cnf_new() upon
327 * receiving SME_ASSOC_CNF.
328 *
329 ***LOGIC:
330 * Message validity checks are performed in this function
331 *
332 ***ASSUMPTIONS:
333 *
334 ***NOTE:
335 *
336 * @param pMeasReq Pointer to Received ASSOC_CNF message
337 * @return true When received SME_ASSOC_CNF is formatted
338 * correctly
339 * false otherwise
340 */
341
342static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
343{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530344 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800345 return false;
346 else
347 return true;
348} /*** end __lim_is_sme_assoc_cnf_valid() ***/
349
350/**
351 * __lim_get_sme_join_req_size_for_alloc()
352 *
353 ***FUNCTION:
354 * This function is called in various places to get IE length
355 * from tSirBssDescription structure
356 * number being scanned.
357 *
358 ***PARAMS:
359 *
360 ***LOGIC:
361 *
362 ***ASSUMPTIONS:
363 * NA
364 *
365 ***NOTE:
366 * NA
367 *
368 * @param pBssDescr
369 * @return Total IE length
370 */
371
372static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
373{
374 uint16_t len = 0;
375
376 if (!pBuf)
377 return len;
378
379 pBuf += sizeof(uint16_t);
380 len = lim_get_u16(pBuf);
Arif Hussainc9651922017-04-16 14:08:23 -0700381 return len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800382}
383
384/**
385 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
386 * @pMac: Global MAC context
387 * @pMsg: Pointer to message posted from SME to LIM.
388 *
389 * Has role only if 11h is enabled. Not used on STA side.
390 * Defers the message if SME is in learn state and brings
391 * the LIM back to normal mode.
392 *
393 * Return: true - If defered false - Otherwise
394 */
395
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800396static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac,
397 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800398{
399 if (lim_is_system_in_scan_state(pMac)) {
400 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700401 pe_err("Could not defer Msg: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800402 return false;
403 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700404 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800405 pMsg->type);
406 return true;
407 }
408 return false;
409}
410
411/**
412 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
413 * @mac_ctx: Pointer to Global MAC structure
414 * @message: Pointer to message posted from SME to LIM.
415 *
416 * Has role only if 11h is enabled. Not used on STA side.
417 * Defers the message if radar is detected.
418 *
419 * Return: true, if defered otherwise return false.
420 */
421static bool
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800422__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx,
423 struct scheduler_msg *message)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800424{
425 /*
426 * fRadarDetCurOperChan will be set only if we
427 * detect radar in current operating channel and
428 * System Role == AP ROLE
429 *
430 * TODO: Need to take care radar detection.
431 *
432 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
433 */
434 if (0) {
435 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700436 pe_err("Could not defer Msg: %d", message->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437 return false;
438 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700439 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800440 message->type);
441 return true;
442 }
443 return false;
444}
445
446/**
447 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
448 * @pMac: Global MAC context
449 * @pMsgBuf: Message from WMA
450 *
451 * handles the notification from HDD. PE just forwards this message to HAL.
452 *
453 * Return: true-Posting to HAL failed, so PE will consume the buffer.
454 * false-Posting to HAL successful, so HAL will consume the buffer.
455 */
456
457static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
458{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700459 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800460 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
461
462 msg.type = WMA_SYS_READY_IND;
463 msg.reserved = 0;
464 msg.bodyptr = pMsgBuf;
465 msg.bodyval = 0;
466
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700467 if (ANI_DRIVER_TYPE(pMac) != QDF_DRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800468 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +0530469 pe_register_mgmt_rx_frm_callback(pMac);
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700470 pe_register_callbacks_with_wma(pMac, ready_req);
Sandeep Puligilla1426d612017-04-12 18:22:06 -0700471 pMac->lim.sme_msg_callback = ready_req->sme_msg_cb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800472 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700473
474 pe_debug("sending WMA_SYS_READY_IND msg to HAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800475 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
476
477 if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700478 pe_err("wma_post_ctrl_msg failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800479 return true;
480 }
481 return false;
482}
483
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800484/**
485 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
486 *@mac_ctx: Pointer to Global MAC structure
487 *@session: A pointer to session entry
488 *@sme_start_bss_req: Start BSS Request from upper layers.
489 *
490 * This function is used to configure the start bss parameters
491 * in to the session.
492 *
493 * Return: None.
494 */
495static void
496lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
497 tpSirSmeStartBssReq sme_start_bss_req)
498{
499 session->limSystemRole = eLIM_AP_ROLE;
500 session->privacy = sme_start_bss_req->privacy;
501 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
502 session->authType = sme_start_bss_req->authType;
503 /* Store the DTIM period */
504 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
505 /* Enable/disable UAPSD */
506 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530507 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800508 session->proxyProbeRspEn = 0;
509 } else {
510 /*
511 * To detect PBC overlap in SAP WPS mode,
512 * Host handles Probe Requests.
513 */
514 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
515 session->proxyProbeRspEn = 1;
516 else
517 session->proxyProbeRspEn = 0;
518 }
519 session->ssidHidden = sme_start_bss_req->ssidHidden;
520 session->wps_state = sme_start_bss_req->wps_state;
521 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530522 session->vendor_vht_sap =
523 sme_start_bss_req->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800524 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
525 &session->shortSlotTimeSupported);
526 session->isCoalesingInIBSSAllowed =
527 sme_start_bss_req->isCoalesingInIBSSAllowed;
528
Jiachao Wu712d4fd2017-08-23 16:52:34 +0800529 session->beacon_tx_rate = sme_start_bss_req->beacon_tx_rate;
530
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800531}
532
533/**
Arif Hussain53cf5692018-04-05 16:35:54 -0700534 * lim_clear_he_tx_stbc() - Clear tx stbc for a given session
535 * @session: Session
536 *
537 * Clear tx stbc for a given session
538 *
539 * Return: None
540 */
541#ifdef WLAN_FEATURE_11AX
542static void lim_clear_he_tx_stbc(tpPESession session)
543{
544 if (session) {
545 session->he_config.tx_stbc_lt_80mhz = 0;
546 session->he_config.tx_stbc_gt_80mhz = 0;
547 }
548}
549#else
550static void lim_clear_he_tx_stbc(tpPESession session)
551{}
552#endif
553
554/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800555 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
556 *@mac_ctx: Pointer to Global MAC structure
557 *@msg_buf: A pointer to the SME message buffer
558 *
559 * This function is called to process SME_START_BSS_REQ message
560 * from HDD or upper layer application.
561 *
562 * Return: None
563 */
564static void
565__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
566{
567 uint16_t size;
568 uint32_t val = 0;
569 tSirRetStatus ret_status;
570 tSirMacChanNum channel_number;
571 tLimMlmStartReq *mlm_start_req = NULL;
572 tpSirSmeStartBssReq sme_start_bss_req = NULL;
573 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
574 /* Flag Used in case of IBSS to Auto generate BSSID. */
575 uint32_t auto_gen_bssid = false;
576 uint8_t session_id;
577 tpPESession session = NULL;
Krunal Sonib37bb352016-12-20 14:12:21 -0800578 uint8_t sme_session_id = 0xFF;
579 uint16_t sme_transaction_id = 0xFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800580 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700581 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800582 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
583
584/* FEATURE_WLAN_DIAG_SUPPORT */
585#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
586 /*
587 * Since the session is not created yet, sending NULL.
588 * The response should have the correct state.
589 */
590 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
591 NULL, 0, 0);
592#endif /* FEATURE_WLAN_DIAG_SUPPORT */
593
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700594 pe_debug("Received START_BSS_REQ");
Krunal Sonib37bb352016-12-20 14:12:21 -0800595 size = sizeof(tSirSmeStartBssReq);
596 sme_start_bss_req = qdf_mem_malloc(size);
597 if (NULL == sme_start_bss_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700598 pe_err("Allocate Memory fail for LimStartBssReq");
Krunal Sonib37bb352016-12-20 14:12:21 -0800599 /* Send failure response to host */
600 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
601 goto free;
602 }
603 qdf_mem_copy(sme_start_bss_req, msg_buf, sizeof(tSirSmeStartBssReq));
604 sme_session_id = sme_start_bss_req->sessionId;
605 sme_transaction_id = sme_start_bss_req->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800606
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800607 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
608 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800609 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
610 sme_start_bss_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700611 pe_warn("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800612 ret_code = eSIR_SME_INVALID_PARAMETERS;
613 goto free;
614 }
615
616 /*
617 * This is the place where PE is going to create a session.
618 * If session is not existed, then create a new session
619 */
620 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800621 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800622 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700623 pe_warn("Session Already exists for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800624 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
625 session = NULL;
626 goto free;
627 } else {
628 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800629 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800630 &session_id, mac_ctx->lim.maxStation,
631 sme_start_bss_req->bssType);
632 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700633 pe_warn("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800634 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
635 goto free;
636 }
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +0530637
638 /* Update the beacon/probe filter in mac_ctx */
639 lim_set_bcn_probe_filter(mac_ctx, session,
640 &sme_start_bss_req->ssId,
641 sme_start_bss_req->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800642 }
643
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700644 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
645 /* Probe resp add ie */
646 lim_start_bss_update_add_ie_buffer(mac_ctx,
647 &session->addIeParams.probeRespData_buff,
648 &session->addIeParams.probeRespDataLen,
649 sme_start_bss_req->addIeParams.
650 probeRespData_buff,
651 sme_start_bss_req->addIeParams.
652 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800653
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700654 /* Probe Beacon add ie */
655 lim_start_bss_update_add_ie_buffer(mac_ctx,
656 &session->addIeParams.probeRespBCNData_buff,
657 &session->addIeParams.probeRespBCNDataLen,
658 sme_start_bss_req->addIeParams.
659 probeRespBCNData_buff,
660 sme_start_bss_req->addIeParams.
661 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800662
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700663 /* Assoc resp IE */
664 lim_start_bss_update_add_ie_buffer(mac_ctx,
665 &session->addIeParams.assocRespData_buff,
666 &session->addIeParams.assocRespDataLen,
667 sme_start_bss_req->addIeParams.
668 assocRespData_buff,
669 sme_start_bss_req->addIeParams.
670 assocRespDataLen);
671 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800672 /* Store the session related params in newly created session */
673 session->pLimStartBssReq = sme_start_bss_req;
674
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800675 /* Store SME session Id in sessionTable */
676 session->smeSessionId = sme_start_bss_req->sessionId;
677
678 session->transactionId = sme_start_bss_req->transactionId;
679
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530680 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800681 &(sme_start_bss_req->htConfig),
682 sizeof(session->htConfig));
683
Sandeep Puligilla98917432016-06-10 13:50:28 -0700684 qdf_mem_copy(&(session->vht_config),
685 &(sme_start_bss_req->vht_config),
686 sizeof(session->vht_config));
687
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800688 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800689 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800690
691 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530692 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800693 (uint8_t *) &sme_start_bss_req->ssId,
694 (sme_start_bss_req->ssId.length + 1));
695
696 session->bssType = sme_start_bss_req->bssType;
697
698 session->nwType = sme_start_bss_req->nwType;
699
700 session->beaconParams.beaconInterval =
701 sme_start_bss_req->beaconInterval;
702
703 /* Store the channel number in session Table */
704 session->currentOperChannel =
705 sme_start_bss_req->channelId;
706
707 /* Store Persona */
708 session->pePersona = sme_start_bss_req->bssPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +0530709 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800710 FL("PE PERSONA=%d"), session->pePersona);
711
712 /* Update the phymode */
713 session->gLimPhyMode = sme_start_bss_req->nwType;
714
715 session->maxTxPower =
716 cfg_get_regulatory_max_transmit_power(mac_ctx,
717 session->currentOperChannel);
718 /* Store the dot 11 mode in to the session Table */
719 session->dot11mode = sme_start_bss_req->dot11mode;
720#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
721 session->cc_switch_mode =
722 sme_start_bss_req->cc_switch_mode;
723#endif
724 session->htCapability =
725 IS_DOT11_MODE_HT(session->dot11mode);
726 session->vhtCapability =
727 IS_DOT11_MODE_VHT(session->dot11mode);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800728
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700729 pe_debug("HT[%d], VHT[%d]",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800730 session->htCapability, session->vhtCapability);
731
732 if (IS_DOT11_MODE_HE(session->dot11mode)) {
733 lim_update_session_he_capable(mac_ctx, session);
734 lim_copy_bss_he_cap(session, sme_start_bss_req);
735 }
736
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800737 session->txLdpcIniFeatureEnabled =
738 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739#ifdef WLAN_FEATURE_11W
740 session->limRmfEnabled =
741 sme_start_bss_req->pmfCapable ? 1 : 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700742 pe_debug("Session RMF enabled: %d", session->limRmfEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743#endif
744
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530745 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800746 (void *)&sme_start_bss_req->operationalRateSet,
747 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530748 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800749 (void *)&sme_start_bss_req->extendedRateSet,
750 sizeof(tSirMacRateSet));
751
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700752 if (IS_5G_CH(session->currentOperChannel))
753 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
754 else
755 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
756
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800757 switch (sme_start_bss_req->bssType) {
758 case eSIR_INFRA_AP_MODE:
759 lim_configure_ap_start_bss_session(mac_ctx, session,
760 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700761 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700762 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700763 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700764 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800765 break;
766 case eSIR_IBSS_MODE:
767 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
768 lim_get_short_slot_from_phy_mode(mac_ctx, session,
769 session->gLimPhyMode,
770 &session->shortSlotTimeSupported);
771
772 /*
773 * initialize to "OPEN".
774 * will be updated upon key installation
775 */
776 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700777 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800778
779 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700780 case eSIR_NDI_MODE:
781 session->limSystemRole = eLIM_NDI_ROLE;
782 break;
783
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800784
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800785 /*
786 * There is one more mode called auto mode.
787 * which is used no where
788 */
789
790 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
791
792 default:
793 /* not used anywhere...used in scan function */
794 break;
795 }
796
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700797 pe_debug("persona - %d, nss - %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700798 session->pePersona, session->vdev_nss);
799 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800800 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700801 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800802 * parsed (Re)Assoc request structure
803 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700804 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800805 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530806 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700807 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800808 if (NULL == session->parsedAssocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700809 pe_warn("AllocateMemory() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800810 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
811 goto free;
812 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813 }
814
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700815 if (!sme_start_bss_req->channelId &&
816 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700817 pe_err("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800818 ret_code = eSIR_SME_INVALID_PARAMETERS;
819 goto free;
820 }
821 channel_number = sme_start_bss_req->channelId;
822#ifdef QCA_HT_2040_COEX
823 if (sme_start_bss_req->obssEnabled)
824 session->htSupportedChannelWidthSet =
825 session->htCapability;
826 else
827#endif
828 session->htSupportedChannelWidthSet =
829 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
830 session->htSecondaryChannelOffset =
831 sme_start_bss_req->sec_ch_offset;
832 session->htRecommendedTxWidthSet =
833 (session->htSecondaryChannelOffset) ? 1 : 0;
Abhishek Singh4294f802017-08-10 16:37:07 +0530834 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835 FL("cbMode %u"), sme_start_bss_req->cbMode);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800836 if (lim_is_session_he_capable(session) ||
837 session->vhtCapability || session->htCapability) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838 chanwidth = sme_start_bss_req->vht_channel_width;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700839 pe_debug("vht_channel_width %u htSupportedChannelWidthSet %d",
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800840 sme_start_bss_req->vht_channel_width,
841 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800842 session->ch_width = chanwidth;
843 if (session->htSupportedChannelWidthSet) {
844 session->ch_center_freq_seg0 =
845 sme_start_bss_req->center_freq_seg0;
846 session->ch_center_freq_seg1 =
847 sme_start_bss_req->center_freq_seg1;
848 } else {
849 session->ch_center_freq_seg0 = 0;
850 session->ch_center_freq_seg1 = 0;
851 }
852 }
853
854 if (session->vhtCapability &&
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800855 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800856 session->nss = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700857 pe_debug("nss set to [%d]", session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700859 pe_debug("vht su tx bformer %d",
Krunal Soni53993f72016-07-08 18:20:03 -0700860 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800861
862 /* Delete pre-auth list if any */
863 lim_delete_pre_auth_list(mac_ctx);
864
Krunal Soni53993f72016-07-08 18:20:03 -0700865 if (session->nss == 1) {
866 session->vht_config.su_beam_former = 0;
867 session->vht_config.tx_stbc = 0;
868 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530869 session->htConfig.ht_tx_stbc = 0;
Arif Hussain53cf5692018-04-05 16:35:54 -0700870 lim_clear_he_tx_stbc(session);
Krunal Soni53993f72016-07-08 18:20:03 -0700871 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800872 /*
873 * keep the RSN/WPA IE information in PE Session Entry
874 * later will be using this to check when received (Re)Assoc req
875 */
876 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
877 &sme_start_bss_req->rsnIE, session);
878
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700879 if (LIM_IS_AP_ROLE(session) ||
880 LIM_IS_IBSS_ROLE(session) ||
881 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800882 session->gLimProtectionControl =
883 sme_start_bss_req->protEnabled;
884 /*
885 * each byte will have the following info
886 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
887 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
888 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530889 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800890 (void *)&sme_start_bss_req->ht_capab,
891 sizeof(uint16_t));
892 /* Initialize WPS PBC session link list */
893 session->pAPWPSPBCSession = NULL;
894 }
895 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530896 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800897 if (NULL == mlm_start_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700898 pe_err("Allocate Memory failed for mlmStartReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800899 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
900 goto free;
901 }
902
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800903 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530904 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800905 (uint8_t *) &sme_start_bss_req->ssId,
906 sme_start_bss_req->ssId.length + 1);
907 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
908 mlm_start_req->obssProtEnabled =
909 sme_start_bss_req->obssProtEnabled;
910
911 mlm_start_req->bssType = session->bssType;
912
913 /* Fill PE session Id from the session Table */
914 mlm_start_req->sessionId = session->peSessionId;
915
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700916 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
917 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800918 /*
919 * Copy the BSSId from sessionTable to
920 * mlmStartReq struct
921 */
922 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
923 } else {
924 /* ibss mode */
925 mac_ctx->lim.gLimIbssCoalescingHappened = false;
926
927 ret_status = wlan_cfg_get_int(mac_ctx,
928 WNI_CFG_IBSS_AUTO_BSSID,
929 &auto_gen_bssid);
930 if (ret_status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700931 pe_err("Get Auto Gen BSSID fail,Status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800932 ret_status);
Abhishek Singh4294f802017-08-10 16:37:07 +0530933 ret_code = eSIR_LOGE_EXCEPTION;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800934 goto free;
935 }
936
937 if (!auto_gen_bssid) {
938 /*
939 * We're not auto generating BSSID.
940 * Instead, get it from session entry
941 */
942 sir_copy_mac_addr(mlm_start_req->bssId,
943 session->bssId);
944 /*
945 * Start IBSS group BSSID
946 * Auto Generating BSSID.
947 */
948 auto_gen_bssid = ((mlm_start_req->bssId[0] &
949 0x01) ? true : false);
950 }
951
952 if (auto_gen_bssid) {
953 /*
954 * if BSSID is not any uc id.
955 * then use locally generated BSSID.
956 * Autogenerate the BSSID
957 */
958 lim_get_random_bssid(mac_ctx,
959 mlm_start_req->bssId);
960 mlm_start_req->bssId[0] = 0x02;
961
962 /*
963 * Copy randomly generated BSSID
964 * to the session Table
965 */
966 sir_copy_mac_addr(session->bssId,
967 mlm_start_req->bssId);
968 }
969 }
970 /* store the channel num in mlmstart req structure */
971 mlm_start_req->channelNumber = session->currentOperChannel;
972 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
973 mlm_start_req->beaconPeriod =
974 session->beaconParams.beaconInterval;
Arif Hussain671a1902017-03-17 09:08:32 -0700975 mlm_start_req->cac_duration_ms =
976 sme_start_bss_req->cac_duration_ms;
977 mlm_start_req->dfs_regdomain =
978 sme_start_bss_req->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800979 if (LIM_IS_AP_ROLE(session)) {
980 mlm_start_req->dtimPeriod = session->dtimPeriod;
981 mlm_start_req->wps_state = session->wps_state;
982
983 } else {
984 if (wlan_cfg_get_int(mac_ctx,
985 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700986 pe_err("could not retrieve DTIM Period");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800987 mlm_start_req->dtimPeriod = (uint8_t) val;
988 }
989
990 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
991 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700992 pe_err("could not retrieve Beacon interval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800993 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
994
995 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
996 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700997 pe_err("could not retrieve CFPMaxDuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800998 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
999
1000 /*
1001 * this may not be needed anymore now,
1002 * as rateSet is now included in the
1003 * session entry and MLM has session context.
1004 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301005 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001006 (void *)&session->rateSet,
1007 sizeof(tSirMacRateSet));
1008
1009 /* Now populate the 11n related parameters */
1010 mlm_start_req->nwType = session->nwType;
1011 mlm_start_req->htCapable = session->htCapability;
1012
1013 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1014 /* Unused */
1015 mlm_start_req->dualCTSProtection =
1016 mac_ctx->lim.gHTDualCTSProtection;
1017 mlm_start_req->txChannelWidthSet =
1018 session->htRecommendedTxWidthSet;
1019
1020 session->limRFBand = lim_get_rf_band(channel_number);
1021
1022 /* Initialize 11h Enable Flag */
1023 session->lim11hEnable = 0;
gaolez76d2a162017-03-21 19:23:58 +08001024 if (mlm_start_req->bssType != eSIR_IBSS_MODE &&
1025 (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001026 BAND_5G == session->limRFBand)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001027 if (wlan_cfg_get_int(mac_ctx,
1028 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001029 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001030 else
1031 session->lim11hEnable = val;
1032
1033 if (session->lim11hEnable &&
1034 (eSIR_INFRA_AP_MODE ==
1035 mlm_start_req->bssType)) {
1036 cfg_get_wmi_dfs_master_param =
1037 wlan_cfg_get_int(mac_ctx,
1038 WNI_CFG_DFS_MASTER_ENABLED,
1039 &val);
1040 session->lim11hEnable = val;
1041 }
1042 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1043 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001044 pe_err("Get Fail, CFG DFS ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001045 }
1046
1047 if (!session->lim11hEnable) {
1048 if (cfg_set_int(mac_ctx,
1049 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1050 eSIR_SUCCESS)
1051 /*
1052 * Failed to set the CFG param
1053 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1054 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001055 pe_err("Set LOCAL_POWER_CONSTRAINT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001056 }
1057
Jiachao Wu712d4fd2017-08-23 16:52:34 +08001058 mlm_start_req->beacon_tx_rate = session->beacon_tx_rate;
1059
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001060 session->limPrevSmeState = session->limSmeState;
1061 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1062 MTRACE(mac_trace
1063 (mac_ctx, TRACE_CODE_SME_STATE,
1064 session->peSessionId,
1065 session->limSmeState));
1066
1067 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1068 (uint32_t *) mlm_start_req);
1069 return;
1070 } else {
1071
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001072 pe_err("Received unexpected START_BSS_REQ, in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001073 mac_ctx->lim.gLimSmeState);
1074 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001075 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001076 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1077
1078free:
1079 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001080 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001081 session->pLimStartBssReq = NULL;
1082 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001083 if (NULL != sme_start_bss_req)
1084 qdf_mem_free(sme_start_bss_req);
1085 if (NULL != mlm_start_req)
1086 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001087 if (NULL != session) {
1088 pe_delete_session(mac_ctx, session);
1089 session = NULL;
1090 }
1091 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1092 session, sme_session_id, sme_transaction_id);
1093}
1094
1095/**
1096 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1097 *
1098 * @pMac: Global MAC context
1099 * @pMsg: Message pointer
1100 *
1101 * Wrapper for the function __lim_handle_sme_start_bss_request
1102 * This message will be defered until softmac come out of
1103 * scan mode or if we have detected radar on the current
1104 * operating channel.
1105 *
1106 * return true - If we consumed the buffer
1107 * false - If have defered the message.
1108 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001109static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1110 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001111{
1112 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1113 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1114 /**
1115 * If message defered, buffer is not consumed yet.
1116 * So return false
1117 */
1118 return false;
1119 }
1120
1121 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1122 return true;
1123}
1124
1125/**
1126 * lim_get_random_bssid()
1127 *
1128 * FUNCTION:This function is called to process generate the random number for bssid
1129 * This function is called to process SME_SCAN_REQ message
1130 * from HDD or upper layer application.
1131 *
1132 * LOGIC:
1133 *
1134 * ASSUMPTIONS:
1135 *
1136 * NOTE:
1137 * 1. geneartes the unique random number for bssid in ibss
1138 *
1139 * @param pMac Pointer to Global MAC structure
1140 * @param *data Pointer to bssid buffer
1141 * @return None
1142 */
1143void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1144{
1145 uint32_t random[2];
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001146
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001147 random[0] = tx_time_get();
1148 random[0] |= (random[0] << 15);
1149 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301150 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001151}
1152
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001153/**
1154 * __lim_process_clear_dfs_channel_list()
1155 *
1156 ***FUNCTION:
Jeff Johnsonc00ae5b2018-05-06 16:06:35 -07001157 ***Clear DFS channel list when country is changed/acquired.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001158 .*This message is sent from SME.
1159 *
1160 ***LOGIC:
1161 *
1162 ***ASSUMPTIONS:
1163 *
1164 ***NOTE:
1165 *
1166 * @param pMac Pointer to Global MAC structure
1167 * @param *pMsgBuf A pointer to the SME message buffer
1168 * @return None
1169 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001170static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1171 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001172{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301173 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001174}
1175
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301176#ifdef WLAN_FEATURE_SAE
1177
1178/**
1179 * lim_update_sae_config()- This API update SAE session info to csr config
1180 * from join request.
1181 * @session: PE session
1182 * @sme_join_req: pointer to join request
1183 *
1184 * Return: None
1185 */
1186static void lim_update_sae_config(tpPESession session,
1187 tpSirSmeJoinReq sme_join_req)
1188{
1189 session->sae_pmk_cached = sme_join_req->sae_pmk_cached;
1190
1191 pe_debug("pmk_cached %d for BSSID=" MAC_ADDRESS_STR,
1192 session->sae_pmk_cached,
1193 MAC_ADDR_ARRAY(sme_join_req->bssDescription.bssId));
1194}
1195#else
1196static inline void lim_update_sae_config(tpPESession session,
1197 tpSirSmeJoinReq sme_join_req)
1198{}
1199#endif
1200
1201
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001202/**
1203 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1204 * @mac_ctx: Pointer to Global MAC structure
1205 * @msg_buf: A pointer to the SME message buffer
1206 *
1207 * This function is called to process SME_JOIN_REQ message
1208 * from HDD or upper layer application.
1209 *
1210 * Return: None
1211 */
1212static void
1213__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1214{
1215 tpSirSmeJoinReq sme_join_req = NULL;
1216 tLimMlmJoinReq *mlm_join_req;
1217 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1218 uint32_t val = 0;
1219 uint16_t n_size;
1220 uint8_t session_id;
1221 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301222 uint8_t sme_session_id = 0;
1223 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001224 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001225 uint16_t ie_len;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001226 const uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001227 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001228 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229
Arif Hussain995fcaf2016-07-18 11:28:22 -07001230 if (!mac_ctx || !msg_buf) {
1231 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1232 FL("JOIN REQ with invalid data"));
1233 return;
1234 }
1235
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001236/* FEATURE_WLAN_DIAG_SUPPORT */
1237#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1238 /*
1239 * Not sending any session, since it is not created yet.
1240 * The response whould have correct state.
1241 */
1242 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1243#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1244
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001245 /*
1246 * Expect Join request in idle state.
1247 * Reassociate request is expected in link established state.
1248 */
1249
1250 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1251 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1252 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1253 msg_buf);
1254
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301255 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001256 if (NULL == sme_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001257 pe_err("AllocateMemory failed for sme_join_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001258 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301259 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001260 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301261 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001262 n_size);
1263
1264 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1265 /* Received invalid eWNI_SME_JOIN_REQ */
1266 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001267 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001268 sme_join_req->sessionId);
1269 ret_code = eSIR_SME_INVALID_PARAMETERS;
1270 goto end;
1271 }
1272
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001273 /*
1274 * Update the capability here itself as this is used in
1275 * lim_extract_ap_capability() below. If not updated issues
1276 * like not honoring power constraint on 1st association after
1277 * driver loading might occur.
1278 */
1279 lim_update_rrm_capability(mac_ctx, sme_join_req);
1280
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001281 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001282 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001283 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001284 &session_id);
1285
1286 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001287 pe_err("Session(%d) Already exists for BSSID: "
1288 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001289 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001290 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001291 session->limSmeState);
1292
1293 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1294 session->smeSessionId == sme_join_req->sessionId) {
1295 /*
1296 * Received eWNI_SME_JOIN_REQ for same
1297 * BSS as currently associated.
1298 * Log the event and send success
1299 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001300 pe_warn("SessionId: %d", session_id);
1301 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001302 /* Send Join success response to host */
1303 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1304 session = NULL;
1305 goto end;
1306 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001307 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 ret_code = eSIR_SME_REFUSED;
1309 session = NULL;
1310 goto end;
1311 }
1312 } else {
1313 /*
1314 * Session Entry does not exist for given BSSId
1315 * Try to Create a new session
1316 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001317 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001318 &session_id, mac_ctx->lim.maxStation,
1319 eSIR_INFRASTRUCTURE_MODE);
1320 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001321 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001322 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1323 goto end;
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301324 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001325 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001326 session_id);
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301327 }
1328
1329 /* Update the beacon/probe filter in mac_ctx */
1330 lim_set_bcn_probe_filter(mac_ctx, session,
1331 &sme_join_req->ssId,
1332 bss_desc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001333 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001334 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001335
1336 /*
1337 * Store Session related parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001338 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339
1340 /* store the smejoin req handle in session table */
1341 session->pLimJoinReq = sme_join_req;
1342
1343 /* Store SME session Id in sessionTable */
1344 session->smeSessionId = sme_join_req->sessionId;
1345
1346 /* Store SME transaction Id in session Table */
1347 session->transactionId = sme_join_req->transactionId;
1348
1349 /* Store beaconInterval */
1350 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001351 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001352
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301353 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001354 sizeof(session->htConfig));
1355
Sandeep Puligilla98917432016-06-10 13:50:28 -07001356 qdf_mem_copy(&(session->vht_config),
1357 &(sme_join_req->vht_config),
1358 sizeof(session->vht_config));
1359
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001360 /* Copying of bssId is already done, while creating session */
1361 sir_copy_mac_addr(session->selfMacAddr,
1362 sme_join_req->selfMacAddr);
1363 session->bssType = sme_join_req->bsstype;
1364
1365 session->statypeForBss = STA_ENTRY_PEER;
1366 session->limWmeEnabled = sme_join_req->isWMEenabled;
1367 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301368 session->wps_registration = sme_join_req->wps_registration;
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001369 session->he_with_wep_tkip = sme_join_req->he_with_wep_tkip;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001370
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301371 session->enable_bcast_probe_rsp =
1372 sme_join_req->enable_bcast_probe_rsp;
1373
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001374 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001375 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001376 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1377
Naveen Rawat08db88f2017-09-08 15:07:48 -07001378 vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001379 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001380 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381
1382 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001383 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001384 session->isCiscoVendorAP = true;
1385 } else {
1386 session->isCiscoVendorAP = false;
1387 }
1388
1389 /* Copy the dot 11 mode in to the session table */
1390
1391 session->dot11mode = sme_join_req->dot11mode;
1392#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1393 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1394#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001395 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001396 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1397 session->enableHtSmps = sme_join_req->enableHtSmps;
1398 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001399 session->send_smps_action =
1400 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001401 /*
1402 * By default supported NSS 1x1 is set to true
1403 * and later on updated while determining session
1404 * supported rates which is the intersection of
1405 * self and peer rates
1406 */
1407 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301408 /*Store Persona */
1409 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001410 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 -08001411 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001412 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001413 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301414 session->supported_nss_1x1,
1415 session->pePersona,
1416 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001417
1418 /*Store Persona */
1419 session->pePersona = sme_join_req->staPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +05301420 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301421 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d force_24ghz_in_ht20 %d"),
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001422 session->pePersona, sme_join_req->cbMode,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301423 session->nwType, session->dot11mode,
1424 sme_join_req->force_24ghz_in_ht20);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001425
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001426 /* Copy The channel Id to the session Table */
1427 session->currentOperChannel = bss_desc->channelId;
1428 if (IS_5G_CH(session->currentOperChannel))
1429 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001430 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001431 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1432 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1433 session->vdev_nss = vdev_type_nss->p2p_cli;
1434 else
1435 session->vdev_nss = vdev_type_nss->sta;
1436 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001437 session->vhtCapability =
1438 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001439 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301440 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001441 session->vht_config.su_beam_formee =
1442 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001443 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001444 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001445 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001446 session->enableVhtpAid =
1447 sme_join_req->enableVhtpAid;
1448 session->enableVhtGid =
1449 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001450 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001451 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001452 }
Krunal Soni53993f72016-07-08 18:20:03 -07001453
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001454 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301455 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001456 session->vht_config.su_beam_formee,
1457 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001458 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001459 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001460 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001461 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301462 session->force_24ghz_in_ht20 =
1463 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001464 /* cbMode is already merged value of peer and self -
1465 * done by csr in csr_get_cb_mode_from_ies */
1466 session->htSupportedChannelWidthSet =
1467 (sme_join_req->cbMode) ? 1 : 0;
1468 session->htRecommendedTxWidthSet =
1469 session->htSupportedChannelWidthSet;
1470 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1471
1472 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1473 session->ch_center_freq_seg0 =
1474 session->currentOperChannel - 2;
1475 session->ch_width = CH_WIDTH_40MHZ;
1476 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1477 sme_join_req->cbMode) {
1478 session->ch_center_freq_seg0 =
1479 session->currentOperChannel + 2;
1480 session->ch_width = CH_WIDTH_40MHZ;
1481 } else {
1482 session->ch_center_freq_seg0 = 0;
1483 session->ch_width = CH_WIDTH_20MHZ;
1484 }
1485
Naveen Rawataeca1b92017-10-16 16:55:31 -07001486 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1487 lim_update_session_he_capable(mac_ctx, session);
1488 lim_copy_join_req_he_cap(session, sme_join_req);
1489 }
1490
1491
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001492 /* Record if management frames need to be protected */
1493#ifdef WLAN_FEATURE_11W
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +05301494 if ((eSIR_ED_AES_128_CMAC ==
1495 sme_join_req->MgmtEncryptionType) ||
1496 (eSIR_ED_AES_GMAC_128 == sme_join_req->MgmtEncryptionType) ||
1497 (eSIR_ED_AES_GMAC_256 == sme_join_req->MgmtEncryptionType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001498 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001499 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001500 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001501#endif
1502
1503#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001504 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001505#endif
1506
1507 /* Copy the SSID from smejoinreq to session entry */
1508 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301509 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001510 session->ssId.length);
1511
1512 /*
1513 * Determin 11r or ESE connection based on input from SME
1514 * which inturn is dependent on the profile the user wants
1515 * to connect to, So input is coming from supplicant
1516 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001517 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001518#ifdef FEATURE_WLAN_ESE
1519 session->isESEconnection = sme_join_req->isESEconnection;
1520#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521 session->isFastTransitionEnabled =
1522 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001523
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001524 session->isFastRoamIniFeatureEnabled =
1525 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526 session->txLdpcIniFeatureEnabled =
1527 sme_join_req->txLdpcIniFeatureEnabled;
1528
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301529 lim_update_fils_config(session, sme_join_req);
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301530 lim_update_sae_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1532 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001533 } else {
1534 /*
1535 * Throw an error and return and make
1536 * sure to delete the session.
1537 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001538 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001539 session->bssType);
1540 ret_code = eSIR_SME_INVALID_PARAMETERS;
1541 goto end;
1542 }
1543
1544 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301545 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001546 &sme_join_req->addIEScan, sizeof(tSirAddie));
1547
1548 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301549 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001550 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1551
1552 val = sizeof(tLimMlmJoinReq) +
1553 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301554 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001555 if (NULL == mlm_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001556 pe_err("AllocateMemory failed for mlmJoinReq");
Nitesh Shah0102cac2016-07-13 14:38:30 +05301557 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1558 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001559 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001560
1561 /* PE SessionId is stored as a part of JoinReq */
1562 mlm_join_req->sessionId = session->peSessionId;
1563
1564 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1565 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1566 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001567 pe_err("couldn't retrieve JoinFailureTimer value"
1568 " setting to default value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001569 mlm_join_req->joinFailureTimeout =
1570 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1571 }
1572
1573 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301574 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001575 (void *)&sme_join_req->operationalRateSet,
1576 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301577 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001578 (void *)&sme_join_req->extendedRateSet,
1579 sizeof(tSirMacRateSet));
1580 /*
1581 * this may not be needed anymore now, as rateSet is now
1582 * included in the session entry and MLM has session context.
1583 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301584 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001585 (void *)&session->rateSet,
1586 sizeof(tSirMacRateSet));
1587
1588 session->encryptType = sme_join_req->UCEncryptionType;
1589
1590 mlm_join_req->bssDescription.length =
1591 session->pLimJoinReq->bssDescription.length;
1592
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301593 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001594 (uint8_t *)
1595 &session->pLimJoinReq->bssDescription.bssId,
1596 session->pLimJoinReq->bssDescription.length + 2);
1597
1598 session->limCurrentBssCaps =
1599 session->pLimJoinReq->bssDescription.capabilityInfo;
1600
1601 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1602 session->currentOperChannel);
1603 local_power_constraint = reg_max;
1604
1605 lim_extract_ap_capability(mac_ctx,
1606 (uint8_t *)
1607 session->pLimJoinReq->bssDescription.ieFields,
1608 lim_get_ielen_from_bss_description(
1609 &session->pLimJoinReq->bssDescription),
1610 &session->limCurrentBssQosCaps,
1611 &session->limCurrentBssPropCap,
1612 &session->gLimCurrentBssUapsd,
1613 &local_power_constraint, session);
1614
Krunal Soni53993f72016-07-08 18:20:03 -07001615 /*
1616 * Once the AP capabilities are available then set the
1617 * beam forming capabilities accordingly.
1618 */
1619 if (session->nss == 1) {
1620 session->vht_config.su_beam_former = 0;
1621 session->vht_config.tx_stbc = 0;
1622 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301623 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001624 }
1625
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001626 session->maxTxPower = lim_get_max_tx_power(reg_max,
1627 local_power_constraint,
1628 mac_ctx->roam.configParam.nTxPowerCap);
Abhinav Kumard528d192018-03-09 17:31:12 +05301629 session->def_max_tx_pwr = session->maxTxPower;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301630
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001631 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301632 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001633
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301634 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1635 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1636 pe_debug("Update MaxTxPower in join Req to %d",
1637 sme_join_req->powerCap.maxTxPower);
1638 }
1639
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001640 if (session->gLimCurrentBssUapsd) {
1641 session->gUapsdPerAcBitmask =
1642 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001643 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001644 session->gUapsdPerAcBitmask);
1645
1646 /* resetting the dynamic uapsd mask */
1647 session->gUapsdPerAcDeliveryEnableMask = 0;
1648 session->gUapsdPerAcTriggerEnableMask = 0;
1649 }
1650
1651 session->limRFBand =
1652 lim_get_rf_band(session->currentOperChannel);
1653
1654 /* Initialize 11h Enable Flag */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001655 if (BAND_5G == session->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001656 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1657 &val) != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001658 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001659 session->lim11hEnable =
1660 WNI_CFG_11H_ENABLED_STADEF;
1661 } else {
1662 session->lim11hEnable = val;
1663 }
1664 } else {
1665 session->lim11hEnable = 0;
1666 }
1667
1668 /*
1669 * To care of the scenario when STA transitions from
1670 * IBSS to Infrastructure mode.
1671 */
1672 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1673
1674 session->limPrevSmeState = session->limSmeState;
1675 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1676 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1677 session->peSessionId,
1678 session->limSmeState));
1679
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001680 /* Indicate whether spectrum management is enabled */
1681 session->spectrumMgtEnabled =
1682 sme_join_req->spectrumMgtIndicator;
1683
1684 /* Enable the spectrum management if this is a DFS channel */
1685 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001686 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001687 session->currentOperChannel))
1688 session->spectrumMgtEnabled = true;
1689
1690 session->isOSENConnection = sme_join_req->isOSENConnection;
1691
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692 /* Issue LIM_MLM_JOIN_REQ to MLM */
1693 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1694 (uint32_t *) mlm_join_req);
1695 return;
1696
1697 } else {
1698 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001699 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001700 mac_ctx->lim.gLimSmeState);
1701 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1702 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1703 session = NULL;
1704 goto end;
1705 }
1706
1707end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301708 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1709 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001710
1711 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301712 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001713 sme_join_req = NULL;
1714 if (NULL != session)
1715 session->pLimJoinReq = NULL;
1716 }
1717 if (ret_code != eSIR_SME_SUCCESS) {
1718 if (NULL != session) {
1719 pe_delete_session(mac_ctx, session);
1720 session = NULL;
1721 }
1722 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001723 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001724 sme_session_id, ret_code);
1725 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1726 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1727 sme_transaction_id);
1728}
1729
Amar Singhala297bfa2015-10-15 15:07:29 -07001730uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001731 uint8_t iniTxPower)
1732{
1733 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301734 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001735
Anurag Chouhan6d760662016-02-20 16:05:43 +05301736 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001737 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1738 maxTxPower = txPower;
1739 else if (txPower < MIN_TX_PWR_CAP)
1740 maxTxPower = MIN_TX_PWR_CAP;
1741 else
1742 maxTxPower = MAX_TX_PWR_CAP;
1743
1744 return maxTxPower;
1745}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001746
1747/**
1748 * __lim_process_sme_reassoc_req() - process reassoc req
1749 *
1750 * @mac_ctx: Pointer to Global MAC structure
1751 * @msg_buf: pointer to the SME message buffer
1752 *
1753 * This function is called to process SME_REASSOC_REQ message
1754 * from HDD or upper layer application.
1755 *
1756 * Return: None
1757 */
1758
1759static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
1760 uint32_t *msg_buf)
1761{
1762 uint16_t caps;
1763 uint32_t val;
1764 tpSirSmeJoinReq reassoc_req = NULL;
1765 tLimMlmReassocReq *mlm_reassoc_req;
1766 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1767 tpPESession session_entry = NULL;
1768 uint8_t session_id;
1769 uint8_t sme_session_id;
1770 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001771 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001772 uint32_t tele_bcn_en = 0;
1773 uint16_t size;
1774
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001775 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301776 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001777 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001778 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001779
1780 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1781 goto end;
1782 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301783 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784
1785 if (!lim_is_sme_join_req_valid(mac_ctx,
1786 (tpSirSmeJoinReq)reassoc_req)) {
1787 /*
1788 * Received invalid eWNI_SME_REASSOC_REQ
1789 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001790 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001791
1792 ret_code = eSIR_SME_INVALID_PARAMETERS;
1793 goto end;
1794 }
1795
1796 session_entry = pe_find_session_by_bssid(mac_ctx,
1797 reassoc_req->bssDescription.bssId,
1798 &session_id);
1799 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001800 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001801 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
1802 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001803 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001804 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
1805 &sme_session_id, &transaction_id);
1806 session_entry =
1807 pe_find_session_by_sme_session_id(mac_ctx,
1808 sme_session_id);
1809 if (session_entry != NULL)
1810 lim_handle_sme_join_result(mac_ctx,
1811 eSIR_SME_INVALID_PARAMETERS,
1812 eSIR_MAC_UNSPEC_FAILURE_STATUS,
1813 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001814 goto end;
1815 }
1816#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
1817 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
1818 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
1819#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1820 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
1821
1822 /* Store the reassoc handle in the session Table */
1823 session_entry->pLimReAssocReq = reassoc_req;
1824
1825 session_entry->dot11mode = reassoc_req->dot11mode;
1826 session_entry->vhtCapability =
1827 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001828
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301829 if (session_entry->vhtCapability) {
1830 if (session_entry->pePersona == QDF_STA_MODE) {
1831 session_entry->vht_config.su_beam_formee =
1832 reassoc_req->vht_config.su_beam_formee;
1833 } else {
1834 reassoc_req->vht_config.su_beam_formee = 0;
1835 }
1836 session_entry->enableVhtpAid =
1837 reassoc_req->enableVhtpAid;
1838 session_entry->enableVhtGid =
1839 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001840 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301841 }
1842
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001843 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301844 session_entry->vhtCapability,
1845 session_entry->vht_config.su_beam_formee,
1846 session_entry->vht_config.su_beam_former);
1847
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001848 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
1849 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001850 session_entry->send_smps_action =
1851 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001852 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001853 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001854 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001855 session_entry->send_smps_action,
1856 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001857 /*
1858 * Reassociate request is expected
1859 * in link established state only.
1860 */
1861
1862 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001863 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
1864 /*
1865 * May be from 11r FT pre-auth. So lets check it
1866 * before we bail out
1867 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001868 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001869 session_entry->peSessionId);
1870
1871 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301872 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001873 session_entry->limReAssocbssId,
1874 6)) {
1875 lim_print_mac_addr(mac_ctx,
1876 reassoc_req->bssDescription.
1877 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001878 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001879 ret_code = eSIR_SME_INVALID_PARAMETERS;
1880 goto end;
1881 }
1882
1883 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
1884 session_entry);
1885 return;
1886 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001887 /*
1888 * Should not have received eWNI_SME_REASSOC_REQ
1889 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001890 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891 session_entry->limSmeState);
1892 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
1893
1894 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1895 goto end;
1896 }
1897
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301898 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001899 session_entry->pLimReAssocReq->bssDescription.bssId,
1900 sizeof(tSirMacAddr));
1901
1902 session_entry->limReassocChannelId =
1903 session_entry->pLimReAssocReq->bssDescription.channelId;
1904
1905 session_entry->reAssocHtSupportedChannelWidthSet =
1906 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
1907 session_entry->reAssocHtRecommendedTxWidthSet =
1908 session_entry->reAssocHtSupportedChannelWidthSet;
1909 session_entry->reAssocHtSecondaryChannelOffset =
1910 session_entry->pLimReAssocReq->cbMode;
1911
1912 session_entry->limReassocBssCaps =
1913 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
1914 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1915 session_entry->currentOperChannel);
1916 local_pwr_constraint = reg_max;
1917
1918 lim_extract_ap_capability(mac_ctx,
1919 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
1920 lim_get_ielen_from_bss_description(
1921 &session_entry->pLimReAssocReq->bssDescription),
1922 &session_entry->limReassocBssQosCaps,
1923 &session_entry->limReassocBssPropCap,
1924 &session_entry->gLimCurrentBssUapsd,
1925 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05301926 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001927 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301928 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001929 /* Copy the SSID from session entry to local variable */
1930 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301931 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001932 reassoc_req->ssId.ssId,
1933 session_entry->limReassocSSID.length);
1934 if (session_entry->gLimCurrentBssUapsd) {
1935 session_entry->gUapsdPerAcBitmask =
1936 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001937 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001938 session_entry->gUapsdPerAcBitmask);
1939 }
1940
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301941 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001942 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001943 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944
1945 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1946 goto end;
1947 }
1948
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301949 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001950 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
1951
1952 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
1953 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001954 eSIR_SUCCESS)
1955 pe_err("could not retrieve ReassocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001956
1957 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001958 eSIR_SUCCESS)
1959 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301960
1961 lim_update_caps_info_for_bss(mac_ctx, &caps,
1962 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001963 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301964
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001965 mlm_reassoc_req->capabilityInfo = caps;
1966
1967 /* Update PE session_id */
1968 mlm_reassoc_req->sessionId = session_id;
1969
1970 /*
1971 * If telescopic beaconing is enabled, set listen interval to
1972 * WNI_CFG_TELE_BCN_MAX_LI
1973 */
1974 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
1975 &tele_bcn_en) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001976 pe_err("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001977
1978 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
1979
1980 if (tele_bcn_en) {
1981 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
1982 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001983 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001984 } else {
1985 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
1986 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001987 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001988 }
1989
1990 mlm_reassoc_req->listenInterval = (uint16_t) val;
1991
1992 /* Indicate whether spectrum management is enabled */
1993 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
1994
1995 /* Enable the spectrum management if this is a DFS channel */
1996 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001997 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 session_entry->currentOperChannel))
1999 session_entry->spectrumMgtEnabled = true;
2000
2001 session_entry->limPrevSmeState = session_entry->limSmeState;
2002 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2003
2004 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2005 session_entry->peSessionId,
2006 session_entry->limSmeState));
2007
2008 lim_post_mlm_message(mac_ctx,
2009 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2010 return;
2011end:
2012 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302013 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002014 if (session_entry)
2015 session_entry->pLimReAssocReq = NULL;
2016 }
2017
2018 if (session_entry) {
2019 /*
2020 * error occurred after we determined the session so extract
2021 * session and transaction info from there
2022 */
2023 sme_session_id = session_entry->smeSessionId;
2024 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002025 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002026 /*
2027 * error occurred before or during the time we determined
2028 * the session so extract the session and transaction info
2029 * from the message
2030 */
2031 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2032 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002033 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002034 /*
2035 * Send Reassoc failure response to host
2036 * (note session_entry may be NULL, but that's OK)
2037 */
2038 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2039 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2040 session_entry, sme_session_id,
2041 transaction_id);
2042}
2043
2044bool send_disassoc_frame = 1;
2045/**
2046 * __lim_process_sme_disassoc_req()
2047 *
2048 ***FUNCTION:
2049 * This function is called to process SME_DISASSOC_REQ message
2050 * from HDD or upper layer application.
2051 *
2052 ***LOGIC:
2053 *
2054 ***ASSUMPTIONS:
2055 *
2056 ***NOTE:
2057 *
2058 * @param pMac Pointer to Global MAC structure
2059 * @param *pMsgBuf A pointer to the SME message buffer
2060 * @return None
2061 */
2062
2063static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2064{
2065 uint16_t disassocTrigger, reasonCode;
2066 tLimMlmDisassocReq *pMlmDisassocReq;
2067 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2068 tSirSmeDisassocReq smeDisassocReq;
2069 tpPESession psessionEntry = NULL;
2070 uint8_t sessionId;
2071 uint8_t smesessionId;
2072 uint16_t smetransactionId;
2073
2074 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002075 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002076 return;
2077 }
2078
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302079 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002080 smesessionId = smeDisassocReq.sessionId;
2081 smetransactionId = smeDisassocReq.transactionId;
2082 if (!lim_is_sme_disassoc_req_valid(pMac,
2083 &smeDisassocReq,
2084 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002085 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002086 if (pMac->lim.gLimRspReqd) {
2087 pMac->lim.gLimRspReqd = false;
2088
2089 retCode = eSIR_SME_INVALID_PARAMETERS;
2090 disassocTrigger = eLIM_HOST_DISASSOC;
2091 goto sendDisassoc;
2092 }
2093
2094 return;
2095 }
2096
2097 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002098 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002099 &sessionId);
2100 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002101 pe_err("session does not exist for given bssId "
2102 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002103 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002104 retCode = eSIR_SME_INVALID_PARAMETERS;
2105 disassocTrigger = eLIM_HOST_DISASSOC;
2106 goto sendDisassoc;
2107 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002108 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2109 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002110 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2111 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002112 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002113
2114#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2115 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2116 0, smeDisassocReq.reasonCode);
2117#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2118
2119 /* Update SME session Id and SME transaction ID */
2120
2121 psessionEntry->smeSessionId = smesessionId;
2122 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002123 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002124 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002125
2126 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2127 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002128 switch (psessionEntry->limSmeState) {
2129 case eLIM_SME_ASSOCIATED_STATE:
2130 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002131 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002132 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002133 psessionEntry->limPrevSmeState =
2134 psessionEntry->limSmeState;
2135 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002136 /* Delete all TDLS peers connected before leaving BSS */
2137 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002138 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2139 psessionEntry->peSessionId,
2140 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002141 break;
2142
2143 case eLIM_SME_WT_DEAUTH_STATE:
2144 /* PE shall still process the DISASSOC_REQ and proceed with
2145 * link tear down even if it had already sent a DEAUTH_IND to
2146 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2147 * its been set when PE entered WT_DEAUTH_STATE.
2148 */
2149 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2150 MTRACE(mac_trace
2151 (pMac, TRACE_CODE_SME_STATE,
2152 psessionEntry->peSessionId,
2153 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002154 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002155 break;
2156
2157 case eLIM_SME_WT_DISASSOC_STATE:
2158 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2159 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2160 * PE can continue processing DISASSOC_REQ and send the response instead
2161 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2162 * for disassoc frame.
2163 *
2164 * It will send a disassoc, which is ok. However, we can use the global flag
2165 * sendDisassoc to not send disassoc frame.
2166 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002167 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002168 break;
2169
2170 case eLIM_SME_JOIN_FAILURE_STATE: {
2171 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002172 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002173 if (pMac->lim.gLimRspReqd) {
2174 retCode = eSIR_SME_SUCCESS;
2175 disassocTrigger = eLIM_HOST_DISASSOC;
2176 goto sendDisassoc;
2177 }
2178 }
2179 break;
2180 default:
2181 /**
2182 * STA is not currently associated.
2183 * Log error and send response to host
2184 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002185 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002186 psessionEntry->limSmeState);
2187 lim_print_sme_state(pMac, LOGE,
2188 psessionEntry->limSmeState);
2189
2190 if (pMac->lim.gLimRspReqd) {
2191 if (psessionEntry->limSmeState !=
2192 eLIM_SME_WT_ASSOC_STATE)
2193 pMac->lim.gLimRspReqd = false;
2194
2195 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2196 disassocTrigger = eLIM_HOST_DISASSOC;
2197 goto sendDisassoc;
2198 }
2199
2200 return;
2201 }
2202
2203 break;
2204
2205 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002206 /* Fall through */
2207 break;
2208
2209 case eLIM_STA_IN_IBSS_ROLE:
2210 default:
2211 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002212 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002213 GET_LIM_SYSTEM_ROLE(psessionEntry));
2214
2215 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2216 disassocTrigger = eLIM_HOST_DISASSOC;
2217 goto sendDisassoc;
2218 } /* end switch (pMac->lim.gLimSystemRole) */
2219
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302220 disassocTrigger = eLIM_HOST_DISASSOC;
2221 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002222
2223 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002224 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002225 send_disassoc_frame = 0;
2226 }
2227 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002228 pe_debug("Sending Disasscoc with disassoc Trigger"
2229 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002230 disassocTrigger, reasonCode);
2231
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302232 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002233 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002234 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002235 return;
2236 }
2237
Anurag Chouhanc5548422016-02-24 18:33:27 +05302238 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002239 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002240
2241 pMlmDisassocReq->reasonCode = reasonCode;
2242 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2243
2244 /* Update PE session ID */
2245 pMlmDisassocReq->sessionId = sessionId;
2246
2247 lim_post_mlm_message(pMac,
2248 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2249 return;
2250
2251sendDisassoc:
2252 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002253 lim_send_sme_disassoc_ntf(pMac,
2254 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002255 retCode,
2256 disassocTrigger,
2257 1, smesessionId, smetransactionId,
2258 psessionEntry);
2259 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002260 lim_send_sme_disassoc_ntf(pMac,
2261 smeDisassocReq.peer_macaddr.bytes,
2262 retCode, disassocTrigger, 1,
2263 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002264
2265} /*** end __lim_process_sme_disassoc_req() ***/
2266
2267/** -----------------------------------------------------------------
2268 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2269
2270 This function is called to process SME_DISASSOC_CNF message
2271 from HDD or upper layer application.
2272
2273 \param pMac - global mac structure
2274 \param pStaDs - station dph hash node
2275 \return none
2276 \sa
2277 ----------------------------------------------------------------- */
2278static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2279{
2280 tSirSmeDisassocCnf smeDisassocCnf;
2281 uint16_t aid;
2282 tpDphHashNode pStaDs;
2283 tpPESession psessionEntry;
2284 uint8_t sessionId;
2285
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302286 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002287 sizeof(struct sSirSmeDisassocCnf));
2288
2289 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002290 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002291 &sessionId);
2292 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002293 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002294 return;
2295 }
2296
2297 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002298 pe_err("received invalid SME_DISASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002299 return;
2300 }
2301#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2302 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2303 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2304 psessionEntry,
2305 (uint16_t) smeDisassocCnf.statusCode, 0);
2306 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2307 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2308 psessionEntry,
2309 (uint16_t) smeDisassocCnf.statusCode, 0);
2310#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2311
2312 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2313 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002314 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2315 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2316 && (psessionEntry->limSmeState !=
2317 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002318 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002319 psessionEntry->limSmeState);
2320 lim_print_sme_state(pMac, LOGE,
2321 psessionEntry->limSmeState);
2322 return;
2323 }
2324 break;
2325
2326 case eLIM_AP_ROLE:
2327 /* Fall through */
2328 break;
2329
2330 case eLIM_STA_IN_IBSS_ROLE:
2331 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002332 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002333 GET_LIM_SYSTEM_ROLE(psessionEntry));
2334
2335 return;
2336 }
2337
2338 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2339 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2340 LIM_IS_AP_ROLE(psessionEntry)) {
2341 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002342 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002343 &psessionEntry->dph.dphHashTable);
2344 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002345 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2346 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002347 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002348 return;
2349 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302350
2351 if ((pStaDs->mlmStaContext.mlmState ==
2352 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2353 (pStaDs->mlmStaContext.mlmState ==
Arif Hussain5fa13782018-05-10 11:29:52 -07002354 eLIM_MLM_WT_DEL_BSS_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002355 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002356 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302357 pStaDs->mlmStaContext.mlmState);
2358 return;
2359 }
2360
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002361 /* Delete FT session if there exists one */
2362 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002363 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2364
2365 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002366 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002367 }
2368
2369 return;
2370}
2371
2372/**
2373 * __lim_process_sme_deauth_req() - process sme deauth req
2374 * @mac_ctx: Pointer to Global MAC structure
2375 * @msg_buf: pointer to the SME message buffer
2376 *
2377 * This function is called to process SME_DEAUTH_REQ message
2378 * from HDD or upper layer application.
2379 *
2380 * Return: None
2381 */
2382
2383static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2384 uint32_t *msg_buf)
2385{
2386 uint16_t deauth_trigger, reason_code;
2387 tLimMlmDeauthReq *mlm_deauth_req;
2388 tSirSmeDeauthReq sme_deauth_req;
2389 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2390 tpPESession session_entry;
2391 uint8_t session_id; /* PE sessionId */
2392 uint8_t sme_session_id;
2393 uint16_t sme_transaction_id;
2394
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302395 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002396 sme_session_id = sme_deauth_req.sessionId;
2397 sme_transaction_id = sme_deauth_req.transactionId;
2398
2399 /*
2400 * We need to get a session first but we don't even know
2401 * if the message is correct.
2402 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002403 session_entry = pe_find_session_by_bssid(mac_ctx,
2404 sme_deauth_req.bssid.bytes,
2405 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002406 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002407 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 ret_code = eSIR_SME_INVALID_PARAMETERS;
2409 deauth_trigger = eLIM_HOST_DEAUTH;
2410 goto send_deauth;
2411 }
2412
2413 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2414 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002415 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002416 mac_ctx->lim.gLimRspReqd = false;
2417
2418 ret_code = eSIR_SME_INVALID_PARAMETERS;
2419 deauth_trigger = eLIM_HOST_DEAUTH;
2420 goto send_deauth;
2421 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002422 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2423 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002424 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2425 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002426 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002427#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2428 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2429 session_entry, 0, sme_deauth_req.reasonCode);
2430#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2431
2432 /* Update SME session ID and Transaction ID */
2433 session_entry->smeSessionId = sme_session_id;
2434 session_entry->transactionId = sme_transaction_id;
2435
2436 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2437 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002438 switch (session_entry->limSmeState) {
2439 case eLIM_SME_ASSOCIATED_STATE:
2440 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302441 /* Delete all TDLS peers connected before leaving BSS */
2442 lim_delete_tdls_peers(mac_ctx, session_entry);
Abhinav Kumarac12c762018-05-02 13:51:02 +05302443 /* fallthrough */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002444 case eLIM_SME_WT_ASSOC_STATE:
2445 case eLIM_SME_JOIN_FAILURE_STATE:
2446 case eLIM_SME_IDLE_STATE:
2447 session_entry->limPrevSmeState =
2448 session_entry->limSmeState;
2449 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2450 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2451 session_entry->peSessionId,
2452 session_entry->limSmeState));
2453 /* Send Deauthentication request to MLM below */
2454 break;
2455 case eLIM_SME_WT_DEAUTH_STATE:
2456 case eLIM_SME_WT_DISASSOC_STATE:
2457 /*
2458 * PE Recieved a Deauth/Disassoc frame. Normally it get
2459 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2460 * Which means host is also trying to disconnect.
2461 * PE can continue processing DEAUTH_REQ and send
2462 * the response instead of failing the request.
2463 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2464 * was sent for deauth/disassoc frame.
2465 */
2466 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002467 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002468 break;
2469 default:
2470 /*
2471 * STA is not in a state to deauthenticate with
2472 * peer. Log error and send response to host.
2473 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002474 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002475 session_entry->limSmeState);
2476 lim_print_sme_state(mac_ctx, LOGE,
2477 session_entry->limSmeState);
2478
2479 if (mac_ctx->lim.gLimRspReqd) {
2480 mac_ctx->lim.gLimRspReqd = false;
2481
2482 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2483 deauth_trigger = eLIM_HOST_DEAUTH;
2484
wadesong42968e92017-06-08 14:11:21 +08002485 /*
2486 * here we received deauth request from AP so
2487 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2488 * have ISSUED delSta then mlm state should be
2489 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2490 * delBSS rsp then mlm state should be
2491 * eLIM_MLM_IDLE_STATE so the below condition
2492 * captures the state where delSta not done
2493 * and firmware still in connected state.
2494 */
2495 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002496 eLIM_SME_WT_DEAUTH_STATE &&
2497 session_entry->limMlmState !=
2498 eLIM_MLM_IDLE_STATE &&
2499 session_entry->limMlmState !=
2500 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002501 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002502 goto send_deauth;
2503 }
2504 return;
2505 }
2506 break;
2507
2508 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002509 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002510 if (mac_ctx->lim.gLimRspReqd) {
2511 mac_ctx->lim.gLimRspReqd = false;
2512 ret_code = eSIR_SME_INVALID_PARAMETERS;
2513 deauth_trigger = eLIM_HOST_DEAUTH;
2514 goto send_deauth;
2515 }
2516 return;
2517 case eLIM_AP_ROLE:
2518 break;
2519 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002520 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002521 GET_LIM_SYSTEM_ROLE(session_entry));
2522 if (mac_ctx->lim.gLimRspReqd) {
2523 mac_ctx->lim.gLimRspReqd = false;
2524 ret_code = eSIR_SME_INVALID_PARAMETERS;
2525 deauth_trigger = eLIM_HOST_DEAUTH;
2526 goto send_deauth;
2527 }
2528 return;
2529 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2530
2531 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2532 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002533 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002534 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2535 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2536 } else {
2537 deauth_trigger = eLIM_HOST_DEAUTH;
2538 reason_code = sme_deauth_req.reasonCode;
2539 }
2540
2541 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302542 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002543 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002544 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002545 if (mac_ctx->lim.gLimRspReqd) {
2546 mac_ctx->lim.gLimRspReqd = false;
2547 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2548 deauth_trigger = eLIM_HOST_DEAUTH;
2549 goto send_deauth;
2550 }
2551 return;
2552 }
2553
Anurag Chouhanc5548422016-02-24 18:33:27 +05302554 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002555 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002556
2557 mlm_deauth_req->reasonCode = reason_code;
2558 mlm_deauth_req->deauthTrigger = deauth_trigger;
2559
2560 /* Update PE session Id */
2561 mlm_deauth_req->sessionId = session_id;
2562
2563 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2564 (uint32_t *)mlm_deauth_req);
2565 return;
2566
2567send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002568 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2569 ret_code, deauth_trigger, 1,
2570 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002571}
2572
2573/**
2574 * __lim_process_sme_set_context_req()
2575 *
2576 * @mac_ctx: Pointer to Global MAC structure
2577 * @msg_buf: pointer to the SME message buffer
2578 *
2579 * This function is called to process SME_SETCONTEXT_REQ message
2580 * from HDD or upper layer application.
2581 *
2582 * Return: None
2583 */
2584
2585static void
2586__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2587{
2588 tpSirSmeSetContextReq set_context_req;
2589 tLimMlmSetKeysReq *mlm_set_key_req;
2590 tpPESession session_entry;
2591 uint8_t session_id; /* PE sessionID */
2592 uint8_t sme_session_id;
2593 uint16_t sme_transaction_id;
2594
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002595 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002596 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002597 return;
2598 }
2599
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302600 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002601 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002602 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002603 return;
2604 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302605 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606 sizeof(struct sSirSmeSetContextReq));
2607 sme_session_id = set_context_req->sessionId;
2608 sme_transaction_id = set_context_req->transactionId;
2609
2610 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002611 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002612 goto end;
2613 }
2614
2615 if (set_context_req->keyMaterial.numKeys >
2616 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002617 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002618 set_context_req->keyMaterial.numKeys);
2619 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002620 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002621 eSIR_SME_INVALID_PARAMETERS, NULL,
2622 sme_session_id, sme_transaction_id);
2623 goto end;
2624 }
2625
2626 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002627 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002628 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002629 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002630 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002631 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002632 eSIR_SME_INVALID_PARAMETERS, NULL,
2633 sme_session_id, sme_transaction_id);
2634 goto end;
2635 }
2636#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2637 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2638 session_entry, 0, 0);
2639#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2640
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002641 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002642 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2643 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002644 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002645 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2646 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302647 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002648 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002649 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002650 goto end;
2651 }
2652 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2653 mlm_set_key_req->numKeys =
2654 set_context_req->keyMaterial.numKeys;
2655 if (mlm_set_key_req->numKeys >
2656 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002657 pe_err("no.of keys exceeded max num of default keys limit");
Jingxiang Ge4168a232018-01-03 18:47:15 +08002658 qdf_mem_free(mlm_set_key_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002659 goto end;
2660 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302661 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002662 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002663
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302664 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002665 (uint8_t *) &set_context_req->keyMaterial.key,
2666 sizeof(tSirKeys) *
2667 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2668 numKeys : 1));
2669
2670 mlm_set_key_req->sessionId = session_id;
2671 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002672 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002673 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002674
2675 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2676 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2677 LIM_IS_AP_ROLE(session_entry)) {
2678 if (set_context_req->keyMaterial.key[0].keyLength) {
2679 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002680
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002681 key_id =
2682 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302683 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002684 &session_entry->WEPKeyMaterial[key_id],
2685 (uint8_t *) &set_context_req->keyMaterial,
2686 sizeof(tSirKeyMaterial));
2687 } else {
2688 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002689
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002690 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2691 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302692 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002693 &mlm_set_key_req->key[i],
2694 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2695 sizeof(tSirKeys));
2696 }
2697 }
2698 }
2699 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2700 (uint32_t *) mlm_set_key_req);
2701 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002702 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002703 GET_LIM_SYSTEM_ROLE(session_entry),
2704 session_entry->limSmeState);
2705 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2706
2707 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002708 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002709 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2710 session_entry, sme_session_id,
2711 sme_transaction_id);
2712 }
2713end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302714 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002715 return;
2716}
2717
2718/**
2719 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2720 *
2721 * @mac_ctx: Pointer to Global MAC structure
2722 * @msg_buf: pointer to the SME message buffer
2723 *
2724 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2725 * from HDD or upper layer application.
2726 *
2727 * Return: None
2728 */
2729
Jeff Johnson801f1532016-10-07 07:54:50 -07002730static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2731 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002732{
2733 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2734 tpDphHashNode sta_ds = NULL;
2735 tpPESession session_entry = NULL;
2736 tSap_Event sap_event;
2737 tpWLAN_SAPEventCB sap_event_cb = NULL;
2738 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2739 uint8_t session_id = CSR_SESSION_ID_INVALID;
2740 uint8_t assoc_id = 0;
2741 uint8_t sta_cnt = 0;
2742
2743 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002744 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002745 return;
2746 }
2747
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302748 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002749 sizeof(struct sSirSmeGetAssocSTAsReq));
2750 /*
2751 * Get Associated stations from PE.
2752 * Find PE session Entry
2753 */
2754 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08002755 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002756 &session_id);
2757 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002758 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002759 goto lim_assoc_sta_end;
2760 }
2761
2762 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002763 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002764 session_entry->limSmeState,
2765 GET_LIM_SYSTEM_ROLE(session_entry));
2766 goto lim_assoc_sta_end;
2767 }
2768 /* Retrieve values obtained in the request message */
2769 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
2770 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2771
2772 if (NULL == assoc_sta_tmp)
2773 goto lim_assoc_sta_end;
2774 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
2775 assoc_id++) {
2776 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
2777 &session_entry->dph.dphHashTable);
2778 if (NULL == sta_ds)
2779 continue;
2780 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302781 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002782 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302783 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002784 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
2785 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
2786
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302787 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002788 (uint8_t *)&sta_ds->supportedRates,
2789 sizeof(tSirSupportedRates));
2790 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
2791 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
2792 assoc_sta_tmp->Support40Mhz =
2793 sta_ds->htDsssCckRate40MHzSupport;
2794
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002795 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002796 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002797 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002798 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002799 pe_debug("Association Id: %d Station Index: %d",
2800 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002801 assoc_sta_tmp++;
2802 sta_cnt++;
2803 }
2804 }
2805lim_assoc_sta_end:
2806 /*
2807 * Call hdd callback with sap event to send the list of
2808 * associated stations from PE
2809 */
2810 if (sap_event_cb != NULL) {
2811 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
2812 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302813 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002814 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
2815 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
2816 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2817 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
2818 }
2819}
2820
2821/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002822 * __lim_counter_measures()
2823 *
2824 * FUNCTION:
2825 * This function is called to "implement" MIC counter measure
2826 * and is *temporary* only
2827 *
2828 * LOGIC: on AP, disassoc all STA associated thru TKIP,
2829 * we don't do the proper STA disassoc sequence since the
2830 * BSS will be stoped anyway
2831 *
2832 ***ASSUMPTIONS:
2833 *
2834 ***NOTE:
2835 *
2836 * @param pMac Pointer to Global MAC structure
2837 * @return None
2838 */
2839
2840static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
2841{
2842 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002843
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002844 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002845 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
2846 mac, psessionEntry, false);
2847};
2848
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002849static void
2850__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2851{
2852 tSirSmeStopBssReq stopBssReq;
2853 tSirRetStatus status;
2854 tLimSmeStates prevState;
2855 tpPESession psessionEntry;
2856 uint8_t smesessionId;
2857 uint8_t sessionId;
2858 uint16_t smetransactionId;
2859 uint8_t i = 0;
2860 tpDphHashNode pStaDs = NULL;
2861
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302862 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002863 smesessionId = stopBssReq.sessionId;
2864 smetransactionId = stopBssReq.transactionId;
2865
2866 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002867 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002868 /* Send Stop BSS response to host */
2869 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2870 eSIR_SME_INVALID_PARAMETERS, smesessionId,
2871 smetransactionId);
2872 return;
2873 }
2874
2875 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08002876 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002877 &sessionId);
2878 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002879 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002880 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2881 eSIR_SME_INVALID_PARAMETERS, smesessionId,
2882 smetransactionId);
2883 return;
2884 }
2885#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2886 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
2887 0, 0);
2888#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2889
2890 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
2891 LIM_IS_STA_ROLE(psessionEntry)) {
2892 /**
2893 * Should not have received STOP_BSS_REQ in states
2894 * other than 'normal' state or on STA in Infrastructure
2895 * mode. Log error and return response to host.
2896 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002897 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002898 psessionEntry->limSmeState,
2899 GET_LIM_SYSTEM_ROLE(psessionEntry));
2900 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
2901 /* / Send Stop BSS response to host */
2902 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2903 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
2904 smetransactionId);
2905 return;
2906 }
2907
2908 if (LIM_IS_AP_ROLE(psessionEntry))
2909 lim_wpspbc_close(pMac, psessionEntry);
2910
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002911 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002912 stopBssReq.reasonCode);
2913
2914 prevState = psessionEntry->limSmeState;
2915
2916 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
2917 MTRACE(mac_trace
2918 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
2919 psessionEntry->limSmeState));
2920
2921 /* Update SME session Id and Transaction Id */
2922 psessionEntry->smeSessionId = smesessionId;
2923 psessionEntry->transactionId = smetransactionId;
2924
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002925 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
2926 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
2927 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002928 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002929
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002930 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
2931 /* Send disassoc all stations associated thru TKIP */
2932 __lim_counter_measures(pMac, psessionEntry);
2933 else
2934 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002935 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
2936 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002937 }
2938
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002939 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
2940 /* Free the buffer allocated in START_BSS_REQ */
2941 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
2942 psessionEntry->addIeParams.probeRespDataLen = 0;
2943 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002944
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002945 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
2946 psessionEntry->addIeParams.assocRespDataLen = 0;
2947 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002948
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002949 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
2950 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
2951 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002952
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002953 /*
2954 * lim_del_bss is also called as part of coalescing,
2955 * when we send DEL BSS followed by Add Bss msg.
2956 */
2957 pMac->lim.gLimIbssCoalescingHappened = false;
2958 }
Min Liufad99ad2018-04-26 13:17:08 +08002959 for (i = 1; i <= pMac->lim.gLimAssocStaLimit; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002960 pStaDs =
2961 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
2962 if (NULL == pStaDs)
2963 continue;
2964 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
2965 if (eSIR_SUCCESS == status) {
2966 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
2967 pStaDs->assocId, psessionEntry);
2968 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
2969 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002970 pe_err("lim_del_sta failed with Status: %d", status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302971 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002972 }
2973 }
2974 /* send a delBss to HAL and wait for a response */
2975 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
2976
2977 if (status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002978 pe_err("delBss failed for bss %d", psessionEntry->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002979 psessionEntry->limSmeState = prevState;
2980
2981 MTRACE(mac_trace
2982 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
2983 psessionEntry->limSmeState));
2984
2985 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2986 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
2987 smetransactionId);
2988 }
2989}
2990
2991/**
2992 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
2993 * @pMac: Global MAC context
2994 * @pMsg: Message from SME
2995 *
2996 * Wrapper for the function __lim_handle_sme_stop_bss_request
2997 * This message will be defered until softmac come out of
2998 * scan mode. Message should be handled even if we have
2999 * detected radar in the current operating channel.
3000 *
3001 * Return: true - If we consumed the buffer
3002 * false - If have defered the message.
3003 */
3004
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003005static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3006 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003007{
3008 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3009 /**
3010 * If message defered, buffer is not consumed yet.
3011 * So return false
3012 */
3013 return false;
3014 }
3015 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3016 return true;
3017} /*** end __lim_process_sme_stop_bss_req() ***/
3018
3019void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3020 uint32_t body, tpPESession psessionEntry)
3021{
3022
3023 (void)body;
3024 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3025 lim_ibss_delete(pMac, psessionEntry);
3026 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3027 lim_delete_pre_auth_list(pMac);
3028 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3029 psessionEntry->smeSessionId,
3030 psessionEntry->transactionId);
3031 return;
3032}
3033
3034/**
3035 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3036 *
3037 * @mac_ctx: pointer to mac context
3038 * @msg_type: message type
3039 * @msg_buf: pointer to the SME message buffer
3040 *
3041 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3042 * in BTAMP AP.
3043 *
3044 * Return: None
3045 */
3046
3047void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3048 uint32_t *msg_buf)
3049{
3050 tSirSmeAssocCnf assoc_cnf;
3051 tpDphHashNode sta_ds = NULL;
3052 tpPESession session_entry = NULL;
3053 uint8_t session_id;
3054 tpSirAssocReq assoc_req;
3055
3056 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003057 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058 goto end;
3059 }
3060
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303061 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003062 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003063 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003064 goto end;
3065 }
3066
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003067 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003068 &session_id);
3069 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003070 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003071 goto end;
3072 }
3073
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003074 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003075 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3076 (session_entry->limSmeState !=
3077 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003078 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003079 msg_type, session_entry->limSmeState,
3080 GET_LIM_SYSTEM_ROLE(session_entry));
3081 goto end;
3082 }
3083 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3084 &session_entry->dph.dphHashTable);
3085 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003086 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003087 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303088 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003089
3090 /*
3091 * send a DISASSOC_IND message to WSM to make sure
3092 * the state in WSM and LIM is the same
3093 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003094 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003095 eSIR_SME_STA_NOT_ASSOCIATED,
3096 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3097 session_entry->smeSessionId,
3098 session_entry->transactionId,
3099 session_entry);
3100 goto end;
3101 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303102 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003103 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303104 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003105 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003106 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303107 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003108 goto end;
3109 }
3110
3111 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3112 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3113 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3114 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3115 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003116 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3117 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003118 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303119 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003120 goto end;
3121 }
3122 /*
3123 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3124 * has been received
3125 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003126 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003127 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3128 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3129
3130 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3131 /*
3132 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3133 * when it had received Assoc Request frame. Now, PE just needs
3134 * to send association rsp frame to the requesting BTAMP-STA.
3135 */
3136 sta_ds->mlmStaContext.mlmState =
3137 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003138 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003139 sta_ds->assocId);
3140 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3141 sta_ds->assocId, sta_ds->staAddr,
3142 sta_ds->mlmStaContext.subType, sta_ds,
3143 session_entry);
3144 goto end;
3145 } else {
3146 /*
3147 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3148 * to be associated since the HAL sta entry is created for
3149 * denied STA we need to remove this HAL entry.
3150 * So to do that set updateContext to 1
3151 */
3152 if (!sta_ds->mlmStaContext.updateContext)
3153 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003154 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003155 assoc_cnf.statusCode, sta_ds->assocId);
3156 lim_reject_association(mac_ctx, sta_ds->staAddr,
3157 sta_ds->mlmStaContext.subType,
3158 true, sta_ds->mlmStaContext.authType,
3159 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003160 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003161 session_entry);
3162 }
3163end:
3164 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3165 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3166 assoc_req = (tpSirAssocReq)
3167 session_entry->parsedAssocReq[sta_ds->assocId];
3168 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303169 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003170 assoc_req->assocReqFrame = NULL;
3171 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303172 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003173 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3174 }
3175}
3176
3177static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3178{
3179 tpDphHashNode pStaDs;
3180 tSirMacAddr peerMac;
3181 tpSirAddtsReq pSirAddts;
3182 uint32_t timeout;
3183 tpPESession psessionEntry;
3184 uint8_t sessionId; /* PE sessionId */
3185 uint8_t smesessionId;
3186 uint16_t smetransactionId;
3187
3188 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003189 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003190 return;
3191 }
3192
3193 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3194 &smetransactionId);
3195
3196 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3197
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003198 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3199 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003200 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003201 pe_err("Session Does not exist for given bssId");
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303202 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3203 NULL, pSirAddts->req.tspec,
3204 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003205 return;
3206 }
3207#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3208 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3209 0);
3210#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3211
3212 /* if sta
3213 * - verify assoc state
3214 * - send addts request to ap
3215 * - wait for addts response from ap
3216 * if ap, just ignore with error log
3217 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003218 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3219 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3220 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003221
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003222 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003223 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303224 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003225 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226
3227 pStaDs =
3228 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3229 &psessionEntry->dph.dphHashTable);
3230
3231 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003232 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303233 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003234 }
3235
3236 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3237 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003238 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303239 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003240 }
3241
3242 pSirAddts->req.wsmTspecPresent = 0;
3243 pSirAddts->req.wmeTspecPresent = 0;
3244 pSirAddts->req.lleTspecPresent = 0;
3245
3246 if ((pStaDs->wsmEnabled) &&
3247 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3248 SIR_MAC_ACCESSPOLICY_EDCA))
3249 pSirAddts->req.wsmTspecPresent = 1;
3250 else if (pStaDs->wmeEnabled)
3251 pSirAddts->req.wmeTspecPresent = 1;
3252 else if (pStaDs->lleEnabled)
3253 pSirAddts->req.lleTspecPresent = 1;
3254 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003255 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303256 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003257 }
3258
3259 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3260 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003261 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003262 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303263 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003264 }
3265
3266 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003267 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003268 pMac->lim.gLimAddtsReq.req.dialogToken,
3269 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3270 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3271 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303272 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003273 }
3274
3275 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3276
3277 /* save the addts request */
3278 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303279 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003280 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3281
3282 /* ship out the message now */
3283 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3284 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303285 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003286 /* start a timer to wait for the response */
3287 if (pSirAddts->timeout)
3288 timeout = pSirAddts->timeout;
3289 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3290 eSIR_SUCCESS) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303291 pe_debug("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003292 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303293 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003294 }
3295
3296 timeout = SYS_MS_TO_TICKS(timeout);
3297 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3298 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003299 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303300 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003301 }
3302 pMac->lim.gLimAddtsRspTimerCount++;
3303 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3304 pMac->lim.gLimAddtsRspTimerCount) !=
3305 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003306 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303307 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003308 }
3309 MTRACE(mac_trace
3310 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3311 eLIM_ADDTS_RSP_TIMER));
3312
3313 /* add the sessionId to the timer object */
3314 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3315 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3316 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003317 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303318 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003319 }
3320 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303321
3322send_failure_addts_rsp:
3323 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3324 psessionEntry, pSirAddts->req.tspec,
3325 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003326}
3327
3328static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3329{
3330 tSirMacAddr peerMacAddr;
3331 uint8_t ac;
3332 tSirMacTSInfo *pTsinfo;
3333 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3334 tpDphHashNode pStaDs = NULL;
3335 tpPESession psessionEntry;
3336 uint8_t sessionId;
3337 uint32_t status = eSIR_SUCCESS;
3338 uint8_t smesessionId;
3339 uint16_t smetransactionId;
3340
3341 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3342 &smetransactionId);
3343
3344 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003345 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003346 &sessionId);
3347 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003348 pe_err("Session Does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003349 status = eSIR_FAILURE;
3350 goto end;
3351 }
3352#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3353 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3354 0);
3355#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3356
3357 if (eSIR_SUCCESS !=
3358 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003359 pe_err("lim_validate_delts_req failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003360 status = eSIR_FAILURE;
3361 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3362 smesessionId, smetransactionId);
3363 return;
3364 }
3365
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003366 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3367 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003368 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3369
3370 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3371 pDeltsReq->req.wmeTspecPresent,
3372 &pDeltsReq->req.tsinfo,
3373 &pDeltsReq->req.tspec, psessionEntry);
3374
3375 pTsinfo =
3376 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3377 tsinfo : &pDeltsReq->req.tsinfo;
3378
3379 /* We've successfully send DELTS frame to AP. Update the
3380 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3381 * is no longer trigger enabled or delivery enabled
3382 */
3383 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3384 pTsinfo, CLEAR_UAPSD_MASK);
3385
3386 /* We're deleting the TSPEC, so this particular AC is no longer
3387 * admitted. PE needs to downgrade the EDCA
3388 * parameters(for the AC for which TS is being deleted) to the
3389 * next best AC for which ACM is not enabled, and send the
3390 * updated values to HAL.
3391 */
3392 ac = upToAc(pTsinfo->traffic.userPrio);
3393
3394 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3395 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3396 ~(1 << ac);
3397 } else if (pTsinfo->traffic.direction ==
3398 SIR_MAC_DIRECTION_DNLINK) {
3399 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3400 ~(1 << ac);
3401 } else if (pTsinfo->traffic.direction ==
3402 SIR_MAC_DIRECTION_BIDIR) {
3403 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3404 ~(1 << ac);
3405 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3406 ~(1 << ac);
3407 }
3408
3409 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3410 psessionEntry);
3411
3412 pStaDs =
3413 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3414 &psessionEntry->dph.dphHashTable);
3415 if (pStaDs != NULL) {
3416 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003417 pStaDs->bssId, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003418 status = eSIR_SUCCESS;
3419 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003420 pe_err("Self entry missing in Hash Table");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003421 status = eSIR_FAILURE;
3422 }
3423#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003424 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003425#endif
3426
3427 /* send an sme response back */
3428end:
3429 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3430 smesessionId, smetransactionId);
3431}
3432
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303433void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434{
3435 /* fetch the sessionEntry based on the sessionId */
3436 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003437
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003438 psessionEntry = pe_find_session_by_session_id(pMac,
3439 pMac->lim.limTimers.gLimAddtsRspTimer.
3440 sessionId);
3441 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003442 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003443 return;
3444 }
3445
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003446 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003447 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003448 GET_LIM_SYSTEM_ROLE(psessionEntry));
3449 pMac->lim.gLimAddtsSent = false;
3450 return;
3451 }
3452
3453 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003454 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003455 return;
3456 }
3457
3458 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003459 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003460 pMac->lim.gLimAddtsRspTimerCount);
3461 return;
3462 }
3463 /* this a real response timeout */
3464 pMac->lim.gLimAddtsSent = false;
3465 pMac->lim.gLimAddtsRspTimerCount++;
3466
3467 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3468 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3469 psessionEntry->smeSessionId,
3470 psessionEntry->transactionId);
3471}
3472
3473/**
3474 * __lim_process_sme_get_statistics_request()
3475 *
3476 ***FUNCTION:
3477 *
3478 *
3479 ***NOTE:
3480 *
3481 * @param pMac Pointer to Global MAC structure
3482 * @param *pMsgBuf A pointer to the SME message buffer
3483 * @return None
3484 */
3485static void
3486__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3487{
3488 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003489 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003490
3491 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3492
3493 msgQ.type = WMA_GET_STATISTICS_REQ;
3494
3495 msgQ.reserved = 0;
3496 msgQ.bodyptr = pMsgBuf;
3497 msgQ.bodyval = 0;
3498 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3499
3500 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303501 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003502 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003503 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003504 return;
3505 }
3506
3507 return;
3508}
3509
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003510#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003511/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003512 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003513 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003514 * @pMac: Pointer to Global MAC structure
3515 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003516 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003517 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003518 */
3519static void
3520__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3521{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003522 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003523
3524 msgQ.type = WMA_TSM_STATS_REQ;
3525 msgQ.reserved = 0;
3526 msgQ.bodyptr = pMsgBuf;
3527 msgQ.bodyval = 0;
3528 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3529
3530 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303531 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003532 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003533 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003534 return;
3535 }
3536}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003537#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003538
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08003539static void lim_process_sme_set_addba_accept(tpAniSirGlobal mac_ctx,
3540 struct sme_addba_accept *msg)
3541{
3542 if (!msg) {
3543 pe_err("Msg Buffer is NULL");
3544 return;
3545 }
3546 if (!msg->addba_accept)
3547 mac_ctx->reject_addba_req = 1;
3548 else
3549 mac_ctx->reject_addba_req = 0;
3550}
3551
Arif Hussaineb8ba362018-03-07 19:15:13 -08003552static void lim_process_sme_update_edca_params(tpAniSirGlobal mac_ctx,
3553 uint32_t sme_session_id)
3554{
3555 tpPESession pe_session;
3556 tpDphHashNode sta_ds_ptr;
3557
3558 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3559 if (!pe_session) {
3560 pe_err("Session does not exist: sme_id %d", sme_session_id);
3561 return;
3562 }
3563 pe_session->gLimEdcaParamsActive[EDCA_AC_BE].no_ack =
3564 mac_ctx->no_ack_policy_cfg[EDCA_AC_BE];
3565 pe_session->gLimEdcaParamsActive[EDCA_AC_BK].no_ack =
3566 mac_ctx->no_ack_policy_cfg[EDCA_AC_BK];
3567 pe_session->gLimEdcaParamsActive[EDCA_AC_VI].no_ack =
3568 mac_ctx->no_ack_policy_cfg[EDCA_AC_VI];
3569 pe_session->gLimEdcaParamsActive[EDCA_AC_VO].no_ack =
3570 mac_ctx->no_ack_policy_cfg[EDCA_AC_VO];
3571 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3572 &pe_session->dph.dphHashTable);
3573 if (sta_ds_ptr)
3574 lim_send_edca_params(mac_ctx,
3575 pe_session->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003576 sta_ds_ptr->bssId, false);
Arif Hussaineb8ba362018-03-07 19:15:13 -08003577 else
3578 pe_err("Self entry missing in Hash Table");
3579}
3580
Naveen Rawat8029a402017-06-01 10:54:19 -07003581static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3582 struct update_config *msg)
3583{
3584 tpPESession pe_session;
3585
3586 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3587 if (msg == NULL) {
3588 pe_err("Buffer is Pointing to NULL");
3589 return;
3590 }
3591
3592 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3593 msg->sme_session_id);
3594 if (pe_session == NULL) {
3595 pe_warn("Session does not exist for given BSSID");
3596 return;
3597 }
3598
3599 switch (msg->capab) {
3600 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3601 pe_session->htConfig.ht_rx_ldpc = msg->value;
3602 break;
3603 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3604 pe_session->htConfig.ht_tx_stbc = msg->value;
3605 break;
3606 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3607 pe_session->htConfig.ht_rx_stbc = msg->value;
3608 break;
3609 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3610 pe_session->htConfig.ht_sgi20 = msg->value;
3611 break;
3612 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3613 pe_session->htConfig.ht_sgi40 = msg->value;
3614 break;
3615 }
3616
3617 if (LIM_IS_AP_ROLE(pe_session)) {
3618 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3619 lim_send_beacon_ind(mac_ctx, pe_session);
3620 }
3621}
3622
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003623void
3624lim_send_vdev_restart(tpAniSirGlobal pMac,
3625 tpPESession psessionEntry, uint8_t sessionId)
3626{
3627 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003628 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003629 tSirRetStatus retCode = eSIR_SUCCESS;
3630
3631 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003632 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003633 return;
3634 }
3635
3636 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303637 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003638 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003639 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003640 return;
3641 }
3642
3643 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3644 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003645 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003646
3647 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3648 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3649 msgQ.bodyval = 0;
3650
3651 retCode = wma_post_ctrl_msg(pMac, &msgQ);
3652 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003653 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303654 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003655 }
3656}
3657
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303658/**
3659 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3660 * @mac_ctx: Pointer to Global MAC structure
3661 * @msg_buf: Pointer to SME message buffer
3662 *
3663 * Return: None
3664 */
3665static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3666 uint32_t *msg_buf)
3667{
3668 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003669 struct scheduler_msg wma_msg = {0};
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303670 tSirRetStatus status;
3671 tSirRoamOffloadScanReq *req_buffer;
3672 uint16_t local_ie_len;
3673 uint8_t *local_ie_buf;
3674
3675 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3676 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3677 req_buffer->sessionId);
3678
3679 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3680 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003681 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303682 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303683 return;
3684 }
3685
3686 local_ie_len = req_buffer->assoc_ie.length;
3687 /* Update ext cap IE if present */
3688 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003689 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3690 local_ie_buf, &local_ie_len)) {
3691 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003692 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3693 req_buffer->assoc_ie.length = local_ie_len;
3694 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3695 local_ie_buf, local_ie_len);
3696 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303697 }
3698 qdf_mem_free(local_ie_buf);
3699
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303700 if (pe_session)
3701 lim_update_fils_rik(pe_session, req_buffer);
3702
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303703 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3704 wma_msg.bodyptr = req_buffer;
3705
3706 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
3707 if (eSIR_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003708 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303709 qdf_mem_free(req_buffer);
3710 }
3711}
3712
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303713/*
3714 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3715 * @mac_ctx: Pointer to global mac context
3716 * @session: Pointer to PE session
3717 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3718 * 1 - Disable broadcast SSID
3719 *
3720 * Return: None
3721 */
3722static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3723 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003724{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003725 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003726 session->ssidHidden, ssid_hidden);
3727
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003728 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303729 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003730 } else {
3731 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05303732 return;
3733 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003734
3735 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303736 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003737
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003738 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303739}
3740
3741/**
3742 * __lim_process_sme_session_update - process SME session update msg
3743 *
3744 * @mac_ctx: Pointer to global mac context
3745 * @msg_buf: Pointer to the received message buffer
3746 *
3747 * Return: None
3748 */
3749static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
3750 uint32_t *msg_buf)
3751{
3752 struct sir_update_session_param *msg;
3753 tpPESession session;
3754
3755 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003756 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303757 return;
3758 }
3759
3760 msg = (struct sir_update_session_param *) msg_buf;
3761
3762 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
3763 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003764 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303765 msg->session_id);
3766 return;
3767 }
3768
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003769 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303770 msg->param_type, msg->param_val);
3771 switch (msg->param_type) {
3772 case SIR_PARAM_SSID_HIDDEN:
3773 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
3774 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303775 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
3776 session->ignore_assoc_disallowed = msg->param_val;
3777 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303778 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003779 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303780 break;
3781 }
3782}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003783
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003784/*
3785 Update the beacon Interval dynamically if beaconInterval is different in MCC
3786 */
3787static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3788{
3789 tpSirChangeBIParams pChangeBIParams;
3790 tpPESession psessionEntry;
3791 uint8_t sessionId = 0;
3792 tUpdateBeaconParams beaconParams;
3793
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003794 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003795
3796 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003797 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003798 return;
3799 }
3800
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303801 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003802 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
3803
3804 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08003805 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003806 &sessionId);
3807 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003808 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003809 return;
3810 }
3811
3812 /*Update sessionEntry Beacon Interval */
3813 if (psessionEntry->beaconParams.beaconInterval !=
3814 pChangeBIParams->beaconInterval) {
3815 psessionEntry->beaconParams.beaconInterval =
3816 pChangeBIParams->beaconInterval;
3817 }
3818
3819 /*Update sch beaconInterval */
3820 if (pMac->sch.schObject.gSchBeaconInterval !=
3821 pChangeBIParams->beaconInterval) {
3822 pMac->sch.schObject.gSchBeaconInterval =
3823 pChangeBIParams->beaconInterval;
3824
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003825 pe_debug("LIM send update BeaconInterval Indication: %d",
3826 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003827
3828 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
3829 /* Update beacon */
3830 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3831
3832 beaconParams.bssIdx = psessionEntry->bssIdx;
3833 /* Set change in beacon Interval */
3834 beaconParams.beaconInterval =
3835 pChangeBIParams->beaconInterval;
3836 beaconParams.paramChangeBitmap =
3837 PARAM_BCN_INTERVAL_CHANGED;
3838 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
3839 }
3840 }
3841
3842 return;
3843} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
3844
3845#ifdef QCA_HT_2040_COEX
3846static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
3847 uint32_t *pMsgBuf)
3848{
3849 tpSirSetHT2040Mode pSetHT2040Mode;
3850 tpPESession psessionEntry;
3851 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003852 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003853 tUpdateVHTOpMode *pHtOpMode = NULL;
3854 uint16_t staId = 0;
3855 tpDphHashNode pStaDs = NULL;
3856
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003857 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003858 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003859 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003860 return;
3861 }
3862
3863 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
3864
3865 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08003866 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003867 &sessionId);
3868 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003869 pe_debug("Session does not exist for given BSSID");
3870 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003871 return;
3872 }
3873
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003874 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003875 pSetHT2040Mode->cbMode);
3876 /*Update sessionEntry HT related fields */
3877 switch (pSetHT2040Mode->cbMode) {
3878 case PHY_SINGLE_CHANNEL_CENTERED:
3879 psessionEntry->htSecondaryChannelOffset =
3880 PHY_SINGLE_CHANNEL_CENTERED;
3881 psessionEntry->htRecommendedTxWidthSet = 0;
3882 if (pSetHT2040Mode->obssEnabled)
3883 psessionEntry->htSupportedChannelWidthSet
3884 = eHT_CHANNEL_WIDTH_40MHZ;
3885 else
3886 psessionEntry->htSupportedChannelWidthSet
3887 = eHT_CHANNEL_WIDTH_20MHZ;
3888 break;
3889 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
3890 psessionEntry->htSecondaryChannelOffset =
3891 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3892 psessionEntry->htRecommendedTxWidthSet = 1;
3893 break;
3894 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
3895 psessionEntry->htSecondaryChannelOffset =
3896 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3897 psessionEntry->htRecommendedTxWidthSet = 1;
3898 break;
3899 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003900 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003901 return;
3902 }
3903
3904 /* Update beacon */
3905 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3906 lim_send_beacon_ind(pMac, psessionEntry);
3907
3908 /* update OP Mode for each associated peer */
3909 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
3910 pStaDs = dph_get_hash_entry(pMac, staId,
3911 &psessionEntry->dph.dphHashTable);
3912 if (NULL == pStaDs)
3913 continue;
3914
3915 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303916 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003917 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003918 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003919 return;
3920 }
3921 pHtOpMode->opMode =
3922 (psessionEntry->htSecondaryChannelOffset ==
3923 PHY_SINGLE_CHANNEL_CENTERED) ?
3924 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
3925 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303926 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003927 sizeof(tSirMacAddr));
3928 pHtOpMode->smesessionId = sessionId;
3929
3930 msg.type = WMA_UPDATE_OP_MODE;
3931 msg.reserved = 0;
3932 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003933 if (!QDF_IS_STATUS_SUCCESS
3934 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
3935 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303936 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003937 return;
3938 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003939 pe_debug("Notifed FW about OP mode: %d for staId=%d",
3940 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003941
3942 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003943 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003944 }
3945
3946 return;
3947}
3948#endif
3949
3950/* -------------------------------------------------------------------- */
3951/**
3952 * __lim_process_report_message
3953 *
3954 * FUNCTION: Processes the next received Radio Resource Management message
3955 *
3956 * LOGIC:
3957 *
3958 * ASSUMPTIONS:
3959 *
3960 * NOTE:
3961 *
3962 * @param None
3963 * @return None
3964 */
3965
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003966static void __lim_process_report_message(tpAniSirGlobal pMac,
3967 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003968{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003969 switch (pMsg->type) {
3970 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
3971 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
3972 break;
3973 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003974 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08003975 break;
3976 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003977 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003978 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003979}
3980
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003981/* -------------------------------------------------------------------- */
3982/**
3983 * lim_send_set_max_tx_power_req
3984 *
3985 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
3986 *
3987 * LOGIC:
3988 *
3989 * ASSUMPTIONS:
3990 *
3991 * NOTE:
3992 *
3993 * @param txPower txPower to be set.
3994 * @param pSessionEntry session entry.
3995 * @return None
3996 */
3997tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07003998lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003999 tpPESession pSessionEntry)
4000{
4001 tpMaxTxPowerParams pMaxTxParams = NULL;
4002 tSirRetStatus retCode = eSIR_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004003 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004004
4005 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004006 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004007 return eSIR_FAILURE;
4008 }
4009
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304010 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004011 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004012 pe_err("Unable to allocate memory for pMaxTxParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004013 return eSIR_MEM_ALLOC_FAILED;
4014
4015 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004016 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304017 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304018 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304019 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004020 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304021 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004022
4023 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4024 msgQ.bodyptr = pMaxTxParams;
4025 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004026 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004027 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4028 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4029 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004030 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304031 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004032 }
4033 return retCode;
4034}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004035
4036/**
4037 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4038 *
4039 * @mac_ctx: Pointer to Global MAC structure
4040 * @msg_buf: pointer to the SME message buffer
4041 *
4042 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4043 * from SME. It Register this information within PE.
4044 *
4045 * Return: None
4046 */
4047static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4048 uint32_t *msg_buf)
4049{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304050 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4052 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4053 struct mgmt_frm_reg_info *next = NULL;
4054 bool match = false;
4055
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004056 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004057 sme_req->registerFrame, sme_req->frameType,
4058 sme_req->matchLen);
4059 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304060 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304061 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4062 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304063 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004064
4065 while (lim_mgmt_regn != NULL) {
4066 if (lim_mgmt_regn->frameType != sme_req->frameType)
4067 goto skip_match;
4068 if (sme_req->matchLen) {
4069 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304070 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004071 sme_req->matchData,
4072 lim_mgmt_regn->matchLen))) {
4073 /* found match! */
4074 match = true;
4075 break;
4076 }
4077 } else {
4078 /* found match! */
4079 match = true;
4080 break;
4081 }
4082skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304083 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304084 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004085 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304086 (qdf_list_node_t *)lim_mgmt_regn,
4087 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304088 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004089 lim_mgmt_regn = next;
4090 next = NULL;
4091 }
4092 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304093 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004094 if (QDF_STATUS_SUCCESS ==
4095 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004096 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004097 (qdf_list_node_t *)lim_mgmt_regn))
4098 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304099 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004100 }
4101
4102 if (sme_req->registerFrame) {
4103 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304104 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004105 sme_req->matchLen);
4106 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004107 lim_mgmt_regn->frameType = sme_req->frameType;
4108 lim_mgmt_regn->matchLen = sme_req->matchLen;
4109 lim_mgmt_regn->sessionId = sme_req->sessionId;
4110 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304111 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004112 sme_req->matchData,
4113 sme_req->matchLen);
4114 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304115 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004116 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304117 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004118 gLimMgmtFrameRegistratinQueue,
4119 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304120 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004121 &mac_ctx->lim.lim_frame_register_lock);
4122 }
4123 }
4124 return;
4125}
4126
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004127static void
4128__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4129{
4130 tpSirResetAPCapsChange pResetCapsChange;
4131 tpPESession psessionEntry;
4132 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004133
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004134 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004135 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004136 return;
4137 }
4138
4139 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4140 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004141 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4142 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004143 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004144 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004145 return;
4146 }
4147
4148 psessionEntry->limSentCapsChangeNtf = false;
4149 return;
4150}
4151
4152/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304153 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4154 * indication callback in PE.
4155 * @mac_ptr: Mac pointer
4156 * @msg_buf: Msg pointer containing the callback
4157 *
4158 * This function is used save the Management frame
4159 * indication callback in PE.
4160 *
4161 * Return: None
4162 */
4163static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4164 uint32_t *msg_buf)
4165{
4166 struct sir_sme_mgmt_frame_cb_req *sme_req =
4167 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4168
4169 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004170 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304171 return;
4172 }
4173 if (sme_req->callback)
4174 mac_ctx->mgmt_frame_ind_cb =
4175 (sir_mgmt_frame_ind_callback)sme_req->callback;
4176 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004177 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304178}
4179
4180/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304181 *__lim_process_send_disassoc_frame: function processes disassoc frame
4182 * @mac_ctx: pointer to mac context
4183 * @msg_buf: message buffer
4184 *
4185 * function processes disassoc request received from SME
4186 *
4187 * return: none
4188 */
4189static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4190 uint32_t *msg_buf)
4191{
4192 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4193 tSirRetStatus status;
4194 tpPESession session_entry = NULL;
4195 uint8_t sme_session_id;
4196 uint16_t sme_trans_id;
4197
4198 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004199 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304200 return;
4201 }
4202
4203 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4204 &sme_trans_id);
4205
4206 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4207 &sme_send_disassoc_frame_req,
4208 (uint8_t *)msg_buf);
4209
4210 if ((eSIR_FAILURE == status) ||
4211 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4212 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004213 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304214 return;
4215 }
4216
4217 session_entry = pe_find_session_by_sme_session_id(
4218 mac_ctx, sme_session_id);
4219 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004220 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304221 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4222 return;
4223 }
4224
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004225 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 +05304226 sme_send_disassoc_frame_req.msg_type,
4227 sme_send_disassoc_frame_req.length,
4228 sme_send_disassoc_frame_req.session_id,
4229 sme_send_disassoc_frame_req.trans_id,
4230 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4231 sme_send_disassoc_frame_req.reason,
4232 sme_send_disassoc_frame_req.wait_for_ack);
4233
4234 lim_send_disassoc_mgmt_frame(mac_ctx,
4235 sme_send_disassoc_frame_req.reason,
4236 sme_send_disassoc_frame_req.peer_mac,
4237 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4238}
4239
4240/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004241 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4242 * @mac_ctx: Pointer to Global MAC structure
4243 * @pdev_id: pdev id to set the IE.
4244 * @nss: Nss values to prepare the HT IE.
4245 *
4246 * Prepares the HT IE with self capabilities for different
4247 * Nss values and sends the set HT IE req to FW.
4248 *
4249 * Return: None
4250 */
4251static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4252 uint8_t nss)
4253{
4254 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004255 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004256 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004257 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004258 tHtCaps *p_ht_cap;
4259 int i;
4260
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004261 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004262 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4263 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004264 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004265 return;
4266 }
4267 ie_params->nss = i;
4268 ie_params->pdev_id = pdev_id;
4269 ie_params->ie_type = DOT11_HT_IE;
4270 /* 2 for IE len and EID */
4271 ie_params->ie_len = 2 + sizeof(tHtCaps);
4272 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4273 if (NULL == ie_params->ie_ptr) {
4274 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004275 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004276 return;
4277 }
4278 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4279 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4280 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4281 ie_params->ie_len);
4282
4283 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004284 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4285 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004286 if (NULL == p_ie) {
4287 qdf_mem_free(ie_params->ie_ptr);
4288 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004289 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004290 return;
4291 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004292 p_ht_cap = (tHtCaps *)&p_ie[2];
4293 p_ht_cap->supportedMCSSet[1] = 0;
4294 p_ht_cap->txSTBC = 0;
4295 }
4296
4297 msg.type = WMA_SET_PDEV_IE_REQ;
4298 msg.bodyptr = ie_params;
4299 msg.bodyval = 0;
4300
4301 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4302 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004303 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004304 qdf_mem_free(ie_params->ie_ptr);
4305 qdf_mem_free(ie_params);
4306 return;
4307 }
4308 }
4309}
4310
4311/**
4312 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4313 * @mac_ctx: Pointer to Global MAC structure
4314 * @pdev_id: pdev id to set the IE.
4315 * @nss: Nss values to prepare the VHT IE.
4316 *
4317 * Prepares the VHT IE with self capabilities for different
4318 * Nss values and sends the set VHT IE req to FW.
4319 *
4320 * Return: None
4321 */
4322static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4323 uint8_t nss)
4324{
4325 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004326 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004327 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004328 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004329 tSirMacVHTCapabilityInfo *vht_cap;
4330 int i;
4331 tSirVhtMcsInfo *vht_mcs;
4332
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004333 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004334 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4335 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004336 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004337 return;
4338 }
4339 ie_params->nss = i;
4340 ie_params->pdev_id = pdev_id;
4341 ie_params->ie_type = DOT11_VHT_IE;
4342 /* 2 for IE len and EID */
4343 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4344 sizeof(tSirVhtMcsInfo);
4345 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4346 if (NULL == ie_params->ie_ptr) {
4347 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004348 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004349 return;
4350 }
4351 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4352 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4353 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4354 ie_params->ie_len);
4355
4356 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004357 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4358 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004359 if (NULL == p_ie) {
4360 qdf_mem_free(ie_params->ie_ptr);
4361 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004362 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004363 return;
4364 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004365 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4366 vht_cap->txSTBC = 0;
4367 vht_mcs =
4368 (tSirVhtMcsInfo *)&p_ie[2 +
4369 sizeof(tSirMacVHTCapabilityInfo)];
4370 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4371 vht_mcs->rxHighest =
4372 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4373 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4374 vht_mcs->txHighest =
4375 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4376 }
4377 msg.type = WMA_SET_PDEV_IE_REQ;
4378 msg.bodyptr = ie_params;
4379 msg.bodyval = 0;
4380
4381 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4382 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004383 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004384 qdf_mem_free(ie_params->ie_ptr);
4385 qdf_mem_free(ie_params);
4386 return;
4387 }
4388 }
4389}
4390
4391/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004392 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4393 * @mac_ctx: Pointer to Global MAC structure
4394 * @msg_buf: Pointer to the SME message buffer
4395 *
4396 * This function is called by limProcessMessageQueue(). This function sets the
4397 * VDEV IEs to the FW.
4398 *
4399 * Return: None
4400 */
4401static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4402 uint32_t *msg_buf)
4403{
4404 struct sir_set_vdev_ies_per_band *p_msg =
4405 (struct sir_set_vdev_ies_per_band *)msg_buf;
4406
4407 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004408 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004409 return;
4410 }
4411
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004412 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004413 p_msg->vdev_id);
4414 /* intentionally using NULL here so that self capabilty are sent */
4415 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4416 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004417 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004418}
4419
4420/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004421 * lim_process_set_pdev_IEs() - process the set pdev IE req
4422 * @mac_ctx: Pointer to Global MAC structure
4423 * @msg_buf: Pointer to the SME message buffer
4424 *
4425 * This function is called by limProcessMessageQueue(). This
4426 * function sets the PDEV IEs to the FW.
4427 *
4428 * Return: None
4429 */
4430static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4431{
4432 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4433
4434 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4435
4436 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004437 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004438 return;
4439 }
4440
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004441 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004442 ht_vht_cfg->nss);
4443 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4444
4445 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4446 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4447 ht_vht_cfg->nss);
4448}
4449
4450/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304451 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4452 *
4453 * access policy
4454 * @mac_ctx: pointer to mac context
4455 * @msg: message buffer
4456 *
4457 * function processes vendor IE and access policy from SME and updates PE
4458 *
4459 * session entry
4460 *
4461 * return: none
4462*/
4463static void lim_process_sme_update_access_policy_vendor_ie(
4464 tpAniSirGlobal mac_ctx,
4465 uint32_t *msg)
4466{
4467 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4468 struct sPESession *pe_session_entry;
Pragaspathi Thilagaraj9b7a1162018-05-07 16:28:13 +05304469 uint16_t num_bytes;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304470
4471 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004472 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304473 return;
4474 }
4475 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4476 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4477 update_vendor_ie->sme_session_id);
4478
4479 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004480 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304481 update_vendor_ie->sme_session_id);
4482 return;
4483 }
4484 if (pe_session_entry->access_policy_vendor_ie)
4485 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4486
4487 num_bytes = update_vendor_ie->ie[1] + 2;
4488 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4489
4490 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004491 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304492 return;
4493 }
4494 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4495 &update_vendor_ie->ie[0], num_bytes);
4496
4497 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4498}
4499
4500/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004501 * lim_process_sme_req_messages()
4502 *
4503 ***FUNCTION:
4504 * This function is called by limProcessMessageQueue(). This
4505 * function processes SME request messages from HDD or upper layer
4506 * application.
4507 *
4508 ***LOGIC:
4509 *
4510 ***ASSUMPTIONS:
4511 *
4512 ***NOTE:
4513 *
4514 * @param pMac Pointer to Global MAC structure
4515 * @param msgType Indicates the SME message type
4516 * @param *pMsgBuf A pointer to the SME message buffer
4517 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4518 * false - if pMsgBuf is not to be freed.
4519 */
4520
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004521bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4522 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004523{
Jeff Johnson33142e62018-05-06 17:58:36 -07004524 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 -08004525 uint32_t *pMsgBuf = pMsg->bodyptr;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004526
4527 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004528 lim_msg_str(pMsg->type), pMsg->type,
4529 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4530 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004531
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004532 /* If no insert NOA required then execute the code below */
4533
4534 switch (pMsg->type) {
4535 case eWNI_SME_SYS_READY_IND:
4536 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4537 break;
4538
4539 case eWNI_SME_START_BSS_REQ:
4540 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4541 break;
4542
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004543 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4544 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4545 break;
4546 case eWNI_SME_JOIN_REQ:
4547 __lim_process_sme_join_req(pMac, pMsgBuf);
4548 break;
4549
4550 case eWNI_SME_REASSOC_REQ:
4551 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4552 break;
4553
4554 case eWNI_SME_DISASSOC_REQ:
4555 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4556 break;
4557
4558 case eWNI_SME_DISASSOC_CNF:
4559 case eWNI_SME_DEAUTH_CNF:
4560 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4561 break;
4562
4563 case eWNI_SME_DEAUTH_REQ:
4564 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4565 break;
4566
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304567 case eWNI_SME_SEND_DISASSOC_FRAME:
4568 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4569 break;
4570
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004571 case eWNI_SME_SETCONTEXT_REQ:
4572 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4573 break;
4574
4575 case eWNI_SME_STOP_BSS_REQ:
4576 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4577 break;
4578
4579 case eWNI_SME_ASSOC_CNF:
4580 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004581 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004582 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4583 pMsgBuf);
4584 break;
4585
4586 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004587 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004588 __lim_process_sme_addts_req(pMac, pMsgBuf);
4589 break;
4590
4591 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004592 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004593 __lim_process_sme_delts_req(pMac, pMsgBuf);
4594 break;
4595
4596 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004597 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004598 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4599 break;
4600
4601 case eWNI_SME_GET_STATISTICS_REQ:
4602 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4603 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4604 bufConsumed = false;
4605 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004606#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004607 case eWNI_SME_GET_TSM_STATS_REQ:
4608 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4609 bufConsumed = false;
4610 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004611#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004612 case eWNI_SME_GET_ASSOC_STAS_REQ:
4613 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4614 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304615 case eWNI_SME_SESSION_UPDATE_PARAM:
4616 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004617 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304618 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4619 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4620 bufConsumed = false;
4621 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004622 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4623 /* Update the beaconInterval */
4624 __lim_process_sme_change_bi(pMac, pMsgBuf);
4625 break;
4626
4627#ifdef QCA_HT_2040_COEX
4628 case eWNI_SME_SET_HT_2040_MODE:
4629 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4630 break;
4631#endif
4632
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004633 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4634 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4635 __lim_process_report_message(pMac, pMsg);
4636 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004637
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004638 case eWNI_SME_FT_PRE_AUTH_REQ:
4639 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4640 break;
4641 case eWNI_SME_FT_UPDATE_KEY:
4642 lim_process_ft_update_key(pMac, pMsgBuf);
4643 break;
4644
4645 case eWNI_SME_FT_AGGR_QOS_REQ:
4646 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4647 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004648
4649 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4650 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4651 break;
4652#ifdef FEATURE_WLAN_TDLS
4653 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4654 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4655 break;
4656 case eWNI_SME_TDLS_ADD_STA_REQ:
4657 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4658 break;
4659 case eWNI_SME_TDLS_DEL_STA_REQ:
4660 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4661 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004662#endif
4663 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4664 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4665 break;
4666
4667 case eWNI_SME_CHANNEL_CHANGE_REQ:
4668 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4669 break;
4670
4671 case eWNI_SME_START_BEACON_REQ:
4672 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4673 break;
4674
4675 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4676 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4677 break;
4678
4679 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4680 lim_process_update_add_ies(pMac, pMsgBuf);
4681 break;
4682
4683 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4684 lim_process_modify_add_ies(pMac, pMsgBuf);
4685 break;
4686 case eWNI_SME_SET_HW_MODE_REQ:
4687 lim_process_set_hw_mode(pMac, pMsgBuf);
4688 break;
4689 case eWNI_SME_NSS_UPDATE_REQ:
4690 lim_process_nss_update_request(pMac, pMsgBuf);
4691 break;
4692 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4693 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4694 break;
4695 case eWNI_SME_SET_IE_REQ:
4696 lim_process_set_ie_req(pMac, pMsgBuf);
4697 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304698 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4699 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
4700 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304701 case eWNI_SME_EXT_CHANGE_CHANNEL:
4702 lim_process_ext_change_channel(pMac, pMsgBuf);
4703 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08004704 case eWNI_SME_SET_ANTENNA_MODE_REQ:
4705 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
4706 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004707 case eWNI_SME_PDEV_SET_HT_VHT_IE:
4708 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07004709 break;
4710 case eWNI_SME_SET_VDEV_IES_PER_BAND:
4711 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
4712 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304713 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
4714 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
4715 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07004716 case eWNI_SME_UPDATE_CONFIG:
4717 lim_process_sme_update_config(pMac,
4718 (struct update_config *)pMsgBuf);
4719 break;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004720 case eWNI_SME_SET_ADDBA_ACCEPT:
4721 lim_process_sme_set_addba_accept(pMac,
4722 (struct sme_addba_accept *)pMsgBuf);
4723 break;
Arif Hussaineb8ba362018-03-07 19:15:13 -08004724 case eWNI_SME_UPDATE_EDCA_PROFILE:
4725 lim_process_sme_update_edca_params(pMac, pMsg->bodyval);
4726 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004727 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304728 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004729 pMsg->bodyptr = NULL;
4730 break;
4731 } /* switch (msgType) */
4732
4733 return bufConsumed;
4734} /*** end lim_process_sme_req_messages() ***/
4735
4736/**
4737 * lim_process_sme_start_beacon_req()
4738 *
4739 ***FUNCTION:
4740 * This function is called by limProcessMessageQueue(). This
4741 * function processes SME request messages from HDD or upper layer
4742 * application.
4743 *
4744 ***LOGIC:
4745 *
4746 ***ASSUMPTIONS:
4747 *
4748 ***NOTE:
4749 *
4750 * @param pMac Pointer to Global MAC structure
4751 * @param msgType Indicates the SME message type
4752 * @param *pMsgBuf A pointer to the SME message buffer
4753 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4754 * false - if pMsgBuf is not to be freed.
4755 */
4756static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
4757{
4758 tpSirStartBeaconIndication pBeaconStartInd;
4759 tpPESession psessionEntry;
4760 uint8_t sessionId; /* PE sessionID */
4761
4762 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004763 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004764 return;
4765 }
4766
4767 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
4768 psessionEntry = pe_find_session_by_bssid(pMac,
4769 pBeaconStartInd->bssid,
4770 &sessionId);
4771 if (psessionEntry == NULL) {
4772 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004773 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004774 return;
4775 }
4776
4777 if (pBeaconStartInd->beaconStartStatus == true) {
4778 /*
4779 * Currently this Indication comes from SAP
4780 * to start Beacon Tx on a DFS channel
4781 * since beaconing has to be done on DFS
4782 * channel only after CAC WAIT is completed.
4783 * On a DFS Channel LIM does not start beacon
4784 * Tx right after the WMA_ADD_BSS_RSP.
4785 */
4786 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05304787 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004788 FL("Start Beacon with ssid %s Ch %d"),
4789 psessionEntry->ssId.ssId,
4790 psessionEntry->currentOperChannel);
4791 lim_send_beacon_ind(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08004792 lim_enable_obss_detection_config(pMac, psessionEntry);
Arif Hussain05fb4872018-01-03 16:02:55 -08004793 lim_send_obss_color_collision_cfg(pMac, psessionEntry,
4794 OBSS_COLOR_COLLISION_DETECTION);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004795 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004796 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004797 return;
4798 }
4799}
4800
4801/**
4802 * lim_process_sme_channel_change_request() - process sme ch change req
4803 *
4804 * @mac_ctx: Pointer to Global MAC structure
4805 * @msg_buf: pointer to the SME message buffer
4806 *
4807 * This function is called to process SME_CHANNEL_CHANGE_REQ message
4808 *
4809 * Return: None
4810 */
4811static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
4812 uint32_t *msg_buf)
4813{
4814 tpSirChanChangeRequest ch_change_req;
4815 tpPESession session_entry;
4816 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07004817 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004818 uint32_t val = 0;
4819
4820 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004821 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004822 return;
4823 }
4824 ch_change_req = (tpSirChanChangeRequest)msg_buf;
4825
4826 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
4827 ch_change_req->targetChannel);
4828
4829 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
4830 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004831 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004832 return;
4833 }
4834
4835 session_entry = pe_find_session_by_bssid(mac_ctx,
4836 ch_change_req->bssid, &session_id);
4837 if (session_entry == NULL) {
4838 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004839 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004840 return;
4841 }
4842
Manjunathappa Prakash34fda792018-02-07 18:23:42 -08004843 if ((session_entry->currentOperChannel ==
4844 ch_change_req->targetChannel) &&
4845 (session_entry->ch_width == ch_change_req->ch_width)) {
4846 pe_err("Target channel and mode is same as current channel and mode channel %d and mode %d",
4847 session_entry->currentOperChannel, session_entry->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004848 return;
4849 }
4850
4851 if (LIM_IS_AP_ROLE(session_entry))
4852 session_entry->channelChangeReasonCode =
4853 LIM_SWITCH_CHANNEL_SAP_DFS;
4854 else
4855 session_entry->channelChangeReasonCode =
4856 LIM_SWITCH_CHANNEL_OPERATION;
4857
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004858 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004859 session_entry->currentOperChannel,
4860 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004861 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004862
4863 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004864 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004865 session_entry->ch_center_freq_seg0 =
4866 ch_change_req->center_freq_seg_0;
4867 session_entry->ch_center_freq_seg1 =
4868 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004869 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004870 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004871 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004872 session_entry->htRecommendedTxWidthSet =
4873 session_entry->htSupportedChannelWidthSet;
4874 session_entry->currentOperChannel =
4875 ch_change_req->targetChannel;
4876 session_entry->limRFBand =
4877 lim_get_rf_band(session_entry->currentOperChannel);
Vignesh Viswanathan153ae932018-04-11 14:24:13 +05304878
4879 /* Update the global beacon filter */
4880 lim_update_bcn_probe_filter(mac_ctx, session_entry);
4881
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004882 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08004883 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004884 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004885 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
4886 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004887 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004888 }
4889
4890 session_entry->lim11hEnable = val;
4891 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304892 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004893 &ch_change_req->operational_rateset,
4894 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304895 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004896 &ch_change_req->extended_rateset,
4897 sizeof(session_entry->extRateSet));
4898 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
4899 session_entry->ch_center_freq_seg0,
4900 session_entry->ch_center_freq_seg1,
4901 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07004902 max_tx_pwr, session_entry->peSessionId,
4903 ch_change_req->cac_duration_ms,
4904 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004905}
4906
4907/******************************************************************************
4908* lim_start_bss_update_add_ie_buffer()
4909*
4910***FUNCTION:
4911* This function checks the src buffer and its length and then malloc for
4912* dst buffer update the same
4913*
4914***LOGIC:
4915*
4916***ASSUMPTIONS:
4917*
4918***NOTE:
4919*
4920* @param pMac Pointer to Global MAC structure
4921* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
4922* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
4923* @param *pSrcData_buff A pointer of uint8_t src buffer
4924* @param srcDataLen src buffer length
4925******************************************************************************/
4926
4927static void
4928lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
4929 uint8_t **pDstData_buff,
4930 uint16_t *pDstDataLen,
4931 uint8_t *pSrcData_buff, uint16_t srcDataLen)
4932{
4933
4934 if (srcDataLen > 0 && pSrcData_buff != NULL) {
4935 *pDstDataLen = srcDataLen;
4936
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304937 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004938
4939 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004940 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004941 return;
4942 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304943 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004944 } else {
4945 *pDstData_buff = NULL;
4946 *pDstDataLen = 0;
4947 }
4948}
4949
4950/******************************************************************************
4951* lim_update_add_ie_buffer()
4952*
4953***FUNCTION:
4954* This function checks the src buffer and length if src buffer length more
4955* than dst buffer length then free the dst buffer and malloc for the new src
4956* length, and update the dst buffer and length. But if dst buffer is bigger
4957* than src buffer length then it just update the dst buffer and length
4958*
4959***LOGIC:
4960*
4961***ASSUMPTIONS:
4962*
4963***NOTE:
4964*
4965* @param pMac Pointer to Global MAC structure
4966* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
4967* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
4968* @param *pSrcData_buff A pointer of uint8_t src buffer
4969* @param srcDataLen src buffer length
4970******************************************************************************/
4971
4972static void
4973lim_update_add_ie_buffer(tpAniSirGlobal pMac,
4974 uint8_t **pDstData_buff,
4975 uint16_t *pDstDataLen,
4976 uint8_t *pSrcData_buff, uint16_t srcDataLen)
4977{
4978
4979 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004980 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004981 return;
4982 }
4983
4984 if (srcDataLen > *pDstDataLen) {
4985 *pDstDataLen = srcDataLen;
4986 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304987 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004988 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304989 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004990
4991 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004992 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004993 *pDstDataLen = 0;
4994 return;
4995 }
4996 }
4997
4998 /* copy the content of buffer into dst buffer
4999 */
5000 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305001 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005002
5003}
5004
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005005/**
5006 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5007 * @pMac : Pointer to Global MAC structure
5008 * @pDstData_buff : A pointer to pointer of dst buffer
5009 * @pDstDataLen : A pointer to pointer of dst buffer length
5010 * @pModifyIE : A pointer to tSirModifyIE
5011 *
5012 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5013 *
5014 * Return:
5015 * True or false depending upon whether IE is updated or not
5016 */
5017static bool
5018lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5019 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5020{
Hong Shi1553d692016-09-28 12:16:19 +08005021 int32_t oui_length;
5022 uint8_t *ibss_ie = NULL;
5023 uint8_t *vendor_ie;
5024#define MAC_VENDOR_OUI "\x00\x16\x32"
5025#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005026
5027 ibss_ie = pModifyIE->pIEBuffer;
5028 oui_length = pModifyIE->oui_length;
5029
5030 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005031 pe_err("Invalid set IBSS vendor IE command length %d",
5032 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005033 return false;
5034 }
5035
Hong Shi1553d692016-09-28 12:16:19 +08005036 /*
5037 * Why replace only beacon OUI data here:
5038 * 1. other ie (such as wpa) shall not be overwritten here.
5039 * 2. per spec, beacon oui ie might be set twice and original one
5040 * shall be updated.
5041 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005042 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005043 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5044 if (vendor_ie) {
5045 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5046 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5047 pModifyIE->ieBufferlength);
5048 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005049 uint16_t new_length;
5050 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005051
Naveen Rawat668dee32017-09-29 14:39:40 -07005052 /*
5053 * check for uint16 overflow before using sum of two numbers as
5054 * length of size to malloc
5055 */
5056 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5057 pe_err("U16 overflow due to %d + %d",
5058 pModifyIE->ieBufferlength, *pDstDataLen);
5059 return false;
5060 }
5061
5062 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5063 new_ptr = qdf_mem_malloc(new_length);
Hong Shi1553d692016-09-28 12:16:19 +08005064 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005065 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005066 return false;
5067 }
5068 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5069 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5070 pModifyIE->ieBufferlength);
5071 qdf_mem_free(*pDstData_buff);
5072 *pDstDataLen = new_length;
5073 *pDstData_buff = new_ptr;
5074 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005075 return true;
5076}
5077
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005078/*
5079* lim_process_modify_add_ies() - process modify additional IE req.
5080*
5081* @mac_ctx: Pointer to Global MAC structure
5082* @msg_buf: pointer to the SME message buffer
5083*
5084* This function update the PE buffers for additional IEs.
5085*
5086* Return: None
5087*/
5088static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5089 uint32_t *msg_buf)
5090{
5091 tpSirModifyIEsInd modify_add_ies;
5092 tpPESession session_entry;
5093 uint8_t session_id;
5094 bool ret = false;
5095 tSirAddIeParams *add_ie_params;
5096
5097 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005098 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005099 return;
5100 }
5101
5102 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5103 /* Incoming message has smeSession, use BSSID to find PE session */
5104 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005105 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005106
5107 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005108 pe_err("Session not found for given bssid"
5109 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005110 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005111 goto end;
5112 }
5113 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5114 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5115 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005116 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005117 modify_add_ies->modifyIE.pIEBuffer,
5118 modify_add_ies->modifyIE.ieBufferlength,
5119 modify_add_ies->modifyIE.ieID,
5120 modify_add_ies->modifyIE.ieIDLen,
5121 modify_add_ies->updateType);
5122 goto end;
5123 }
5124 add_ie_params = &session_entry->addIeParams;
5125 switch (modify_add_ies->updateType) {
5126 case eUPDATE_IE_PROBE_RESP:
5127 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005128 if (LIM_IS_IBSS_ROLE(session_entry)) {
5129 lim_update_ibss_prop_add_ies(mac_ctx,
5130 &add_ie_params->probeRespData_buff,
5131 &add_ie_params->probeRespDataLen,
5132 &modify_add_ies->modifyIE);
5133 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005134 break;
5135 case eUPDATE_IE_ASSOC_RESP:
5136 /* assoc resp IE */
5137 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305138 QDF_TRACE(QDF_MODULE_ID_PE,
5139 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005140 "assoc resp add ie not present %d"),
5141 add_ie_params->assocRespDataLen);
5142 }
5143 /* search through the buffer and modify the IE */
5144 break;
5145 case eUPDATE_IE_PROBE_BCN:
5146 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005147 if (LIM_IS_IBSS_ROLE(session_entry)) {
5148 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5149 &add_ie_params->probeRespBCNData_buff,
5150 &add_ie_params->probeRespBCNDataLen,
5151 &modify_add_ies->modifyIE);
5152 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005153 if (ret == true && modify_add_ies->modifyIE.notify) {
5154 lim_handle_param_update(mac_ctx,
5155 modify_add_ies->updateType);
5156 }
5157 break;
5158 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005159 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005160 modify_add_ies->updateType);
5161 break;
5162 }
5163end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305164 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005165 modify_add_ies->modifyIE.pIEBuffer = NULL;
5166}
5167
5168/*
5169* lim_process_update_add_ies() - process additional IE update req
5170*
5171* @mac_ctx: Pointer to Global MAC structure
5172* @msg_buf: pointer to the SME message buffer
5173*
5174* This function update the PE buffers for additional IEs.
5175*
5176* Return: None
5177*/
5178static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5179 uint32_t *msg_buf)
5180{
5181 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5182 uint8_t session_id;
5183 tpPESession session_entry;
5184 tSirAddIeParams *addn_ie;
5185 uint16_t new_length = 0;
5186 uint8_t *new_ptr = NULL;
5187 tSirUpdateIE *update_ie;
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 update_ie = &update_add_ies->updateIE;
5194 /* incoming message has smeSession, use BSSID to find PE session */
5195 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005196 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005197
5198 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005199 pe_err("Session not found for given bssid"
5200 MAC_ADDRESS_STR,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005201 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005202 goto end;
5203 }
5204 addn_ie = &session_entry->addIeParams;
5205 /* if len is 0, upper layer requested freeing of buffer */
5206 if (0 == update_ie->ieBufferlength) {
5207 switch (update_add_ies->updateType) {
5208 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305209 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005210 addn_ie->probeRespData_buff = NULL;
5211 addn_ie->probeRespDataLen = 0;
5212 break;
5213 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305214 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005215 addn_ie->assocRespData_buff = NULL;
5216 addn_ie->assocRespDataLen = 0;
5217 break;
5218 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305219 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005220 addn_ie->probeRespBCNData_buff = NULL;
5221 addn_ie->probeRespBCNDataLen = 0;
5222
5223 if (update_ie->notify)
5224 lim_handle_param_update(mac_ctx,
5225 update_add_ies->updateType);
5226 break;
5227 default:
5228 break;
5229 }
5230 return;
5231 }
5232 switch (update_add_ies->updateType) {
5233 case eUPDATE_IE_PROBE_RESP:
5234 if (update_ie->append) {
5235 /*
5236 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005237 * with combined length.
5238 * Multiple back to back append commands
5239 * can lead to a huge length.So, check
5240 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005241 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005242 if (addn_ie->probeRespDataLen >
5243 (USHRT_MAX - update_ie->ieBufferlength)) {
5244 pe_err("IE Length overflow, curr:%d, new:%d",
5245 addn_ie->probeRespDataLen,
5246 update_ie->ieBufferlength);
5247 goto end;
5248 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005249 new_length = update_ie->ieBufferlength +
5250 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305251 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005252 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005253 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005254 goto end;
5255 }
5256 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305257 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005258 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305259 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005260 update_ie->pAdditionIEBuffer,
5261 update_ie->ieBufferlength);
5262 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305263 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005264 /* adjust length accordingly */
5265 addn_ie->probeRespDataLen = new_length;
5266 /* save refernece of local buffer in PE session */
5267 addn_ie->probeRespData_buff = new_ptr;
5268 goto end;
5269 }
5270 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5271 &addn_ie->probeRespDataLen,
5272 update_ie->pAdditionIEBuffer,
5273 update_ie->ieBufferlength);
5274 break;
5275 case eUPDATE_IE_ASSOC_RESP:
5276 /* assoc resp IE */
5277 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5278 &addn_ie->assocRespDataLen,
5279 update_ie->pAdditionIEBuffer,
5280 update_ie->ieBufferlength);
5281 break;
5282 case eUPDATE_IE_PROBE_BCN:
5283 /* probe resp Bcn IE */
5284 lim_update_add_ie_buffer(mac_ctx,
5285 &addn_ie->probeRespBCNData_buff,
5286 &addn_ie->probeRespBCNDataLen,
5287 update_ie->pAdditionIEBuffer,
5288 update_ie->ieBufferlength);
5289 if (update_ie->notify)
5290 lim_handle_param_update(mac_ctx,
5291 update_add_ies->updateType);
5292 break;
5293 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005294 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005295 break;
5296 }
5297end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305298 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005299 update_ie->pAdditionIEBuffer = NULL;
5300}
5301
5302/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305303 * send_extended_chan_switch_action_frame()- function to send ECSA
5304 * action frame for each sta connected to SAP/GO and AP in case of
5305 * STA .
5306 * @mac_ctx: pointer to global mac structure
5307 * @new_channel: new channel to switch to.
5308 * @ch_bandwidth: BW of channel to calculate op_class
5309 * @session_entry: pe session
5310 *
5311 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5312 *
5313 * Return: void
5314 */
5315
5316static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5317 uint16_t new_channel, uint8_t ch_bandwidth,
5318 tpPESession session_entry)
5319{
5320 uint16_t op_class;
5321 uint8_t switch_mode = 0, i;
5322 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005323 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305324
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005325 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305326 mac_ctx->scan.countryCodeCurrent,
5327 new_channel,
5328 ch_bandwidth);
5329
5330 if (LIM_IS_AP_ROLE(session_entry) &&
5331 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005332 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305333
gaoleze2920bd2017-03-21 17:38:42 +08005334 switch_count = session_entry->gLimChannelSwitch.switchCount;
5335
Abhishek Singh518323d2015-10-19 17:42:01 +05305336 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005337 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305338 psta =
5339 session_entry->dph.dphHashTable.pDphNodeArray + i;
5340 if (psta && psta->added)
5341 lim_send_extended_chan_switch_action_frame(
5342 mac_ctx,
5343 psta->staAddr,
5344 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005345 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305346 }
5347 } else if (LIM_IS_STA_ROLE(session_entry)) {
5348 lim_send_extended_chan_switch_action_frame(mac_ctx,
5349 session_entry->bssId,
5350 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005351 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305352 }
5353
5354}
5355
gaolez76d2a162017-03-21 19:23:58 +08005356void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5357 uint16_t new_channel,
5358 uint8_t ch_bandwidth,
5359 tpPESession session_entry)
5360{
5361 uint16_t op_class;
5362 uint8_t switch_mode = 0, i;
5363 uint8_t switch_count;
5364 tpDphHashNode psta;
5365 tpDphHashNode dph_node_array_ptr;
5366
5367 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5368
5369 op_class = wlan_reg_dmn_get_opclass_from_channel(
5370 mac_ctx->scan.countryCodeCurrent,
5371 new_channel, ch_bandwidth);
5372
5373 if (LIM_IS_AP_ROLE(session_entry) &&
5374 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5375 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5376
5377 switch_count = session_entry->gLimChannelSwitch.switchCount;
5378
5379 if (LIM_IS_AP_ROLE(session_entry)) {
5380 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5381 psta = dph_node_array_ptr + i;
5382 if (!(psta && psta->added))
5383 continue;
5384 if (session_entry->lim_non_ecsa_cap_num == 0)
5385 lim_send_extended_chan_switch_action_frame
5386 (mac_ctx, psta->staAddr, switch_mode,
5387 op_class, new_channel, switch_count,
5388 session_entry);
5389 else
5390 lim_send_channel_switch_mgmt_frame
5391 (mac_ctx, psta->staAddr, switch_mode,
5392 new_channel, switch_count,
5393 session_entry);
5394 }
5395 } else if (LIM_IS_STA_ROLE(session_entry)) {
5396 lim_send_extended_chan_switch_action_frame
5397 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5398 new_channel, switch_count, session_entry);
5399 }
5400}
5401
5402/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005403 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5404 *
5405 * @mac_ctx: Pointer to Global MAC structure
5406 * @msg_buf: pointer to the SME message buffer
5407 *
5408 * This function processes SME request messages from HDD or upper layer
5409 * application.
5410 *
5411 * Return: None
5412 */
5413static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5414 uint32_t *msg_buf)
5415{
5416 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5417 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005418 uint8_t session_id;
5419 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005420 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005421
5422 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005423 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005424 return;
5425 }
5426
5427 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5428 session_entry = pe_find_session_by_bssid(mac_ctx,
5429 dfs_csa_ie_req->bssid, &session_id);
5430 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005431 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005432 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5433 return;
5434 }
5435
5436 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005437 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005438 GET_LIM_SYSTEM_ROLE(session_entry));
5439 return;
5440 }
5441
5442 /* target channel */
5443 session_entry->gLimChannelSwitch.primaryChannel =
5444 dfs_csa_ie_req->targetChannel;
5445
5446 /* Channel switch announcement needs to be included in beacon */
5447 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005448 session_entry->gLimChannelSwitch.switchCount =
5449 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005450 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005451 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305452 session_entry->gLimChannelSwitch.sec_ch_offset =
5453 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005454 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005455 session_entry->gLimChannelSwitch.switchMode =
5456 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005457
5458 /*
5459 * Validate if SAP is operating HT or VHT mode and set the Channel
5460 * Switch Wrapper element with the Wide Band Switch subelement.
5461 */
5462 if (true != session_entry->vhtCapability)
5463 goto skip_vht;
5464
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005465 /* Now encode the Wider Ch BW element depending on the ch width */
5466 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005467 switch (dfs_csa_ie_req->ch_params.ch_width) {
5468 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005469 /*
5470 * Wide channel BW sublement in channel wrapper element is not
5471 * required in case of 20 Mhz operation. Currently It is set
5472 * only set in case of 40/80 Mhz Operation.
5473 */
5474 session_entry->dfsIncludeChanWrapperIe = false;
5475 wider_bw_ch_switch->newChanWidth =
5476 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5477 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005478 case CH_WIDTH_40MHZ:
5479 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005480 wider_bw_ch_switch->newChanWidth =
5481 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5482 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005483 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005484 session_entry->dfsIncludeChanWrapperIe = true;
5485 wider_bw_ch_switch->newChanWidth =
5486 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5487 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005488 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005489 session_entry->dfsIncludeChanWrapperIe = true;
5490 wider_bw_ch_switch->newChanWidth =
5491 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5492 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005493 case CH_WIDTH_80P80MHZ:
5494 session_entry->dfsIncludeChanWrapperIe = true;
5495 wider_bw_ch_switch->newChanWidth =
5496 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005497 /*
5498 * This is not applicable for 20/40/80 Mhz.
5499 * Only used when we support 80+80 Mhz operation.
5500 * In case of 80+80 Mhz, this parameter indicates
5501 * center channel frequency index of 80 Mhz channel of
5502 * frequency segment 1.
5503 */
5504 wider_bw_ch_switch->newCenterChanFreq1 =
5505 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005506 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005507 default:
5508 session_entry->dfsIncludeChanWrapperIe = false;
5509 /*
5510 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5511 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5512 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005513 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005514 break;
5515 }
5516 /* Fetch the center channel based on the channel width */
5517 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005518 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005519skip_vht:
5520 /* Send CSA IE request from here */
5521 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5522 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005523 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005524 return;
5525 }
5526
5527 /*
5528 * First beacon update request is sent here, the remaining updates are
5529 * done when the FW responds back after sending the first beacon after
5530 * the template update
5531 */
5532 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305533
5534 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5535 ch_offset = BW80;
5536 else
5537 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5538
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005539 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305540 session_entry->gLimChannelSwitch.switchCount,
5541 session_entry->gLimChannelSwitch.primaryChannel,
5542 session_entry->gLimChannelSwitch.ch_width,
5543 session_entry->dfsIncludeChanWrapperIe,
5544 ch_offset);
5545
gaolez76d2a162017-03-21 19:23:58 +08005546 /* Send ECSA/CSA Action frame after updating the beacon */
5547 if (CHAN_HOP_ALL_BANDS_ENABLE)
5548 lim_send_chan_switch_action_frame(mac_ctx,
5549 session_entry->gLimChannelSwitch.primaryChannel,
5550 ch_offset, session_entry);
5551 else
5552 send_extended_chan_switch_action_frame(mac_ctx,
5553 session_entry->gLimChannelSwitch.primaryChannel,
5554 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005555}
5556
5557/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305558 * lim_process_ext_change_channel()- function to send ECSA
5559 * action frame for STA/CLI .
5560 * @mac_ctx: pointer to global mac structure
5561 * @msg: params from sme for new channel.
5562 *
5563 * This function is called to send ECSA frame for STA/CLI.
5564 *
5565 * Return: void
5566 */
5567
5568static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5569 uint32_t *msg)
5570{
5571 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5572 (struct sir_sme_ext_cng_chan_req *) msg;
5573 tpPESession session_entry = NULL;
5574
5575 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005576 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305577 return;
5578 }
5579 session_entry =
5580 pe_find_session_by_sme_session_id(mac_ctx,
5581 ext_chng_channel->session_id);
5582 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005583 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305584 ext_chng_channel->session_id);
5585 return;
5586 }
5587 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005588 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305589 return;
5590 }
5591 send_extended_chan_switch_action_frame(mac_ctx,
5592 ext_chng_channel->new_channel,
5593 0, session_entry);
5594}
5595
5596/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005597 * lim_process_nss_update_request() - process sme nss update req
5598 *
5599 * @mac_ctx: Pointer to Global MAC structure
5600 * @msg_buf: pointer to the SME message buffer
5601 *
5602 * This function processes SME request messages from HDD or upper layer
5603 * application.
5604 *
5605 * Return: None
5606 */
5607static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5608 uint32_t *msg_buf)
5609{
5610 struct sir_nss_update_request *nss_update_req_ptr;
5611 tpPESession session_entry = NULL;
5612
5613 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005614 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005615 return;
5616 }
5617
5618 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305619 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005620 nss_update_req_ptr->vdev_id);
5621 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005622 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005623 nss_update_req_ptr->vdev_id);
5624 return;
5625 }
5626
5627 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005628 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005629 GET_LIM_SYSTEM_ROLE(session_entry));
5630 return;
5631 }
5632
5633 /* populate nss field in the beacon */
5634 session_entry->gLimOperatingMode.present = 1;
5635 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05305636 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
5637
5638 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
5639 (session_entry->ch_width > CH_WIDTH_80MHZ))
5640 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
5641
5642 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
5643
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005644 /* Send nss update request from here */
5645 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5646 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005647 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005648 return;
5649 }
5650
5651 lim_send_beacon_ind(mac_ctx, session_entry);
5652}
5653
5654/**
5655 * lim_process_set_ie_req() - process sme set IE request
5656 *
5657 * @mac_ctx: Pointer to Global MAC structure
5658 * @msg_buf: pointer to the SME message buffer
5659 *
5660 * This function processes SME request messages from HDD or upper layer
5661 * application.
5662 *
5663 * Return: None
5664 */
5665static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5666{
5667 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305668 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005669
5670 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005671 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005672 return;
5673 }
5674
5675 msg = (struct send_extcap_ie *)msg_buf;
5676 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305677 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005678 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005679
5680}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005681
5682#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Arif Hussain05fb4872018-01-03 16:02:55 -08005683
5684/**
5685 * obss_color_collision_process_color_disable() - Disable bss color
5686 * @mac_ctx: Pointer to Global MAC structure
5687 * @session: pointer to session
5688 *
5689 * This function will disbale bss color.
5690 *
5691 * Return: None
5692 */
5693static void obss_color_collision_process_color_disable(tpAniSirGlobal mac_ctx,
5694 tpPESession session)
5695{
5696 tUpdateBeaconParams beacon_params;
5697
5698 if (!session) {
5699 pe_err("Invalid session");
5700 return;
5701 }
5702
5703 if (session->valid && !LIM_IS_AP_ROLE(session)) {
5704 pe_err("Invalid SystemRole %d",
5705 GET_LIM_SYSTEM_ROLE(session));
5706 return;
5707 }
5708
5709 if (session->bss_color_changing == 1) {
5710 pe_warn("%d: color change in progress", session->smeSessionId);
5711 /* Continue color collision detection */
5712 lim_send_obss_color_collision_cfg(mac_ctx, session,
5713 OBSS_COLOR_COLLISION_DETECTION);
5714 return;
5715 }
5716
5717 if (session->he_op.bss_col_disabled == 1) {
5718 pe_warn("%d: bss color already disabled",
5719 session->smeSessionId);
5720 /* Continue free color detection */
5721 lim_send_obss_color_collision_cfg(mac_ctx, session,
5722 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5723 return;
5724 }
5725
5726 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5727 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5728 session->he_op.bss_col_disabled = 1;
Arif Hussain05fb4872018-01-03 16:02:55 -08005729 beacon_params.bss_color_disabled = 1;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005730 beacon_params.bss_color = session->he_op.bss_color;
Arif Hussain05fb4872018-01-03 16:02:55 -08005731
5732 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
5733 eSIR_SUCCESS) {
5734 pe_err("Unable to set op mode IE in beacon");
5735 return;
5736 }
5737
5738 lim_send_beacon_params(mac_ctx, &beacon_params, session);
5739 lim_send_obss_color_collision_cfg(mac_ctx, session,
5740 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5741}
5742
5743/**
5744 * obss_color_collision_process_color_change() - Process bss color change
5745 * @mac_ctx: Pointer to Global MAC structure
5746 * @session: pointer to session
5747 * @obss_color_info: obss color collision/free slot indication info
5748 *
5749 * This function selects new color ib case of bss color collision.
5750 *
5751 * Return: None
5752 */
5753static void obss_color_collision_process_color_change(tpAniSirGlobal mac_ctx,
5754 tpPESession session,
5755 struct wmi_obss_color_collision_info *obss_color_info)
5756{
5757 int i, num_bss_color = 0;
5758 uint32_t bss_color_bitmap;
5759 uint8_t bss_color_index_array[MAX_BSS_COLOR_VALUE];
5760 uint32_t rand_byte = 0;
5761 struct sir_set_he_bss_color he_bss_color;
5762 bool is_color_collision = false;
5763
5764
5765 if (session->bss_color_changing == 1) {
5766 pe_err("%d: color change in progress", session->smeSessionId);
5767 return;
5768 }
5769
5770 if (!session->he_op.bss_col_disabled) {
5771 if (session->he_op.bss_color < 32)
5772 is_color_collision = (obss_color_info->
5773 obss_color_bitmap_bit0to31 >>
5774 session->he_op.bss_color) & 0x01;
5775 else
5776 is_color_collision = (obss_color_info->
5777 obss_color_bitmap_bit32to63 >>
5778 (session->he_op.bss_color -
Arif Hussain9e8c5612018-04-12 16:35:48 -07005779 32)) & 0x01;
Arif Hussain05fb4872018-01-03 16:02:55 -08005780 if (!is_color_collision) {
5781 pe_err("%d: color collision not found, curr_color: %d",
5782 session->smeSessionId,
5783 session->he_op.bss_color);
5784 return;
5785 }
5786 }
5787
5788 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit0to31;
5789
5790 /* Skip color zero */
5791 bss_color_bitmap = bss_color_bitmap >> 1;
5792 for (i = 0; (i < 31) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5793 if (!(bss_color_bitmap & 0x01)) {
5794 bss_color_index_array[num_bss_color] = i + 1;
5795 num_bss_color++;
5796 }
5797 bss_color_bitmap = bss_color_bitmap >> 1;
5798 }
5799
5800 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit32to63;
5801 for (i = 0; (i < 32) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5802 if (!(bss_color_bitmap & 0x01)) {
5803 bss_color_index_array[num_bss_color] = i + 32;
5804 num_bss_color++;
5805 }
5806 bss_color_bitmap = bss_color_bitmap >> 1;
5807 }
5808
5809 if (num_bss_color) {
5810 qdf_get_random_bytes((void *) &rand_byte, 1);
5811 i = (rand_byte + qdf_mc_timer_get_system_ticks()) %
5812 num_bss_color;
5813 pe_debug("New bss color = %d", bss_color_index_array[i]);
5814 he_bss_color.session_id = obss_color_info->vdev_id;
5815 he_bss_color.bss_color = bss_color_index_array[i];
5816 lim_process_set_he_bss_color(mac_ctx,
5817 (uint32_t *)&he_bss_color);
5818 } else {
5819 pe_err("Unable to find bss color from bitmasp");
5820 if (obss_color_info->evt_type ==
5821 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY &&
5822 session->obss_color_collision_dec_evt ==
5823 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
5824 /* In dot11BSSColorCollisionAPPeriod and
5825 * timer expired, time to disable bss color.
5826 */
5827 obss_color_collision_process_color_disable(mac_ctx,
5828 session);
5829 else
5830 /*
5831 * Enter dot11BSSColorCollisionAPPeriod period.
5832 */
5833 lim_send_obss_color_collision_cfg(mac_ctx, session,
5834 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY);
5835 }
5836}
5837
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005838void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5839{
5840 struct sir_set_he_bss_color *bss_color;
5841 tpPESession session_entry = NULL;
5842 tUpdateBeaconParams beacon_params;
5843
5844 if (!msg_buf) {
5845 pe_err("Buffer is Pointing to NULL");
5846 return;
5847 }
5848
5849 bss_color = (struct sir_set_he_bss_color *)msg_buf;
5850 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5851 bss_color->session_id);
5852 if (!session_entry) {
5853 pe_err("Session not found for given session_id %d",
5854 bss_color->session_id);
5855 return;
5856 }
5857
5858 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5859 pe_err("Invalid SystemRole %d",
5860 GET_LIM_SYSTEM_ROLE(session_entry));
5861 return;
5862 }
5863
5864 if (bss_color->bss_color == session_entry->he_op.bss_color) {
5865 pe_err("No change in BSS color, current BSS color %d",
5866 bss_color->bss_color);
5867 return;
5868 }
5869 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5870 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5871 session_entry->he_op.bss_col_disabled = 1;
5872 session_entry->he_bss_color_change.countdown =
5873 BSS_COLOR_SWITCH_COUNTDOWN;
5874 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005875 beacon_params.bss_color_disabled = 1;
5876 beacon_params.bss_color = session_entry->he_op.bss_color;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005877 session_entry->bss_color_changing = 1;
5878
5879 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5880 eSIR_SUCCESS) {
5881 pe_err("Unable to set op mode IE in beacon");
5882 return;
5883 }
5884
5885 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
Arif Hussain05fb4872018-01-03 16:02:55 -08005886 lim_send_obss_color_collision_cfg(mac_ctx, session_entry,
5887 OBSS_COLOR_COLLISION_DETECTION_DISABLE);
5888}
5889
5890void lim_send_obss_color_collision_cfg(tpAniSirGlobal mac_ctx,
5891 tpPESession session,
5892 enum wmi_obss_color_collision_evt_type
5893 event_type)
5894{
5895 struct wmi_obss_color_collision_cfg_param *cfg_param;
5896 struct scheduler_msg msg = {0};
5897
5898 if (!session) {
5899 pe_err("Invalid session");
5900 return;
5901 }
5902
5903 if (!session->he_capable ||
5904 !session->is_session_obss_color_collision_det_enabled) {
5905 pe_debug("%d: obss color det not enabled, he_cap:%d, sup:%d:%d",
5906 session->smeSessionId, session->he_capable,
5907 session->is_session_obss_color_collision_det_enabled,
5908 mac_ctx->lim.global_obss_color_collision_det_offload);
5909 return;
5910 }
5911
5912 cfg_param = qdf_mem_malloc(sizeof(*cfg_param));
5913 if (!cfg_param) {
5914 pe_err("Failed to allocate memory");
5915 return;
5916 }
5917
5918 pe_debug("%d: sending event:%d", session->smeSessionId, event_type);
5919 qdf_mem_zero(cfg_param, sizeof(*cfg_param));
5920 cfg_param->vdev_id = session->smeSessionId;
5921 cfg_param->evt_type = event_type;
5922 if (LIM_IS_AP_ROLE(session))
5923 cfg_param->detection_period_ms =
5924 OBSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS;
5925 else
5926 cfg_param->detection_period_ms =
5927 OBSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS;
5928
5929 cfg_param->scan_period_ms = OBSS_COLOR_COLLISION_SCAN_PERIOD_MS;
5930 if (event_type == OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
5931 cfg_param->free_slot_expiry_time_ms =
5932 OBSS_COLOR_COLLISION_FREE_SLOT_EXPIRY_MS;
5933
5934 msg.type = WMA_OBSS_COLOR_COLLISION_REQ;
5935 msg.bodyptr = cfg_param;
5936 msg.reserved = 0;
5937
5938 if (QDF_IS_STATUS_ERROR(scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
5939 pe_err("Failed to post WMA_OBSS_COLOR_COLLISION_REQ to WMA");
5940 qdf_mem_free(cfg_param);
5941 } else {
5942 session->obss_color_collision_dec_evt = event_type;
5943 }
5944}
5945
5946void lim_process_obss_color_collision_info(tpAniSirGlobal mac_ctx,
5947 uint32_t *msg_buf)
5948{
5949 struct wmi_obss_color_collision_info *obss_color_info;
5950 tpPESession session;
5951
5952 if (!msg_buf) {
5953 pe_err("Buffer is Pointing to NULL");
5954 return;
5955 }
5956
5957 obss_color_info = (struct wmi_obss_color_collision_info *)msg_buf;
5958 session = pe_find_session_by_sme_session_id(mac_ctx,
5959 obss_color_info->vdev_id);
5960 if (!session) {
5961 pe_err("Session not found for given session_id %d",
5962 obss_color_info->vdev_id);
5963 return;
5964 }
5965
5966 pe_debug("vdev_id:%d, evt:%d:%d, 0to31:0x%x, 32to63:0x%x, cap:%d:%d:%d",
5967 obss_color_info->vdev_id,
5968 obss_color_info->evt_type,
5969 session->obss_color_collision_dec_evt,
5970 obss_color_info->obss_color_bitmap_bit0to31,
5971 obss_color_info->obss_color_bitmap_bit32to63,
5972 session->he_capable,
5973 session->is_session_obss_color_collision_det_enabled,
5974 mac_ctx->lim.global_obss_color_collision_det_offload);
5975
5976 if (!session->he_capable ||
5977 !session->is_session_obss_color_collision_det_enabled) {
5978 return;
5979 }
5980
5981 switch (obss_color_info->evt_type) {
5982 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
5983 pe_err("%d: FW disabled obss color det. he_cap:%d, sup:%d:%d",
5984 session->smeSessionId, session->he_capable,
5985 session->is_session_obss_color_collision_det_enabled,
5986 mac_ctx->lim.global_obss_color_collision_det_offload);
5987 session->is_session_obss_color_collision_det_enabled = false;
5988 return;
5989 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
5990 case OBSS_COLOR_COLLISION_DETECTION:
5991 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
5992 if (session->valid && !LIM_IS_AP_ROLE(session)) {
5993 pe_debug("Invalid System Role %d",
5994 GET_LIM_SYSTEM_ROLE(session));
5995 return;
5996 }
5997
5998 if (session->obss_color_collision_dec_evt !=
5999 obss_color_info->evt_type) {
6000 pe_debug("%d: Wrong event: %d, skiping",
6001 obss_color_info->vdev_id,
6002 obss_color_info->evt_type);
6003 return;
6004 }
6005 obss_color_collision_process_color_change(mac_ctx, session,
6006 obss_color_info);
6007 break;
6008 default:
6009 pe_err("%d: Invalid event type %d",
6010 obss_color_info->vdev_id, obss_color_info->evt_type);
6011 return;
6012 }
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006013}
6014#endif