blob: 1d332a01a3d62e675674251e13371ffdc5fd5757 [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;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302285 uint32_t *msg = NULL;
2286 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002287
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302288 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002289 sizeof(struct sSirSmeDisassocCnf));
2290
2291 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002292 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002293 &sessionId);
2294 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002295 pe_err("session does not exist for given bssId");
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302296 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2297 CSR_SESSION_ID_INVALID,
2298 eSIR_SME_INVALID_SESSION,
2299 NULL);
2300 if (QDF_IS_STATUS_SUCCESS(status))
2301 lim_send_sme_disassoc_deauth_ntf(pMac,
2302 QDF_STATUS_SUCCESS,
2303 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002304 return;
2305 }
2306
2307 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002308 pe_err("received invalid SME_DISASSOC_CNF message");
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302309 status = lim_prepare_disconnect_done_ind(pMac, &msg, sessionId,
2310 eSIR_SME_INVALID_PARAMETERS,
2311 &smeDisassocCnf.bssid.bytes[0]);
2312 if (QDF_IS_STATUS_SUCCESS(status))
2313 lim_send_sme_disassoc_deauth_ntf(pMac,
2314 QDF_STATUS_SUCCESS,
2315 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002316 return;
2317 }
2318#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2319 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2320 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2321 psessionEntry,
2322 (uint16_t) smeDisassocCnf.statusCode, 0);
2323 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2324 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2325 psessionEntry,
2326 (uint16_t) smeDisassocCnf.statusCode, 0);
2327#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2328
2329 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2330 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002331 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2332 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2333 && (psessionEntry->limSmeState !=
2334 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002335 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002336 psessionEntry->limSmeState);
2337 lim_print_sme_state(pMac, LOGE,
2338 psessionEntry->limSmeState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302339 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2340 sessionId,
2341 eSIR_SME_INVALID_STATE,
2342 &smeDisassocCnf.bssid.
2343 bytes[0]);
2344 if (QDF_IS_STATUS_SUCCESS(status))
2345 lim_send_sme_disassoc_deauth_ntf(pMac,
2346 QDF_STATUS_SUCCESS,
2347 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002348 return;
2349 }
2350 break;
2351
2352 case eLIM_AP_ROLE:
2353 /* Fall through */
2354 break;
2355
2356 case eLIM_STA_IN_IBSS_ROLE:
2357 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002358 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002359 GET_LIM_SYSTEM_ROLE(psessionEntry));
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302360 status = lim_prepare_disconnect_done_ind(pMac, &msg, sessionId,
2361 eSIR_SME_INVALID_STATE,
2362 &smeDisassocCnf.bssid.bytes[0]);
2363 if (QDF_IS_STATUS_SUCCESS(status))
2364 lim_send_sme_disassoc_deauth_ntf(pMac,
2365 QDF_STATUS_SUCCESS,
2366 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002367 return;
2368 }
2369
2370 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2371 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2372 LIM_IS_AP_ROLE(psessionEntry)) {
2373 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002374 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002375 &psessionEntry->dph.dphHashTable);
2376 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002377 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2378 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002379 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302380 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05302381 sessionId,
2382 eSIR_SME_INVALID_PARAMETERS,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302383 &smeDisassocCnf.bssid.bytes[0]);
2384 if (QDF_IS_STATUS_SUCCESS(status))
2385 lim_send_sme_disassoc_deauth_ntf(pMac,
2386 QDF_STATUS_SUCCESS,
2387 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002388 return;
2389 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302390
2391 if ((pStaDs->mlmStaContext.mlmState ==
2392 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2393 (pStaDs->mlmStaContext.mlmState ==
Arif Hussain5fa13782018-05-10 11:29:52 -07002394 eLIM_MLM_WT_DEL_BSS_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002395 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002396 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302397 pStaDs->mlmStaContext.mlmState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302398 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2399 CSR_SESSION_ID_INVALID,
2400 eSIR_SME_SUCCESS,
2401 NULL);
2402 if (QDF_IS_STATUS_SUCCESS(status))
2403 lim_send_sme_disassoc_deauth_ntf(pMac,
2404 QDF_STATUS_SUCCESS,
2405 (uint32_t *)msg);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302406 return;
2407 }
2408
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002409 /* Delete FT session if there exists one */
2410 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002411 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2412
2413 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002414 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002415 }
2416
2417 return;
2418}
2419
2420/**
2421 * __lim_process_sme_deauth_req() - process sme deauth req
2422 * @mac_ctx: Pointer to Global MAC structure
2423 * @msg_buf: pointer to the SME message buffer
2424 *
2425 * This function is called to process SME_DEAUTH_REQ message
2426 * from HDD or upper layer application.
2427 *
2428 * Return: None
2429 */
2430
2431static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2432 uint32_t *msg_buf)
2433{
2434 uint16_t deauth_trigger, reason_code;
2435 tLimMlmDeauthReq *mlm_deauth_req;
2436 tSirSmeDeauthReq sme_deauth_req;
2437 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2438 tpPESession session_entry;
2439 uint8_t session_id; /* PE sessionId */
2440 uint8_t sme_session_id;
2441 uint16_t sme_transaction_id;
2442
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302443 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002444 sme_session_id = sme_deauth_req.sessionId;
2445 sme_transaction_id = sme_deauth_req.transactionId;
2446
2447 /*
2448 * We need to get a session first but we don't even know
2449 * if the message is correct.
2450 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002451 session_entry = pe_find_session_by_bssid(mac_ctx,
2452 sme_deauth_req.bssid.bytes,
2453 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002454 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002455 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002456 ret_code = eSIR_SME_INVALID_PARAMETERS;
2457 deauth_trigger = eLIM_HOST_DEAUTH;
2458 goto send_deauth;
2459 }
2460
2461 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2462 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002463 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002464 mac_ctx->lim.gLimRspReqd = false;
2465
2466 ret_code = eSIR_SME_INVALID_PARAMETERS;
2467 deauth_trigger = eLIM_HOST_DEAUTH;
2468 goto send_deauth;
2469 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002470 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2471 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002472 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2473 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002474 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002475#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2476 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2477 session_entry, 0, sme_deauth_req.reasonCode);
2478#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2479
2480 /* Update SME session ID and Transaction ID */
2481 session_entry->smeSessionId = sme_session_id;
2482 session_entry->transactionId = sme_transaction_id;
2483
2484 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2485 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002486 switch (session_entry->limSmeState) {
2487 case eLIM_SME_ASSOCIATED_STATE:
2488 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302489 /* Delete all TDLS peers connected before leaving BSS */
2490 lim_delete_tdls_peers(mac_ctx, session_entry);
Abhinav Kumarac12c762018-05-02 13:51:02 +05302491 /* fallthrough */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002492 case eLIM_SME_WT_ASSOC_STATE:
2493 case eLIM_SME_JOIN_FAILURE_STATE:
2494 case eLIM_SME_IDLE_STATE:
2495 session_entry->limPrevSmeState =
2496 session_entry->limSmeState;
2497 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2498 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2499 session_entry->peSessionId,
2500 session_entry->limSmeState));
2501 /* Send Deauthentication request to MLM below */
2502 break;
2503 case eLIM_SME_WT_DEAUTH_STATE:
2504 case eLIM_SME_WT_DISASSOC_STATE:
2505 /*
2506 * PE Recieved a Deauth/Disassoc frame. Normally it get
2507 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2508 * Which means host is also trying to disconnect.
2509 * PE can continue processing DEAUTH_REQ and send
2510 * the response instead of failing the request.
2511 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2512 * was sent for deauth/disassoc frame.
2513 */
2514 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002515 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002516 break;
2517 default:
2518 /*
2519 * STA is not in a state to deauthenticate with
2520 * peer. Log error and send response to host.
2521 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002522 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002523 session_entry->limSmeState);
2524 lim_print_sme_state(mac_ctx, LOGE,
2525 session_entry->limSmeState);
2526
2527 if (mac_ctx->lim.gLimRspReqd) {
2528 mac_ctx->lim.gLimRspReqd = false;
2529
2530 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2531 deauth_trigger = eLIM_HOST_DEAUTH;
2532
wadesong42968e92017-06-08 14:11:21 +08002533 /*
2534 * here we received deauth request from AP so
2535 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2536 * have ISSUED delSta then mlm state should be
2537 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2538 * delBSS rsp then mlm state should be
2539 * eLIM_MLM_IDLE_STATE so the below condition
2540 * captures the state where delSta not done
2541 * and firmware still in connected state.
2542 */
2543 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002544 eLIM_SME_WT_DEAUTH_STATE &&
2545 session_entry->limMlmState !=
2546 eLIM_MLM_IDLE_STATE &&
2547 session_entry->limMlmState !=
2548 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002549 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002550 goto send_deauth;
2551 }
2552 return;
2553 }
2554 break;
2555
2556 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002557 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002558 if (mac_ctx->lim.gLimRspReqd) {
2559 mac_ctx->lim.gLimRspReqd = false;
2560 ret_code = eSIR_SME_INVALID_PARAMETERS;
2561 deauth_trigger = eLIM_HOST_DEAUTH;
2562 goto send_deauth;
2563 }
2564 return;
2565 case eLIM_AP_ROLE:
2566 break;
2567 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002568 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002569 GET_LIM_SYSTEM_ROLE(session_entry));
2570 if (mac_ctx->lim.gLimRspReqd) {
2571 mac_ctx->lim.gLimRspReqd = false;
2572 ret_code = eSIR_SME_INVALID_PARAMETERS;
2573 deauth_trigger = eLIM_HOST_DEAUTH;
2574 goto send_deauth;
2575 }
2576 return;
2577 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2578
2579 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2580 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002581 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002582 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2583 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2584 } else {
2585 deauth_trigger = eLIM_HOST_DEAUTH;
2586 reason_code = sme_deauth_req.reasonCode;
2587 }
2588
2589 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302590 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002591 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002592 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002593 if (mac_ctx->lim.gLimRspReqd) {
2594 mac_ctx->lim.gLimRspReqd = false;
2595 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2596 deauth_trigger = eLIM_HOST_DEAUTH;
2597 goto send_deauth;
2598 }
2599 return;
2600 }
2601
Anurag Chouhanc5548422016-02-24 18:33:27 +05302602 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002603 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002604
2605 mlm_deauth_req->reasonCode = reason_code;
2606 mlm_deauth_req->deauthTrigger = deauth_trigger;
2607
2608 /* Update PE session Id */
2609 mlm_deauth_req->sessionId = session_id;
2610
2611 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2612 (uint32_t *)mlm_deauth_req);
2613 return;
2614
2615send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002616 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2617 ret_code, deauth_trigger, 1,
2618 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002619}
2620
2621/**
2622 * __lim_process_sme_set_context_req()
2623 *
2624 * @mac_ctx: Pointer to Global MAC structure
2625 * @msg_buf: pointer to the SME message buffer
2626 *
2627 * This function is called to process SME_SETCONTEXT_REQ message
2628 * from HDD or upper layer application.
2629 *
2630 * Return: None
2631 */
2632
2633static void
2634__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2635{
2636 tpSirSmeSetContextReq set_context_req;
2637 tLimMlmSetKeysReq *mlm_set_key_req;
2638 tpPESession session_entry;
2639 uint8_t session_id; /* PE sessionID */
2640 uint8_t sme_session_id;
2641 uint16_t sme_transaction_id;
2642
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002643 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002644 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002645 return;
2646 }
2647
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302648 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002649 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002650 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002651 return;
2652 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302653 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002654 sizeof(struct sSirSmeSetContextReq));
2655 sme_session_id = set_context_req->sessionId;
2656 sme_transaction_id = set_context_req->transactionId;
2657
2658 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002659 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660 goto end;
2661 }
2662
2663 if (set_context_req->keyMaterial.numKeys >
2664 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002665 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002666 set_context_req->keyMaterial.numKeys);
2667 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002668 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002669 eSIR_SME_INVALID_PARAMETERS, NULL,
2670 sme_session_id, sme_transaction_id);
2671 goto end;
2672 }
2673
2674 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002675 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002676 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002677 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002678 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002679 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002680 eSIR_SME_INVALID_PARAMETERS, NULL,
2681 sme_session_id, sme_transaction_id);
2682 goto end;
2683 }
2684#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2685 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2686 session_entry, 0, 0);
2687#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2688
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002689 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002690 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2691 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002692 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002693 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2694 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302695 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002696 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002697 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002698 goto end;
2699 }
2700 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2701 mlm_set_key_req->numKeys =
2702 set_context_req->keyMaterial.numKeys;
2703 if (mlm_set_key_req->numKeys >
2704 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002705 pe_err("no.of keys exceeded max num of default keys limit");
Jingxiang Ge4168a232018-01-03 18:47:15 +08002706 qdf_mem_free(mlm_set_key_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002707 goto end;
2708 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302709 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002710 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002711
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302712 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002713 (uint8_t *) &set_context_req->keyMaterial.key,
2714 sizeof(tSirKeys) *
2715 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2716 numKeys : 1));
2717
2718 mlm_set_key_req->sessionId = session_id;
2719 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002720 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002721 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002722
2723 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2724 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2725 LIM_IS_AP_ROLE(session_entry)) {
2726 if (set_context_req->keyMaterial.key[0].keyLength) {
2727 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002728
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002729 key_id =
2730 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302731 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002732 &session_entry->WEPKeyMaterial[key_id],
2733 (uint8_t *) &set_context_req->keyMaterial,
2734 sizeof(tSirKeyMaterial));
2735 } else {
2736 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002737
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002738 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2739 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302740 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002741 &mlm_set_key_req->key[i],
2742 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2743 sizeof(tSirKeys));
2744 }
2745 }
2746 }
2747 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2748 (uint32_t *) mlm_set_key_req);
2749 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002750 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002751 GET_LIM_SYSTEM_ROLE(session_entry),
2752 session_entry->limSmeState);
2753 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2754
2755 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002756 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002757 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2758 session_entry, sme_session_id,
2759 sme_transaction_id);
2760 }
2761end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302762 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002763 return;
2764}
2765
2766/**
2767 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2768 *
2769 * @mac_ctx: Pointer to Global MAC structure
2770 * @msg_buf: pointer to the SME message buffer
2771 *
2772 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2773 * from HDD or upper layer application.
2774 *
2775 * Return: None
2776 */
2777
Jeff Johnson801f1532016-10-07 07:54:50 -07002778static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2779 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002780{
2781 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2782 tpDphHashNode sta_ds = NULL;
2783 tpPESession session_entry = NULL;
2784 tSap_Event sap_event;
2785 tpWLAN_SAPEventCB sap_event_cb = NULL;
2786 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2787 uint8_t session_id = CSR_SESSION_ID_INVALID;
2788 uint8_t assoc_id = 0;
2789 uint8_t sta_cnt = 0;
2790
2791 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002792 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002793 return;
2794 }
2795
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302796 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002797 sizeof(struct sSirSmeGetAssocSTAsReq));
2798 /*
2799 * Get Associated stations from PE.
2800 * Find PE session Entry
2801 */
2802 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08002803 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002804 &session_id);
2805 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002806 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002807 goto lim_assoc_sta_end;
2808 }
2809
2810 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002811 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002812 session_entry->limSmeState,
2813 GET_LIM_SYSTEM_ROLE(session_entry));
2814 goto lim_assoc_sta_end;
2815 }
2816 /* Retrieve values obtained in the request message */
2817 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
2818 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2819
2820 if (NULL == assoc_sta_tmp)
2821 goto lim_assoc_sta_end;
2822 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
2823 assoc_id++) {
2824 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
2825 &session_entry->dph.dphHashTable);
2826 if (NULL == sta_ds)
2827 continue;
2828 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302829 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002830 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302831 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002832 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
2833 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
2834
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302835 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002836 (uint8_t *)&sta_ds->supportedRates,
2837 sizeof(tSirSupportedRates));
2838 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
2839 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
2840 assoc_sta_tmp->Support40Mhz =
2841 sta_ds->htDsssCckRate40MHzSupport;
2842
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002843 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002844 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002845 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002846 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002847 pe_debug("Association Id: %d Station Index: %d",
2848 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002849 assoc_sta_tmp++;
2850 sta_cnt++;
2851 }
2852 }
2853lim_assoc_sta_end:
2854 /*
2855 * Call hdd callback with sap event to send the list of
2856 * associated stations from PE
2857 */
2858 if (sap_event_cb != NULL) {
2859 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
2860 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302861 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002862 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
2863 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
2864 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2865 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
2866 }
2867}
2868
2869/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002870 * __lim_counter_measures()
2871 *
2872 * FUNCTION:
2873 * This function is called to "implement" MIC counter measure
2874 * and is *temporary* only
2875 *
2876 * LOGIC: on AP, disassoc all STA associated thru TKIP,
2877 * we don't do the proper STA disassoc sequence since the
Jeff Johnsond460e842018-05-11 13:25:53 -07002878 * BSS will be stopped anyway
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002879 *
2880 ***ASSUMPTIONS:
2881 *
2882 ***NOTE:
2883 *
2884 * @param pMac Pointer to Global MAC structure
2885 * @return None
2886 */
2887
2888static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
2889{
2890 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002891
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002892 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002893 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
2894 mac, psessionEntry, false);
2895};
2896
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002897static void
2898__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2899{
2900 tSirSmeStopBssReq stopBssReq;
2901 tSirRetStatus status;
2902 tLimSmeStates prevState;
2903 tpPESession psessionEntry;
2904 uint8_t smesessionId;
2905 uint8_t sessionId;
2906 uint16_t smetransactionId;
2907 uint8_t i = 0;
2908 tpDphHashNode pStaDs = NULL;
2909
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302910 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002911 smesessionId = stopBssReq.sessionId;
2912 smetransactionId = stopBssReq.transactionId;
2913
2914 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002915 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002916 /* Send Stop BSS response to host */
2917 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2918 eSIR_SME_INVALID_PARAMETERS, smesessionId,
2919 smetransactionId);
2920 return;
2921 }
2922
2923 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08002924 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002925 &sessionId);
2926 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002927 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002928 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2929 eSIR_SME_INVALID_PARAMETERS, smesessionId,
2930 smetransactionId);
2931 return;
2932 }
2933#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2934 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
2935 0, 0);
2936#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2937
2938 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
2939 LIM_IS_STA_ROLE(psessionEntry)) {
2940 /**
2941 * Should not have received STOP_BSS_REQ in states
2942 * other than 'normal' state or on STA in Infrastructure
2943 * mode. Log error and return response to host.
2944 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002945 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002946 psessionEntry->limSmeState,
2947 GET_LIM_SYSTEM_ROLE(psessionEntry));
2948 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
2949 /* / Send Stop BSS response to host */
2950 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2951 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
2952 smetransactionId);
2953 return;
2954 }
2955
2956 if (LIM_IS_AP_ROLE(psessionEntry))
2957 lim_wpspbc_close(pMac, psessionEntry);
2958
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002959 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002960 stopBssReq.reasonCode);
2961
2962 prevState = psessionEntry->limSmeState;
2963
2964 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
2965 MTRACE(mac_trace
2966 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
2967 psessionEntry->limSmeState));
2968
2969 /* Update SME session Id and Transaction Id */
2970 psessionEntry->smeSessionId = smesessionId;
2971 psessionEntry->transactionId = smetransactionId;
2972
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002973 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
2974 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
2975 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002976 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002977
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002978 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
2979 /* Send disassoc all stations associated thru TKIP */
2980 __lim_counter_measures(pMac, psessionEntry);
2981 else
2982 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002983 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
2984 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002985 }
2986
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002987 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
2988 /* Free the buffer allocated in START_BSS_REQ */
2989 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
2990 psessionEntry->addIeParams.probeRespDataLen = 0;
2991 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002992
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002993 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
2994 psessionEntry->addIeParams.assocRespDataLen = 0;
2995 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002996
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002997 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
2998 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
2999 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003000
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003001 /*
3002 * lim_del_bss is also called as part of coalescing,
3003 * when we send DEL BSS followed by Add Bss msg.
3004 */
3005 pMac->lim.gLimIbssCoalescingHappened = false;
3006 }
Min Liufad99ad2018-04-26 13:17:08 +08003007 for (i = 1; i <= pMac->lim.gLimAssocStaLimit; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003008 pStaDs =
3009 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3010 if (NULL == pStaDs)
3011 continue;
3012 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3013 if (eSIR_SUCCESS == status) {
3014 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3015 pStaDs->assocId, psessionEntry);
3016 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3017 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003018 pe_err("lim_del_sta failed with Status: %d", status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303019 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003020 }
3021 }
3022 /* send a delBss to HAL and wait for a response */
3023 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3024
3025 if (status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003026 pe_err("delBss failed for bss %d", psessionEntry->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003027 psessionEntry->limSmeState = prevState;
3028
3029 MTRACE(mac_trace
3030 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3031 psessionEntry->limSmeState));
3032
3033 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3034 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3035 smetransactionId);
3036 }
3037}
3038
3039/**
3040 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3041 * @pMac: Global MAC context
3042 * @pMsg: Message from SME
3043 *
3044 * Wrapper for the function __lim_handle_sme_stop_bss_request
3045 * This message will be defered until softmac come out of
3046 * scan mode. Message should be handled even if we have
3047 * detected radar in the current operating channel.
3048 *
3049 * Return: true - If we consumed the buffer
3050 * false - If have defered the message.
3051 */
3052
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003053static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3054 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055{
3056 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3057 /**
3058 * If message defered, buffer is not consumed yet.
3059 * So return false
3060 */
3061 return false;
3062 }
3063 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3064 return true;
3065} /*** end __lim_process_sme_stop_bss_req() ***/
3066
3067void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3068 uint32_t body, tpPESession psessionEntry)
3069{
3070
3071 (void)body;
3072 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3073 lim_ibss_delete(pMac, psessionEntry);
3074 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3075 lim_delete_pre_auth_list(pMac);
3076 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3077 psessionEntry->smeSessionId,
3078 psessionEntry->transactionId);
3079 return;
3080}
3081
3082/**
3083 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3084 *
3085 * @mac_ctx: pointer to mac context
3086 * @msg_type: message type
3087 * @msg_buf: pointer to the SME message buffer
3088 *
3089 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3090 * in BTAMP AP.
3091 *
3092 * Return: None
3093 */
3094
3095void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3096 uint32_t *msg_buf)
3097{
3098 tSirSmeAssocCnf assoc_cnf;
3099 tpDphHashNode sta_ds = NULL;
3100 tpPESession session_entry = NULL;
3101 uint8_t session_id;
3102 tpSirAssocReq assoc_req;
3103
3104 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003105 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003106 goto end;
3107 }
3108
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303109 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003110 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003111 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003112 goto end;
3113 }
3114
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003115 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003116 &session_id);
3117 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003118 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003119 goto end;
3120 }
3121
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003122 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003123 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3124 (session_entry->limSmeState !=
3125 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003126 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003127 msg_type, session_entry->limSmeState,
3128 GET_LIM_SYSTEM_ROLE(session_entry));
3129 goto end;
3130 }
3131 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3132 &session_entry->dph.dphHashTable);
3133 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003134 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003135 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303136 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003137
3138 /*
3139 * send a DISASSOC_IND message to WSM to make sure
3140 * the state in WSM and LIM is the same
3141 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003142 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003143 eSIR_SME_STA_NOT_ASSOCIATED,
3144 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3145 session_entry->smeSessionId,
3146 session_entry->transactionId,
3147 session_entry);
3148 goto end;
3149 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303150 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003151 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303152 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003153 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003154 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303155 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003156 goto end;
3157 }
3158
3159 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3160 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3161 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3162 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3163 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003164 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3165 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003166 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303167 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003168 goto end;
3169 }
3170 /*
3171 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3172 * has been received
3173 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003174 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003175 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3176 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3177
3178 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3179 /*
3180 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3181 * when it had received Assoc Request frame. Now, PE just needs
3182 * to send association rsp frame to the requesting BTAMP-STA.
3183 */
3184 sta_ds->mlmStaContext.mlmState =
3185 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003186 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003187 sta_ds->assocId);
3188 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3189 sta_ds->assocId, sta_ds->staAddr,
3190 sta_ds->mlmStaContext.subType, sta_ds,
3191 session_entry);
3192 goto end;
3193 } else {
3194 /*
3195 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3196 * to be associated since the HAL sta entry is created for
3197 * denied STA we need to remove this HAL entry.
3198 * So to do that set updateContext to 1
3199 */
3200 if (!sta_ds->mlmStaContext.updateContext)
3201 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003202 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003203 assoc_cnf.statusCode, sta_ds->assocId);
3204 lim_reject_association(mac_ctx, sta_ds->staAddr,
3205 sta_ds->mlmStaContext.subType,
3206 true, sta_ds->mlmStaContext.authType,
3207 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003208 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003209 session_entry);
3210 }
3211end:
3212 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3213 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3214 assoc_req = (tpSirAssocReq)
3215 session_entry->parsedAssocReq[sta_ds->assocId];
3216 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303217 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218 assoc_req->assocReqFrame = NULL;
3219 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303220 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003221 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3222 }
3223}
3224
3225static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3226{
3227 tpDphHashNode pStaDs;
3228 tSirMacAddr peerMac;
3229 tpSirAddtsReq pSirAddts;
3230 uint32_t timeout;
3231 tpPESession psessionEntry;
3232 uint8_t sessionId; /* PE sessionId */
3233 uint8_t smesessionId;
3234 uint16_t smetransactionId;
3235
3236 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003237 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003238 return;
3239 }
3240
3241 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3242 &smetransactionId);
3243
3244 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3245
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003246 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3247 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003248 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003249 pe_err("Session Does not exist for given bssId");
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303250 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3251 NULL, pSirAddts->req.tspec,
3252 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253 return;
3254 }
3255#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3256 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3257 0);
3258#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3259
3260 /* if sta
3261 * - verify assoc state
3262 * - send addts request to ap
3263 * - wait for addts response from ap
3264 * if ap, just ignore with error log
3265 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003266 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3267 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3268 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003269
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003270 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003271 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303272 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003273 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003274
3275 pStaDs =
3276 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3277 &psessionEntry->dph.dphHashTable);
3278
3279 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003280 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303281 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003282 }
3283
3284 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3285 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003286 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303287 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003288 }
3289
3290 pSirAddts->req.wsmTspecPresent = 0;
3291 pSirAddts->req.wmeTspecPresent = 0;
3292 pSirAddts->req.lleTspecPresent = 0;
3293
3294 if ((pStaDs->wsmEnabled) &&
3295 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3296 SIR_MAC_ACCESSPOLICY_EDCA))
3297 pSirAddts->req.wsmTspecPresent = 1;
3298 else if (pStaDs->wmeEnabled)
3299 pSirAddts->req.wmeTspecPresent = 1;
3300 else if (pStaDs->lleEnabled)
3301 pSirAddts->req.lleTspecPresent = 1;
3302 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003303 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303304 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003305 }
3306
3307 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3308 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003309 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003310 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303311 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003312 }
3313
3314 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003315 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003316 pMac->lim.gLimAddtsReq.req.dialogToken,
3317 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3318 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3319 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303320 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321 }
3322
3323 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3324
3325 /* save the addts request */
3326 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303327 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003328 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3329
3330 /* ship out the message now */
3331 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3332 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303333 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003334 /* start a timer to wait for the response */
3335 if (pSirAddts->timeout)
3336 timeout = pSirAddts->timeout;
3337 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3338 eSIR_SUCCESS) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303339 pe_debug("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003340 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303341 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003342 }
3343
3344 timeout = SYS_MS_TO_TICKS(timeout);
3345 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3346 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003347 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303348 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003349 }
3350 pMac->lim.gLimAddtsRspTimerCount++;
3351 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3352 pMac->lim.gLimAddtsRspTimerCount) !=
3353 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003354 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303355 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003356 }
3357 MTRACE(mac_trace
3358 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3359 eLIM_ADDTS_RSP_TIMER));
3360
3361 /* add the sessionId to the timer object */
3362 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3363 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3364 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003365 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303366 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003367 }
3368 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303369
3370send_failure_addts_rsp:
3371 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3372 psessionEntry, pSirAddts->req.tspec,
3373 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003374}
3375
3376static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3377{
3378 tSirMacAddr peerMacAddr;
3379 uint8_t ac;
3380 tSirMacTSInfo *pTsinfo;
3381 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3382 tpDphHashNode pStaDs = NULL;
3383 tpPESession psessionEntry;
3384 uint8_t sessionId;
3385 uint32_t status = eSIR_SUCCESS;
3386 uint8_t smesessionId;
3387 uint16_t smetransactionId;
3388
3389 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3390 &smetransactionId);
3391
3392 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003393 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003394 &sessionId);
3395 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003396 pe_err("Session Does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003397 status = eSIR_FAILURE;
3398 goto end;
3399 }
3400#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3401 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3402 0);
3403#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3404
3405 if (eSIR_SUCCESS !=
3406 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003407 pe_err("lim_validate_delts_req failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003408 status = eSIR_FAILURE;
3409 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3410 smesessionId, smetransactionId);
3411 return;
3412 }
3413
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003414 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3415 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003416 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3417
3418 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3419 pDeltsReq->req.wmeTspecPresent,
3420 &pDeltsReq->req.tsinfo,
3421 &pDeltsReq->req.tspec, psessionEntry);
3422
3423 pTsinfo =
3424 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3425 tsinfo : &pDeltsReq->req.tsinfo;
3426
3427 /* We've successfully send DELTS frame to AP. Update the
3428 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3429 * is no longer trigger enabled or delivery enabled
3430 */
3431 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3432 pTsinfo, CLEAR_UAPSD_MASK);
3433
3434 /* We're deleting the TSPEC, so this particular AC is no longer
3435 * admitted. PE needs to downgrade the EDCA
3436 * parameters(for the AC for which TS is being deleted) to the
3437 * next best AC for which ACM is not enabled, and send the
3438 * updated values to HAL.
3439 */
3440 ac = upToAc(pTsinfo->traffic.userPrio);
3441
3442 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3443 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3444 ~(1 << ac);
3445 } else if (pTsinfo->traffic.direction ==
3446 SIR_MAC_DIRECTION_DNLINK) {
3447 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3448 ~(1 << ac);
3449 } else if (pTsinfo->traffic.direction ==
3450 SIR_MAC_DIRECTION_BIDIR) {
3451 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3452 ~(1 << ac);
3453 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3454 ~(1 << ac);
3455 }
3456
3457 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3458 psessionEntry);
3459
3460 pStaDs =
3461 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3462 &psessionEntry->dph.dphHashTable);
3463 if (pStaDs != NULL) {
3464 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003465 pStaDs->bssId, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003466 status = eSIR_SUCCESS;
3467 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003468 pe_err("Self entry missing in Hash Table");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003469 status = eSIR_FAILURE;
3470 }
3471#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003472 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003473#endif
3474
3475 /* send an sme response back */
3476end:
3477 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3478 smesessionId, smetransactionId);
3479}
3480
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303481void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003482{
3483 /* fetch the sessionEntry based on the sessionId */
3484 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003485
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003486 psessionEntry = pe_find_session_by_session_id(pMac,
3487 pMac->lim.limTimers.gLimAddtsRspTimer.
3488 sessionId);
3489 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003490 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003491 return;
3492 }
3493
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003494 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003495 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496 GET_LIM_SYSTEM_ROLE(psessionEntry));
3497 pMac->lim.gLimAddtsSent = false;
3498 return;
3499 }
3500
3501 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003502 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003503 return;
3504 }
3505
3506 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003507 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003508 pMac->lim.gLimAddtsRspTimerCount);
3509 return;
3510 }
3511 /* this a real response timeout */
3512 pMac->lim.gLimAddtsSent = false;
3513 pMac->lim.gLimAddtsRspTimerCount++;
3514
3515 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3516 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3517 psessionEntry->smeSessionId,
3518 psessionEntry->transactionId);
3519}
3520
3521/**
3522 * __lim_process_sme_get_statistics_request()
3523 *
3524 ***FUNCTION:
3525 *
3526 *
3527 ***NOTE:
3528 *
3529 * @param pMac Pointer to Global MAC structure
3530 * @param *pMsgBuf A pointer to the SME message buffer
3531 * @return None
3532 */
3533static void
3534__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3535{
3536 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003537 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003538
3539 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3540
3541 msgQ.type = WMA_GET_STATISTICS_REQ;
3542
3543 msgQ.reserved = 0;
3544 msgQ.bodyptr = pMsgBuf;
3545 msgQ.bodyval = 0;
3546 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3547
3548 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303549 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003550 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003551 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003552 return;
3553 }
3554
3555 return;
3556}
3557
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003558#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003559/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003560 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003561 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003562 * @pMac: Pointer to Global MAC structure
3563 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003564 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003565 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003566 */
3567static void
3568__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3569{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003570 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003571
3572 msgQ.type = WMA_TSM_STATS_REQ;
3573 msgQ.reserved = 0;
3574 msgQ.bodyptr = pMsgBuf;
3575 msgQ.bodyval = 0;
3576 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3577
3578 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303579 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003580 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003581 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003582 return;
3583 }
3584}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003585#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08003587static void lim_process_sme_set_addba_accept(tpAniSirGlobal mac_ctx,
3588 struct sme_addba_accept *msg)
3589{
3590 if (!msg) {
3591 pe_err("Msg Buffer is NULL");
3592 return;
3593 }
3594 if (!msg->addba_accept)
3595 mac_ctx->reject_addba_req = 1;
3596 else
3597 mac_ctx->reject_addba_req = 0;
3598}
3599
Arif Hussaineb8ba362018-03-07 19:15:13 -08003600static void lim_process_sme_update_edca_params(tpAniSirGlobal mac_ctx,
3601 uint32_t sme_session_id)
3602{
3603 tpPESession pe_session;
3604 tpDphHashNode sta_ds_ptr;
3605
3606 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3607 if (!pe_session) {
3608 pe_err("Session does not exist: sme_id %d", sme_session_id);
3609 return;
3610 }
3611 pe_session->gLimEdcaParamsActive[EDCA_AC_BE].no_ack =
3612 mac_ctx->no_ack_policy_cfg[EDCA_AC_BE];
3613 pe_session->gLimEdcaParamsActive[EDCA_AC_BK].no_ack =
3614 mac_ctx->no_ack_policy_cfg[EDCA_AC_BK];
3615 pe_session->gLimEdcaParamsActive[EDCA_AC_VI].no_ack =
3616 mac_ctx->no_ack_policy_cfg[EDCA_AC_VI];
3617 pe_session->gLimEdcaParamsActive[EDCA_AC_VO].no_ack =
3618 mac_ctx->no_ack_policy_cfg[EDCA_AC_VO];
3619 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3620 &pe_session->dph.dphHashTable);
3621 if (sta_ds_ptr)
3622 lim_send_edca_params(mac_ctx,
3623 pe_session->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003624 sta_ds_ptr->bssId, false);
Arif Hussaineb8ba362018-03-07 19:15:13 -08003625 else
3626 pe_err("Self entry missing in Hash Table");
3627}
3628
Naveen Rawat8029a402017-06-01 10:54:19 -07003629static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3630 struct update_config *msg)
3631{
3632 tpPESession pe_session;
3633
3634 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3635 if (msg == NULL) {
3636 pe_err("Buffer is Pointing to NULL");
3637 return;
3638 }
3639
3640 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3641 msg->sme_session_id);
3642 if (pe_session == NULL) {
3643 pe_warn("Session does not exist for given BSSID");
3644 return;
3645 }
3646
3647 switch (msg->capab) {
3648 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3649 pe_session->htConfig.ht_rx_ldpc = msg->value;
3650 break;
3651 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3652 pe_session->htConfig.ht_tx_stbc = msg->value;
3653 break;
3654 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3655 pe_session->htConfig.ht_rx_stbc = msg->value;
3656 break;
3657 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3658 pe_session->htConfig.ht_sgi20 = msg->value;
3659 break;
3660 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3661 pe_session->htConfig.ht_sgi40 = msg->value;
3662 break;
3663 }
3664
3665 if (LIM_IS_AP_ROLE(pe_session)) {
3666 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3667 lim_send_beacon_ind(mac_ctx, pe_session);
3668 }
3669}
3670
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003671void
3672lim_send_vdev_restart(tpAniSirGlobal pMac,
3673 tpPESession psessionEntry, uint8_t sessionId)
3674{
3675 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003676 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003677 tSirRetStatus retCode = eSIR_SUCCESS;
3678
3679 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003680 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003681 return;
3682 }
3683
3684 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303685 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003686 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003687 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003688 return;
3689 }
3690
3691 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3692 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003693 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003694
3695 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3696 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3697 msgQ.bodyval = 0;
3698
3699 retCode = wma_post_ctrl_msg(pMac, &msgQ);
3700 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003701 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303702 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003703 }
3704}
3705
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303706/**
3707 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3708 * @mac_ctx: Pointer to Global MAC structure
3709 * @msg_buf: Pointer to SME message buffer
3710 *
3711 * Return: None
3712 */
3713static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3714 uint32_t *msg_buf)
3715{
3716 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003717 struct scheduler_msg wma_msg = {0};
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303718 tSirRetStatus status;
3719 tSirRoamOffloadScanReq *req_buffer;
3720 uint16_t local_ie_len;
3721 uint8_t *local_ie_buf;
3722
3723 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3724 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3725 req_buffer->sessionId);
3726
3727 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3728 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003729 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303730 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303731 return;
3732 }
3733
3734 local_ie_len = req_buffer->assoc_ie.length;
3735 /* Update ext cap IE if present */
3736 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003737 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3738 local_ie_buf, &local_ie_len)) {
3739 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003740 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3741 req_buffer->assoc_ie.length = local_ie_len;
3742 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3743 local_ie_buf, local_ie_len);
3744 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303745 }
3746 qdf_mem_free(local_ie_buf);
3747
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303748 if (pe_session)
3749 lim_update_fils_rik(pe_session, req_buffer);
3750
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303751 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3752 wma_msg.bodyptr = req_buffer;
3753
3754 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
3755 if (eSIR_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003756 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303757 qdf_mem_free(req_buffer);
3758 }
3759}
3760
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303761/*
3762 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3763 * @mac_ctx: Pointer to global mac context
3764 * @session: Pointer to PE session
3765 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3766 * 1 - Disable broadcast SSID
3767 *
3768 * Return: None
3769 */
3770static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3771 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003772{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003773 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003774 session->ssidHidden, ssid_hidden);
3775
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003776 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303777 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003778 } else {
3779 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05303780 return;
3781 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003782
3783 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303784 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003785
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003786 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303787}
3788
3789/**
3790 * __lim_process_sme_session_update - process SME session update msg
3791 *
3792 * @mac_ctx: Pointer to global mac context
3793 * @msg_buf: Pointer to the received message buffer
3794 *
3795 * Return: None
3796 */
3797static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
3798 uint32_t *msg_buf)
3799{
3800 struct sir_update_session_param *msg;
3801 tpPESession session;
3802
3803 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003804 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303805 return;
3806 }
3807
3808 msg = (struct sir_update_session_param *) msg_buf;
3809
3810 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
3811 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003812 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303813 msg->session_id);
3814 return;
3815 }
3816
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003817 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303818 msg->param_type, msg->param_val);
3819 switch (msg->param_type) {
3820 case SIR_PARAM_SSID_HIDDEN:
3821 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
3822 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303823 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
3824 session->ignore_assoc_disallowed = msg->param_val;
3825 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303826 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003827 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303828 break;
3829 }
3830}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003831
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003832/*
3833 Update the beacon Interval dynamically if beaconInterval is different in MCC
3834 */
3835static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3836{
3837 tpSirChangeBIParams pChangeBIParams;
3838 tpPESession psessionEntry;
3839 uint8_t sessionId = 0;
3840 tUpdateBeaconParams beaconParams;
3841
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003842 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003843
3844 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003845 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003846 return;
3847 }
3848
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303849 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003850 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
3851
3852 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08003853 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003854 &sessionId);
3855 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003856 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003857 return;
3858 }
3859
3860 /*Update sessionEntry Beacon Interval */
3861 if (psessionEntry->beaconParams.beaconInterval !=
3862 pChangeBIParams->beaconInterval) {
3863 psessionEntry->beaconParams.beaconInterval =
3864 pChangeBIParams->beaconInterval;
3865 }
3866
3867 /*Update sch beaconInterval */
3868 if (pMac->sch.schObject.gSchBeaconInterval !=
3869 pChangeBIParams->beaconInterval) {
3870 pMac->sch.schObject.gSchBeaconInterval =
3871 pChangeBIParams->beaconInterval;
3872
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003873 pe_debug("LIM send update BeaconInterval Indication: %d",
3874 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003875
3876 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
3877 /* Update beacon */
3878 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3879
3880 beaconParams.bssIdx = psessionEntry->bssIdx;
3881 /* Set change in beacon Interval */
3882 beaconParams.beaconInterval =
3883 pChangeBIParams->beaconInterval;
3884 beaconParams.paramChangeBitmap =
3885 PARAM_BCN_INTERVAL_CHANGED;
3886 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
3887 }
3888 }
3889
3890 return;
3891} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
3892
3893#ifdef QCA_HT_2040_COEX
3894static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
3895 uint32_t *pMsgBuf)
3896{
3897 tpSirSetHT2040Mode pSetHT2040Mode;
3898 tpPESession psessionEntry;
3899 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003900 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003901 tUpdateVHTOpMode *pHtOpMode = NULL;
3902 uint16_t staId = 0;
3903 tpDphHashNode pStaDs = NULL;
3904
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003905 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003906 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003907 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003908 return;
3909 }
3910
3911 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
3912
3913 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08003914 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003915 &sessionId);
3916 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003917 pe_debug("Session does not exist for given BSSID");
3918 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003919 return;
3920 }
3921
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003922 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003923 pSetHT2040Mode->cbMode);
3924 /*Update sessionEntry HT related fields */
3925 switch (pSetHT2040Mode->cbMode) {
3926 case PHY_SINGLE_CHANNEL_CENTERED:
3927 psessionEntry->htSecondaryChannelOffset =
3928 PHY_SINGLE_CHANNEL_CENTERED;
3929 psessionEntry->htRecommendedTxWidthSet = 0;
3930 if (pSetHT2040Mode->obssEnabled)
3931 psessionEntry->htSupportedChannelWidthSet
3932 = eHT_CHANNEL_WIDTH_40MHZ;
3933 else
3934 psessionEntry->htSupportedChannelWidthSet
3935 = eHT_CHANNEL_WIDTH_20MHZ;
3936 break;
3937 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
3938 psessionEntry->htSecondaryChannelOffset =
3939 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3940 psessionEntry->htRecommendedTxWidthSet = 1;
3941 break;
3942 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
3943 psessionEntry->htSecondaryChannelOffset =
3944 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3945 psessionEntry->htRecommendedTxWidthSet = 1;
3946 break;
3947 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003948 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003949 return;
3950 }
3951
3952 /* Update beacon */
3953 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3954 lim_send_beacon_ind(pMac, psessionEntry);
3955
3956 /* update OP Mode for each associated peer */
3957 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
3958 pStaDs = dph_get_hash_entry(pMac, staId,
3959 &psessionEntry->dph.dphHashTable);
3960 if (NULL == pStaDs)
3961 continue;
3962
3963 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303964 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003965 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003966 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003967 return;
3968 }
3969 pHtOpMode->opMode =
3970 (psessionEntry->htSecondaryChannelOffset ==
3971 PHY_SINGLE_CHANNEL_CENTERED) ?
3972 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
3973 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303974 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003975 sizeof(tSirMacAddr));
3976 pHtOpMode->smesessionId = sessionId;
3977
3978 msg.type = WMA_UPDATE_OP_MODE;
3979 msg.reserved = 0;
3980 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003981 if (!QDF_IS_STATUS_SUCCESS
3982 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
3983 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303984 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003985 return;
3986 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003987 pe_debug("Notifed FW about OP mode: %d for staId=%d",
3988 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003989
3990 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003991 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003992 }
3993
3994 return;
3995}
3996#endif
3997
3998/* -------------------------------------------------------------------- */
3999/**
4000 * __lim_process_report_message
4001 *
4002 * FUNCTION: Processes the next received Radio Resource Management message
4003 *
4004 * LOGIC:
4005 *
4006 * ASSUMPTIONS:
4007 *
4008 * NOTE:
4009 *
4010 * @param None
4011 * @return None
4012 */
4013
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004014static void __lim_process_report_message(tpAniSirGlobal pMac,
4015 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004016{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004017 switch (pMsg->type) {
4018 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4019 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4020 break;
4021 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004022 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004023 break;
4024 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004025 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004026 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004027}
4028
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004029/* -------------------------------------------------------------------- */
4030/**
4031 * lim_send_set_max_tx_power_req
4032 *
4033 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4034 *
4035 * LOGIC:
4036 *
4037 * ASSUMPTIONS:
4038 *
4039 * NOTE:
4040 *
4041 * @param txPower txPower to be set.
4042 * @param pSessionEntry session entry.
4043 * @return None
4044 */
4045tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004046lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004047 tpPESession pSessionEntry)
4048{
4049 tpMaxTxPowerParams pMaxTxParams = NULL;
4050 tSirRetStatus retCode = eSIR_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004051 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004052
4053 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004054 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004055 return eSIR_FAILURE;
4056 }
4057
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304058 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004059 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004060 pe_err("Unable to allocate memory for pMaxTxParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004061 return eSIR_MEM_ALLOC_FAILED;
4062
4063 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004064 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304065 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304066 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304067 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004068 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304069 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004070
4071 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4072 msgQ.bodyptr = pMaxTxParams;
4073 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004074 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004075 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4076 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4077 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004078 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304079 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004080 }
4081 return retCode;
4082}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004083
4084/**
4085 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4086 *
4087 * @mac_ctx: Pointer to Global MAC structure
4088 * @msg_buf: pointer to the SME message buffer
4089 *
4090 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4091 * from SME. It Register this information within PE.
4092 *
4093 * Return: None
4094 */
4095static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4096 uint32_t *msg_buf)
4097{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304098 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004099 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4100 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4101 struct mgmt_frm_reg_info *next = NULL;
4102 bool match = false;
4103
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004104 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004105 sme_req->registerFrame, sme_req->frameType,
4106 sme_req->matchLen);
4107 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304108 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304109 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4110 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304111 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004112
4113 while (lim_mgmt_regn != NULL) {
4114 if (lim_mgmt_regn->frameType != sme_req->frameType)
4115 goto skip_match;
4116 if (sme_req->matchLen) {
4117 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304118 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004119 sme_req->matchData,
4120 lim_mgmt_regn->matchLen))) {
4121 /* found match! */
4122 match = true;
4123 break;
4124 }
4125 } else {
4126 /* found match! */
4127 match = true;
4128 break;
4129 }
4130skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304131 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304132 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004133 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304134 (qdf_list_node_t *)lim_mgmt_regn,
4135 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304136 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004137 lim_mgmt_regn = next;
4138 next = NULL;
4139 }
4140 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304141 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004142 if (QDF_STATUS_SUCCESS ==
4143 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004144 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004145 (qdf_list_node_t *)lim_mgmt_regn))
4146 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304147 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004148 }
4149
4150 if (sme_req->registerFrame) {
4151 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304152 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004153 sme_req->matchLen);
4154 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004155 lim_mgmt_regn->frameType = sme_req->frameType;
4156 lim_mgmt_regn->matchLen = sme_req->matchLen;
4157 lim_mgmt_regn->sessionId = sme_req->sessionId;
4158 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304159 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004160 sme_req->matchData,
4161 sme_req->matchLen);
4162 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304163 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004164 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304165 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004166 gLimMgmtFrameRegistratinQueue,
4167 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304168 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004169 &mac_ctx->lim.lim_frame_register_lock);
4170 }
4171 }
4172 return;
4173}
4174
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004175static void
4176__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4177{
4178 tpSirResetAPCapsChange pResetCapsChange;
4179 tpPESession psessionEntry;
4180 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004181
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004182 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004183 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004184 return;
4185 }
4186
4187 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4188 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004189 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4190 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004191 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004192 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004193 return;
4194 }
4195
4196 psessionEntry->limSentCapsChangeNtf = false;
4197 return;
4198}
4199
4200/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304201 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4202 * indication callback in PE.
4203 * @mac_ptr: Mac pointer
4204 * @msg_buf: Msg pointer containing the callback
4205 *
4206 * This function is used save the Management frame
4207 * indication callback in PE.
4208 *
4209 * Return: None
4210 */
4211static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4212 uint32_t *msg_buf)
4213{
4214 struct sir_sme_mgmt_frame_cb_req *sme_req =
4215 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4216
4217 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004218 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304219 return;
4220 }
4221 if (sme_req->callback)
4222 mac_ctx->mgmt_frame_ind_cb =
4223 (sir_mgmt_frame_ind_callback)sme_req->callback;
4224 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004225 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304226}
4227
4228/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304229 *__lim_process_send_disassoc_frame: function processes disassoc frame
4230 * @mac_ctx: pointer to mac context
4231 * @msg_buf: message buffer
4232 *
4233 * function processes disassoc request received from SME
4234 *
4235 * return: none
4236 */
4237static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4238 uint32_t *msg_buf)
4239{
4240 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4241 tSirRetStatus status;
4242 tpPESession session_entry = NULL;
4243 uint8_t sme_session_id;
4244 uint16_t sme_trans_id;
4245
4246 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004247 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304248 return;
4249 }
4250
4251 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4252 &sme_trans_id);
4253
4254 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4255 &sme_send_disassoc_frame_req,
4256 (uint8_t *)msg_buf);
4257
4258 if ((eSIR_FAILURE == status) ||
4259 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4260 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004261 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304262 return;
4263 }
4264
4265 session_entry = pe_find_session_by_sme_session_id(
4266 mac_ctx, sme_session_id);
4267 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004268 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304269 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4270 return;
4271 }
4272
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004273 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 +05304274 sme_send_disassoc_frame_req.msg_type,
4275 sme_send_disassoc_frame_req.length,
4276 sme_send_disassoc_frame_req.session_id,
4277 sme_send_disassoc_frame_req.trans_id,
4278 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4279 sme_send_disassoc_frame_req.reason,
4280 sme_send_disassoc_frame_req.wait_for_ack);
4281
4282 lim_send_disassoc_mgmt_frame(mac_ctx,
4283 sme_send_disassoc_frame_req.reason,
4284 sme_send_disassoc_frame_req.peer_mac,
4285 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4286}
4287
4288/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004289 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4290 * @mac_ctx: Pointer to Global MAC structure
4291 * @pdev_id: pdev id to set the IE.
4292 * @nss: Nss values to prepare the HT IE.
4293 *
4294 * Prepares the HT IE with self capabilities for different
4295 * Nss values and sends the set HT IE req to FW.
4296 *
4297 * Return: None
4298 */
4299static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4300 uint8_t nss)
4301{
4302 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004303 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004304 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004305 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004306 tHtCaps *p_ht_cap;
4307 int i;
4308
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004309 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004310 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4311 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004312 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004313 return;
4314 }
4315 ie_params->nss = i;
4316 ie_params->pdev_id = pdev_id;
4317 ie_params->ie_type = DOT11_HT_IE;
4318 /* 2 for IE len and EID */
4319 ie_params->ie_len = 2 + sizeof(tHtCaps);
4320 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4321 if (NULL == ie_params->ie_ptr) {
4322 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004323 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004324 return;
4325 }
4326 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4327 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4328 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4329 ie_params->ie_len);
4330
4331 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004332 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4333 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004334 if (NULL == p_ie) {
4335 qdf_mem_free(ie_params->ie_ptr);
4336 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004337 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004338 return;
4339 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004340 p_ht_cap = (tHtCaps *)&p_ie[2];
4341 p_ht_cap->supportedMCSSet[1] = 0;
4342 p_ht_cap->txSTBC = 0;
4343 }
4344
4345 msg.type = WMA_SET_PDEV_IE_REQ;
4346 msg.bodyptr = ie_params;
4347 msg.bodyval = 0;
4348
4349 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4350 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004351 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004352 qdf_mem_free(ie_params->ie_ptr);
4353 qdf_mem_free(ie_params);
4354 return;
4355 }
4356 }
4357}
4358
4359/**
4360 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4361 * @mac_ctx: Pointer to Global MAC structure
4362 * @pdev_id: pdev id to set the IE.
4363 * @nss: Nss values to prepare the VHT IE.
4364 *
4365 * Prepares the VHT IE with self capabilities for different
4366 * Nss values and sends the set VHT IE req to FW.
4367 *
4368 * Return: None
4369 */
4370static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4371 uint8_t nss)
4372{
4373 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004374 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004375 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004376 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004377 tSirMacVHTCapabilityInfo *vht_cap;
4378 int i;
4379 tSirVhtMcsInfo *vht_mcs;
4380
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004381 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004382 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4383 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004384 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004385 return;
4386 }
4387 ie_params->nss = i;
4388 ie_params->pdev_id = pdev_id;
4389 ie_params->ie_type = DOT11_VHT_IE;
4390 /* 2 for IE len and EID */
4391 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4392 sizeof(tSirVhtMcsInfo);
4393 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4394 if (NULL == ie_params->ie_ptr) {
4395 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004396 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004397 return;
4398 }
4399 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4400 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4401 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4402 ie_params->ie_len);
4403
4404 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004405 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4406 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004407 if (NULL == p_ie) {
4408 qdf_mem_free(ie_params->ie_ptr);
4409 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004410 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004411 return;
4412 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004413 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4414 vht_cap->txSTBC = 0;
4415 vht_mcs =
4416 (tSirVhtMcsInfo *)&p_ie[2 +
4417 sizeof(tSirMacVHTCapabilityInfo)];
4418 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4419 vht_mcs->rxHighest =
4420 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4421 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4422 vht_mcs->txHighest =
4423 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4424 }
4425 msg.type = WMA_SET_PDEV_IE_REQ;
4426 msg.bodyptr = ie_params;
4427 msg.bodyval = 0;
4428
4429 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4430 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004431 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004432 qdf_mem_free(ie_params->ie_ptr);
4433 qdf_mem_free(ie_params);
4434 return;
4435 }
4436 }
4437}
4438
4439/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004440 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4441 * @mac_ctx: Pointer to Global MAC structure
4442 * @msg_buf: Pointer to the SME message buffer
4443 *
4444 * This function is called by limProcessMessageQueue(). This function sets the
4445 * VDEV IEs to the FW.
4446 *
4447 * Return: None
4448 */
4449static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4450 uint32_t *msg_buf)
4451{
4452 struct sir_set_vdev_ies_per_band *p_msg =
4453 (struct sir_set_vdev_ies_per_band *)msg_buf;
4454
4455 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004456 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004457 return;
4458 }
4459
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004460 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004461 p_msg->vdev_id);
4462 /* intentionally using NULL here so that self capabilty are sent */
4463 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4464 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004465 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004466}
4467
4468/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004469 * lim_process_set_pdev_IEs() - process the set pdev IE req
4470 * @mac_ctx: Pointer to Global MAC structure
4471 * @msg_buf: Pointer to the SME message buffer
4472 *
4473 * This function is called by limProcessMessageQueue(). This
4474 * function sets the PDEV IEs to the FW.
4475 *
4476 * Return: None
4477 */
4478static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4479{
4480 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4481
4482 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4483
4484 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004485 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004486 return;
4487 }
4488
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004489 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004490 ht_vht_cfg->nss);
4491 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4492
4493 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4494 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4495 ht_vht_cfg->nss);
4496}
4497
4498/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304499 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4500 *
4501 * access policy
4502 * @mac_ctx: pointer to mac context
4503 * @msg: message buffer
4504 *
4505 * function processes vendor IE and access policy from SME and updates PE
4506 *
4507 * session entry
4508 *
4509 * return: none
4510*/
4511static void lim_process_sme_update_access_policy_vendor_ie(
4512 tpAniSirGlobal mac_ctx,
4513 uint32_t *msg)
4514{
4515 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4516 struct sPESession *pe_session_entry;
Pragaspathi Thilagaraj9b7a1162018-05-07 16:28:13 +05304517 uint16_t num_bytes;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304518
4519 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004520 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304521 return;
4522 }
4523 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4524 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4525 update_vendor_ie->sme_session_id);
4526
4527 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004528 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304529 update_vendor_ie->sme_session_id);
4530 return;
4531 }
4532 if (pe_session_entry->access_policy_vendor_ie)
4533 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4534
4535 num_bytes = update_vendor_ie->ie[1] + 2;
4536 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4537
4538 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004539 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304540 return;
4541 }
4542 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4543 &update_vendor_ie->ie[0], num_bytes);
4544
4545 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4546}
4547
4548/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004549 * lim_process_sme_req_messages()
4550 *
4551 ***FUNCTION:
4552 * This function is called by limProcessMessageQueue(). This
4553 * function processes SME request messages from HDD or upper layer
4554 * application.
4555 *
4556 ***LOGIC:
4557 *
4558 ***ASSUMPTIONS:
4559 *
4560 ***NOTE:
4561 *
4562 * @param pMac Pointer to Global MAC structure
4563 * @param msgType Indicates the SME message type
4564 * @param *pMsgBuf A pointer to the SME message buffer
4565 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4566 * false - if pMsgBuf is not to be freed.
4567 */
4568
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004569bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4570 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004571{
Jeff Johnson33142e62018-05-06 17:58:36 -07004572 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 -08004573 uint32_t *pMsgBuf = pMsg->bodyptr;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004574
4575 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004576 lim_msg_str(pMsg->type), pMsg->type,
4577 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4578 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004579
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004580 /* If no insert NOA required then execute the code below */
4581
4582 switch (pMsg->type) {
4583 case eWNI_SME_SYS_READY_IND:
4584 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4585 break;
4586
4587 case eWNI_SME_START_BSS_REQ:
4588 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4589 break;
4590
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004591 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4592 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4593 break;
4594 case eWNI_SME_JOIN_REQ:
4595 __lim_process_sme_join_req(pMac, pMsgBuf);
4596 break;
4597
4598 case eWNI_SME_REASSOC_REQ:
4599 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4600 break;
4601
4602 case eWNI_SME_DISASSOC_REQ:
4603 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4604 break;
4605
4606 case eWNI_SME_DISASSOC_CNF:
4607 case eWNI_SME_DEAUTH_CNF:
4608 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4609 break;
4610
4611 case eWNI_SME_DEAUTH_REQ:
4612 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4613 break;
4614
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304615 case eWNI_SME_SEND_DISASSOC_FRAME:
4616 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4617 break;
4618
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004619 case eWNI_SME_SETCONTEXT_REQ:
4620 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4621 break;
4622
4623 case eWNI_SME_STOP_BSS_REQ:
4624 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4625 break;
4626
4627 case eWNI_SME_ASSOC_CNF:
4628 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004629 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004630 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4631 pMsgBuf);
4632 break;
4633
4634 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004635 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004636 __lim_process_sme_addts_req(pMac, pMsgBuf);
4637 break;
4638
4639 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004640 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004641 __lim_process_sme_delts_req(pMac, pMsgBuf);
4642 break;
4643
4644 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004645 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004646 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4647 break;
4648
4649 case eWNI_SME_GET_STATISTICS_REQ:
4650 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4651 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4652 bufConsumed = false;
4653 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004654#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004655 case eWNI_SME_GET_TSM_STATS_REQ:
4656 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4657 bufConsumed = false;
4658 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004659#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004660 case eWNI_SME_GET_ASSOC_STAS_REQ:
4661 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4662 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304663 case eWNI_SME_SESSION_UPDATE_PARAM:
4664 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004665 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304666 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4667 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4668 bufConsumed = false;
4669 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004670 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4671 /* Update the beaconInterval */
4672 __lim_process_sme_change_bi(pMac, pMsgBuf);
4673 break;
4674
4675#ifdef QCA_HT_2040_COEX
4676 case eWNI_SME_SET_HT_2040_MODE:
4677 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4678 break;
4679#endif
4680
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004681 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4682 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4683 __lim_process_report_message(pMac, pMsg);
4684 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004685
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004686 case eWNI_SME_FT_PRE_AUTH_REQ:
4687 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4688 break;
4689 case eWNI_SME_FT_UPDATE_KEY:
4690 lim_process_ft_update_key(pMac, pMsgBuf);
4691 break;
4692
4693 case eWNI_SME_FT_AGGR_QOS_REQ:
4694 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4695 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004696
4697 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4698 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4699 break;
4700#ifdef FEATURE_WLAN_TDLS
4701 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4702 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4703 break;
4704 case eWNI_SME_TDLS_ADD_STA_REQ:
4705 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4706 break;
4707 case eWNI_SME_TDLS_DEL_STA_REQ:
4708 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4709 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004710#endif
4711 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4712 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4713 break;
4714
4715 case eWNI_SME_CHANNEL_CHANGE_REQ:
4716 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4717 break;
4718
4719 case eWNI_SME_START_BEACON_REQ:
4720 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4721 break;
4722
4723 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4724 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4725 break;
4726
4727 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4728 lim_process_update_add_ies(pMac, pMsgBuf);
4729 break;
4730
4731 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4732 lim_process_modify_add_ies(pMac, pMsgBuf);
4733 break;
4734 case eWNI_SME_SET_HW_MODE_REQ:
4735 lim_process_set_hw_mode(pMac, pMsgBuf);
4736 break;
4737 case eWNI_SME_NSS_UPDATE_REQ:
4738 lim_process_nss_update_request(pMac, pMsgBuf);
4739 break;
4740 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4741 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4742 break;
4743 case eWNI_SME_SET_IE_REQ:
4744 lim_process_set_ie_req(pMac, pMsgBuf);
4745 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304746 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4747 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
4748 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304749 case eWNI_SME_EXT_CHANGE_CHANNEL:
4750 lim_process_ext_change_channel(pMac, pMsgBuf);
4751 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08004752 case eWNI_SME_SET_ANTENNA_MODE_REQ:
4753 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
4754 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004755 case eWNI_SME_PDEV_SET_HT_VHT_IE:
4756 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07004757 break;
4758 case eWNI_SME_SET_VDEV_IES_PER_BAND:
4759 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
4760 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304761 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
4762 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
4763 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07004764 case eWNI_SME_UPDATE_CONFIG:
4765 lim_process_sme_update_config(pMac,
4766 (struct update_config *)pMsgBuf);
4767 break;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004768 case eWNI_SME_SET_ADDBA_ACCEPT:
4769 lim_process_sme_set_addba_accept(pMac,
4770 (struct sme_addba_accept *)pMsgBuf);
4771 break;
Arif Hussaineb8ba362018-03-07 19:15:13 -08004772 case eWNI_SME_UPDATE_EDCA_PROFILE:
4773 lim_process_sme_update_edca_params(pMac, pMsg->bodyval);
4774 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004775 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304776 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004777 pMsg->bodyptr = NULL;
4778 break;
4779 } /* switch (msgType) */
4780
4781 return bufConsumed;
4782} /*** end lim_process_sme_req_messages() ***/
4783
4784/**
4785 * lim_process_sme_start_beacon_req()
4786 *
4787 ***FUNCTION:
4788 * This function is called by limProcessMessageQueue(). This
4789 * function processes SME request messages from HDD or upper layer
4790 * application.
4791 *
4792 ***LOGIC:
4793 *
4794 ***ASSUMPTIONS:
4795 *
4796 ***NOTE:
4797 *
4798 * @param pMac Pointer to Global MAC structure
4799 * @param msgType Indicates the SME message type
4800 * @param *pMsgBuf A pointer to the SME message buffer
4801 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4802 * false - if pMsgBuf is not to be freed.
4803 */
4804static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
4805{
4806 tpSirStartBeaconIndication pBeaconStartInd;
4807 tpPESession psessionEntry;
4808 uint8_t sessionId; /* PE sessionID */
4809
4810 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004811 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004812 return;
4813 }
4814
4815 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
4816 psessionEntry = pe_find_session_by_bssid(pMac,
4817 pBeaconStartInd->bssid,
4818 &sessionId);
4819 if (psessionEntry == NULL) {
4820 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004821 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004822 return;
4823 }
4824
4825 if (pBeaconStartInd->beaconStartStatus == true) {
4826 /*
4827 * Currently this Indication comes from SAP
4828 * to start Beacon Tx on a DFS channel
4829 * since beaconing has to be done on DFS
4830 * channel only after CAC WAIT is completed.
4831 * On a DFS Channel LIM does not start beacon
4832 * Tx right after the WMA_ADD_BSS_RSP.
4833 */
4834 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05304835 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004836 FL("Start Beacon with ssid %s Ch %d"),
4837 psessionEntry->ssId.ssId,
4838 psessionEntry->currentOperChannel);
4839 lim_send_beacon_ind(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08004840 lim_enable_obss_detection_config(pMac, psessionEntry);
Arif Hussain05fb4872018-01-03 16:02:55 -08004841 lim_send_obss_color_collision_cfg(pMac, psessionEntry,
4842 OBSS_COLOR_COLLISION_DETECTION);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004843 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004844 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004845 return;
4846 }
4847}
4848
4849/**
4850 * lim_process_sme_channel_change_request() - process sme ch change req
4851 *
4852 * @mac_ctx: Pointer to Global MAC structure
4853 * @msg_buf: pointer to the SME message buffer
4854 *
4855 * This function is called to process SME_CHANNEL_CHANGE_REQ message
4856 *
4857 * Return: None
4858 */
4859static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
4860 uint32_t *msg_buf)
4861{
4862 tpSirChanChangeRequest ch_change_req;
4863 tpPESession session_entry;
4864 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07004865 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004866 uint32_t val = 0;
4867
4868 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004869 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004870 return;
4871 }
4872 ch_change_req = (tpSirChanChangeRequest)msg_buf;
4873
4874 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
4875 ch_change_req->targetChannel);
4876
4877 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
4878 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004879 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004880 return;
4881 }
4882
4883 session_entry = pe_find_session_by_bssid(mac_ctx,
4884 ch_change_req->bssid, &session_id);
4885 if (session_entry == NULL) {
4886 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004887 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004888 return;
4889 }
4890
Manjunathappa Prakash34fda792018-02-07 18:23:42 -08004891 if ((session_entry->currentOperChannel ==
4892 ch_change_req->targetChannel) &&
4893 (session_entry->ch_width == ch_change_req->ch_width)) {
4894 pe_err("Target channel and mode is same as current channel and mode channel %d and mode %d",
4895 session_entry->currentOperChannel, session_entry->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004896 return;
4897 }
4898
4899 if (LIM_IS_AP_ROLE(session_entry))
4900 session_entry->channelChangeReasonCode =
4901 LIM_SWITCH_CHANNEL_SAP_DFS;
4902 else
4903 session_entry->channelChangeReasonCode =
4904 LIM_SWITCH_CHANNEL_OPERATION;
4905
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004906 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004907 session_entry->currentOperChannel,
4908 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004909 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004910
4911 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004912 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004913 session_entry->ch_center_freq_seg0 =
4914 ch_change_req->center_freq_seg_0;
4915 session_entry->ch_center_freq_seg1 =
4916 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004917 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004918 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004919 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004920 session_entry->htRecommendedTxWidthSet =
4921 session_entry->htSupportedChannelWidthSet;
4922 session_entry->currentOperChannel =
4923 ch_change_req->targetChannel;
4924 session_entry->limRFBand =
4925 lim_get_rf_band(session_entry->currentOperChannel);
Vignesh Viswanathan153ae932018-04-11 14:24:13 +05304926
4927 /* Update the global beacon filter */
4928 lim_update_bcn_probe_filter(mac_ctx, session_entry);
4929
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004930 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08004931 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004932 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004933 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
4934 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004935 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004936 }
4937
4938 session_entry->lim11hEnable = val;
4939 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304940 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004941 &ch_change_req->operational_rateset,
4942 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304943 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004944 &ch_change_req->extended_rateset,
4945 sizeof(session_entry->extRateSet));
4946 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
4947 session_entry->ch_center_freq_seg0,
4948 session_entry->ch_center_freq_seg1,
4949 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07004950 max_tx_pwr, session_entry->peSessionId,
4951 ch_change_req->cac_duration_ms,
4952 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004953}
4954
4955/******************************************************************************
4956* lim_start_bss_update_add_ie_buffer()
4957*
4958***FUNCTION:
4959* This function checks the src buffer and its length and then malloc for
4960* dst buffer update the same
4961*
4962***LOGIC:
4963*
4964***ASSUMPTIONS:
4965*
4966***NOTE:
4967*
4968* @param pMac Pointer to Global MAC structure
4969* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
4970* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
4971* @param *pSrcData_buff A pointer of uint8_t src buffer
4972* @param srcDataLen src buffer length
4973******************************************************************************/
4974
4975static void
4976lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
4977 uint8_t **pDstData_buff,
4978 uint16_t *pDstDataLen,
4979 uint8_t *pSrcData_buff, uint16_t srcDataLen)
4980{
4981
4982 if (srcDataLen > 0 && pSrcData_buff != NULL) {
4983 *pDstDataLen = srcDataLen;
4984
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304985 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004986
4987 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004988 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004989 return;
4990 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304991 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004992 } else {
4993 *pDstData_buff = NULL;
4994 *pDstDataLen = 0;
4995 }
4996}
4997
4998/******************************************************************************
4999* lim_update_add_ie_buffer()
5000*
5001***FUNCTION:
5002* This function checks the src buffer and length if src buffer length more
5003* than dst buffer length then free the dst buffer and malloc for the new src
5004* length, and update the dst buffer and length. But if dst buffer is bigger
5005* than src buffer length then it just update the dst buffer and length
5006*
5007***LOGIC:
5008*
5009***ASSUMPTIONS:
5010*
5011***NOTE:
5012*
5013* @param pMac Pointer to Global MAC structure
5014* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5015* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5016* @param *pSrcData_buff A pointer of uint8_t src buffer
5017* @param srcDataLen src buffer length
5018******************************************************************************/
5019
5020static void
5021lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5022 uint8_t **pDstData_buff,
5023 uint16_t *pDstDataLen,
5024 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5025{
5026
5027 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005028 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005029 return;
5030 }
5031
5032 if (srcDataLen > *pDstDataLen) {
5033 *pDstDataLen = srcDataLen;
5034 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305035 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005036 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305037 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005038
5039 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005040 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005041 *pDstDataLen = 0;
5042 return;
5043 }
5044 }
5045
5046 /* copy the content of buffer into dst buffer
5047 */
5048 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305049 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005050
5051}
5052
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005053/**
5054 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5055 * @pMac : Pointer to Global MAC structure
5056 * @pDstData_buff : A pointer to pointer of dst buffer
5057 * @pDstDataLen : A pointer to pointer of dst buffer length
5058 * @pModifyIE : A pointer to tSirModifyIE
5059 *
5060 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5061 *
5062 * Return:
5063 * True or false depending upon whether IE is updated or not
5064 */
5065static bool
5066lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5067 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5068{
Hong Shi1553d692016-09-28 12:16:19 +08005069 int32_t oui_length;
5070 uint8_t *ibss_ie = NULL;
5071 uint8_t *vendor_ie;
5072#define MAC_VENDOR_OUI "\x00\x16\x32"
5073#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005074
5075 ibss_ie = pModifyIE->pIEBuffer;
5076 oui_length = pModifyIE->oui_length;
5077
5078 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005079 pe_err("Invalid set IBSS vendor IE command length %d",
5080 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005081 return false;
5082 }
5083
Hong Shi1553d692016-09-28 12:16:19 +08005084 /*
5085 * Why replace only beacon OUI data here:
5086 * 1. other ie (such as wpa) shall not be overwritten here.
5087 * 2. per spec, beacon oui ie might be set twice and original one
5088 * shall be updated.
5089 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005090 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005091 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5092 if (vendor_ie) {
5093 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5094 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5095 pModifyIE->ieBufferlength);
5096 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005097 uint16_t new_length;
5098 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005099
Naveen Rawat668dee32017-09-29 14:39:40 -07005100 /*
5101 * check for uint16 overflow before using sum of two numbers as
5102 * length of size to malloc
5103 */
5104 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5105 pe_err("U16 overflow due to %d + %d",
5106 pModifyIE->ieBufferlength, *pDstDataLen);
5107 return false;
5108 }
5109
5110 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5111 new_ptr = qdf_mem_malloc(new_length);
Hong Shi1553d692016-09-28 12:16:19 +08005112 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005113 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005114 return false;
5115 }
5116 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5117 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5118 pModifyIE->ieBufferlength);
5119 qdf_mem_free(*pDstData_buff);
5120 *pDstDataLen = new_length;
5121 *pDstData_buff = new_ptr;
5122 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005123 return true;
5124}
5125
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005126/*
5127* lim_process_modify_add_ies() - process modify additional IE req.
5128*
5129* @mac_ctx: Pointer to Global MAC structure
5130* @msg_buf: pointer to the SME message buffer
5131*
5132* This function update the PE buffers for additional IEs.
5133*
5134* Return: None
5135*/
5136static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5137 uint32_t *msg_buf)
5138{
5139 tpSirModifyIEsInd modify_add_ies;
5140 tpPESession session_entry;
5141 uint8_t session_id;
5142 bool ret = false;
5143 tSirAddIeParams *add_ie_params;
5144
5145 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005146 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005147 return;
5148 }
5149
5150 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5151 /* Incoming message has smeSession, use BSSID to find PE session */
5152 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005153 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005154
5155 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005156 pe_err("Session not found for given bssid"
5157 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005158 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005159 goto end;
5160 }
5161 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5162 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5163 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005164 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005165 modify_add_ies->modifyIE.pIEBuffer,
5166 modify_add_ies->modifyIE.ieBufferlength,
5167 modify_add_ies->modifyIE.ieID,
5168 modify_add_ies->modifyIE.ieIDLen,
5169 modify_add_ies->updateType);
5170 goto end;
5171 }
5172 add_ie_params = &session_entry->addIeParams;
5173 switch (modify_add_ies->updateType) {
5174 case eUPDATE_IE_PROBE_RESP:
5175 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005176 if (LIM_IS_IBSS_ROLE(session_entry)) {
5177 lim_update_ibss_prop_add_ies(mac_ctx,
5178 &add_ie_params->probeRespData_buff,
5179 &add_ie_params->probeRespDataLen,
5180 &modify_add_ies->modifyIE);
5181 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005182 break;
5183 case eUPDATE_IE_ASSOC_RESP:
5184 /* assoc resp IE */
5185 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305186 QDF_TRACE(QDF_MODULE_ID_PE,
5187 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005188 "assoc resp add ie not present %d"),
5189 add_ie_params->assocRespDataLen);
5190 }
5191 /* search through the buffer and modify the IE */
5192 break;
5193 case eUPDATE_IE_PROBE_BCN:
5194 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005195 if (LIM_IS_IBSS_ROLE(session_entry)) {
5196 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5197 &add_ie_params->probeRespBCNData_buff,
5198 &add_ie_params->probeRespBCNDataLen,
5199 &modify_add_ies->modifyIE);
5200 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005201 if (ret == true && modify_add_ies->modifyIE.notify) {
5202 lim_handle_param_update(mac_ctx,
5203 modify_add_ies->updateType);
5204 }
5205 break;
5206 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005207 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005208 modify_add_ies->updateType);
5209 break;
5210 }
5211end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305212 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005213 modify_add_ies->modifyIE.pIEBuffer = NULL;
5214}
5215
5216/*
5217* lim_process_update_add_ies() - process additional IE update req
5218*
5219* @mac_ctx: Pointer to Global MAC structure
5220* @msg_buf: pointer to the SME message buffer
5221*
5222* This function update the PE buffers for additional IEs.
5223*
5224* Return: None
5225*/
5226static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5227 uint32_t *msg_buf)
5228{
5229 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5230 uint8_t session_id;
5231 tpPESession session_entry;
5232 tSirAddIeParams *addn_ie;
5233 uint16_t new_length = 0;
5234 uint8_t *new_ptr = NULL;
5235 tSirUpdateIE *update_ie;
5236
5237 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005238 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005239 return;
5240 }
5241 update_ie = &update_add_ies->updateIE;
5242 /* incoming message has smeSession, use BSSID to find PE session */
5243 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005244 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005245
5246 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005247 pe_err("Session not found for given bssid"
5248 MAC_ADDRESS_STR,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005249 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005250 goto end;
5251 }
5252 addn_ie = &session_entry->addIeParams;
5253 /* if len is 0, upper layer requested freeing of buffer */
5254 if (0 == update_ie->ieBufferlength) {
5255 switch (update_add_ies->updateType) {
5256 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305257 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005258 addn_ie->probeRespData_buff = NULL;
5259 addn_ie->probeRespDataLen = 0;
5260 break;
5261 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305262 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005263 addn_ie->assocRespData_buff = NULL;
5264 addn_ie->assocRespDataLen = 0;
5265 break;
5266 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305267 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005268 addn_ie->probeRespBCNData_buff = NULL;
5269 addn_ie->probeRespBCNDataLen = 0;
5270
5271 if (update_ie->notify)
5272 lim_handle_param_update(mac_ctx,
5273 update_add_ies->updateType);
5274 break;
5275 default:
5276 break;
5277 }
5278 return;
5279 }
5280 switch (update_add_ies->updateType) {
5281 case eUPDATE_IE_PROBE_RESP:
5282 if (update_ie->append) {
5283 /*
5284 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005285 * with combined length.
5286 * Multiple back to back append commands
5287 * can lead to a huge length.So, check
5288 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005289 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005290 if (addn_ie->probeRespDataLen >
5291 (USHRT_MAX - update_ie->ieBufferlength)) {
5292 pe_err("IE Length overflow, curr:%d, new:%d",
5293 addn_ie->probeRespDataLen,
5294 update_ie->ieBufferlength);
5295 goto end;
5296 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005297 new_length = update_ie->ieBufferlength +
5298 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305299 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005300 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005301 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005302 goto end;
5303 }
5304 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305305 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005306 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305307 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005308 update_ie->pAdditionIEBuffer,
5309 update_ie->ieBufferlength);
5310 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305311 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005312 /* adjust length accordingly */
5313 addn_ie->probeRespDataLen = new_length;
5314 /* save refernece of local buffer in PE session */
5315 addn_ie->probeRespData_buff = new_ptr;
5316 goto end;
5317 }
5318 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5319 &addn_ie->probeRespDataLen,
5320 update_ie->pAdditionIEBuffer,
5321 update_ie->ieBufferlength);
5322 break;
5323 case eUPDATE_IE_ASSOC_RESP:
5324 /* assoc resp IE */
5325 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5326 &addn_ie->assocRespDataLen,
5327 update_ie->pAdditionIEBuffer,
5328 update_ie->ieBufferlength);
5329 break;
5330 case eUPDATE_IE_PROBE_BCN:
5331 /* probe resp Bcn IE */
5332 lim_update_add_ie_buffer(mac_ctx,
5333 &addn_ie->probeRespBCNData_buff,
5334 &addn_ie->probeRespBCNDataLen,
5335 update_ie->pAdditionIEBuffer,
5336 update_ie->ieBufferlength);
5337 if (update_ie->notify)
5338 lim_handle_param_update(mac_ctx,
5339 update_add_ies->updateType);
5340 break;
5341 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005342 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005343 break;
5344 }
5345end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305346 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005347 update_ie->pAdditionIEBuffer = NULL;
5348}
5349
5350/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305351 * send_extended_chan_switch_action_frame()- function to send ECSA
5352 * action frame for each sta connected to SAP/GO and AP in case of
5353 * STA .
5354 * @mac_ctx: pointer to global mac structure
5355 * @new_channel: new channel to switch to.
5356 * @ch_bandwidth: BW of channel to calculate op_class
5357 * @session_entry: pe session
5358 *
5359 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5360 *
5361 * Return: void
5362 */
5363
5364static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5365 uint16_t new_channel, uint8_t ch_bandwidth,
5366 tpPESession session_entry)
5367{
5368 uint16_t op_class;
5369 uint8_t switch_mode = 0, i;
5370 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005371 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305372
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005373 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305374 mac_ctx->scan.countryCodeCurrent,
5375 new_channel,
5376 ch_bandwidth);
5377
5378 if (LIM_IS_AP_ROLE(session_entry) &&
5379 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005380 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305381
gaoleze2920bd2017-03-21 17:38:42 +08005382 switch_count = session_entry->gLimChannelSwitch.switchCount;
5383
Abhishek Singh518323d2015-10-19 17:42:01 +05305384 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005385 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305386 psta =
5387 session_entry->dph.dphHashTable.pDphNodeArray + i;
5388 if (psta && psta->added)
5389 lim_send_extended_chan_switch_action_frame(
5390 mac_ctx,
5391 psta->staAddr,
5392 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005393 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305394 }
5395 } else if (LIM_IS_STA_ROLE(session_entry)) {
5396 lim_send_extended_chan_switch_action_frame(mac_ctx,
5397 session_entry->bssId,
5398 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005399 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305400 }
5401
5402}
5403
gaolez76d2a162017-03-21 19:23:58 +08005404void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5405 uint16_t new_channel,
5406 uint8_t ch_bandwidth,
5407 tpPESession session_entry)
5408{
5409 uint16_t op_class;
5410 uint8_t switch_mode = 0, i;
5411 uint8_t switch_count;
5412 tpDphHashNode psta;
5413 tpDphHashNode dph_node_array_ptr;
5414
5415 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5416
5417 op_class = wlan_reg_dmn_get_opclass_from_channel(
5418 mac_ctx->scan.countryCodeCurrent,
5419 new_channel, ch_bandwidth);
5420
5421 if (LIM_IS_AP_ROLE(session_entry) &&
5422 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5423 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5424
5425 switch_count = session_entry->gLimChannelSwitch.switchCount;
5426
5427 if (LIM_IS_AP_ROLE(session_entry)) {
5428 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5429 psta = dph_node_array_ptr + i;
5430 if (!(psta && psta->added))
5431 continue;
5432 if (session_entry->lim_non_ecsa_cap_num == 0)
5433 lim_send_extended_chan_switch_action_frame
5434 (mac_ctx, psta->staAddr, switch_mode,
5435 op_class, new_channel, switch_count,
5436 session_entry);
5437 else
5438 lim_send_channel_switch_mgmt_frame
5439 (mac_ctx, psta->staAddr, switch_mode,
5440 new_channel, switch_count,
5441 session_entry);
5442 }
5443 } else if (LIM_IS_STA_ROLE(session_entry)) {
5444 lim_send_extended_chan_switch_action_frame
5445 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5446 new_channel, switch_count, session_entry);
5447 }
5448}
5449
5450/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005451 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5452 *
5453 * @mac_ctx: Pointer to Global MAC structure
5454 * @msg_buf: pointer to the SME message buffer
5455 *
5456 * This function processes SME request messages from HDD or upper layer
5457 * application.
5458 *
5459 * Return: None
5460 */
5461static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5462 uint32_t *msg_buf)
5463{
5464 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5465 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005466 uint8_t session_id;
5467 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005468 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005469
5470 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005471 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005472 return;
5473 }
5474
5475 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5476 session_entry = pe_find_session_by_bssid(mac_ctx,
5477 dfs_csa_ie_req->bssid, &session_id);
5478 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005479 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005480 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5481 return;
5482 }
5483
5484 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005485 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005486 GET_LIM_SYSTEM_ROLE(session_entry));
5487 return;
5488 }
5489
5490 /* target channel */
5491 session_entry->gLimChannelSwitch.primaryChannel =
5492 dfs_csa_ie_req->targetChannel;
5493
5494 /* Channel switch announcement needs to be included in beacon */
5495 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005496 session_entry->gLimChannelSwitch.switchCount =
5497 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005498 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005499 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305500 session_entry->gLimChannelSwitch.sec_ch_offset =
5501 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005502 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005503 session_entry->gLimChannelSwitch.switchMode =
5504 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005505
5506 /*
5507 * Validate if SAP is operating HT or VHT mode and set the Channel
5508 * Switch Wrapper element with the Wide Band Switch subelement.
5509 */
5510 if (true != session_entry->vhtCapability)
5511 goto skip_vht;
5512
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005513 /* Now encode the Wider Ch BW element depending on the ch width */
5514 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005515 switch (dfs_csa_ie_req->ch_params.ch_width) {
5516 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005517 /*
5518 * Wide channel BW sublement in channel wrapper element is not
5519 * required in case of 20 Mhz operation. Currently It is set
5520 * only set in case of 40/80 Mhz Operation.
5521 */
5522 session_entry->dfsIncludeChanWrapperIe = false;
5523 wider_bw_ch_switch->newChanWidth =
5524 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5525 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005526 case CH_WIDTH_40MHZ:
5527 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005528 wider_bw_ch_switch->newChanWidth =
5529 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5530 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005531 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005532 session_entry->dfsIncludeChanWrapperIe = true;
5533 wider_bw_ch_switch->newChanWidth =
5534 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5535 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005536 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005537 session_entry->dfsIncludeChanWrapperIe = true;
5538 wider_bw_ch_switch->newChanWidth =
5539 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5540 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005541 case CH_WIDTH_80P80MHZ:
5542 session_entry->dfsIncludeChanWrapperIe = true;
5543 wider_bw_ch_switch->newChanWidth =
5544 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005545 /*
5546 * This is not applicable for 20/40/80 Mhz.
5547 * Only used when we support 80+80 Mhz operation.
5548 * In case of 80+80 Mhz, this parameter indicates
5549 * center channel frequency index of 80 Mhz channel of
5550 * frequency segment 1.
5551 */
5552 wider_bw_ch_switch->newCenterChanFreq1 =
5553 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005554 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005555 default:
5556 session_entry->dfsIncludeChanWrapperIe = false;
5557 /*
5558 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5559 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5560 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005561 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005562 break;
5563 }
5564 /* Fetch the center channel based on the channel width */
5565 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005566 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005567skip_vht:
5568 /* Send CSA IE request from here */
5569 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5570 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005571 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005572 return;
5573 }
5574
5575 /*
5576 * First beacon update request is sent here, the remaining updates are
5577 * done when the FW responds back after sending the first beacon after
5578 * the template update
5579 */
5580 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305581
5582 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5583 ch_offset = BW80;
5584 else
5585 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5586
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005587 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305588 session_entry->gLimChannelSwitch.switchCount,
5589 session_entry->gLimChannelSwitch.primaryChannel,
5590 session_entry->gLimChannelSwitch.ch_width,
5591 session_entry->dfsIncludeChanWrapperIe,
5592 ch_offset);
5593
gaolez76d2a162017-03-21 19:23:58 +08005594 /* Send ECSA/CSA Action frame after updating the beacon */
5595 if (CHAN_HOP_ALL_BANDS_ENABLE)
5596 lim_send_chan_switch_action_frame(mac_ctx,
5597 session_entry->gLimChannelSwitch.primaryChannel,
5598 ch_offset, session_entry);
5599 else
5600 send_extended_chan_switch_action_frame(mac_ctx,
5601 session_entry->gLimChannelSwitch.primaryChannel,
5602 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005603}
5604
5605/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305606 * lim_process_ext_change_channel()- function to send ECSA
5607 * action frame for STA/CLI .
5608 * @mac_ctx: pointer to global mac structure
5609 * @msg: params from sme for new channel.
5610 *
5611 * This function is called to send ECSA frame for STA/CLI.
5612 *
5613 * Return: void
5614 */
5615
5616static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5617 uint32_t *msg)
5618{
5619 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5620 (struct sir_sme_ext_cng_chan_req *) msg;
5621 tpPESession session_entry = NULL;
5622
5623 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005624 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305625 return;
5626 }
5627 session_entry =
5628 pe_find_session_by_sme_session_id(mac_ctx,
5629 ext_chng_channel->session_id);
5630 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005631 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305632 ext_chng_channel->session_id);
5633 return;
5634 }
5635 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005636 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305637 return;
5638 }
5639 send_extended_chan_switch_action_frame(mac_ctx,
5640 ext_chng_channel->new_channel,
5641 0, session_entry);
5642}
5643
5644/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005645 * lim_process_nss_update_request() - process sme nss update req
5646 *
5647 * @mac_ctx: Pointer to Global MAC structure
5648 * @msg_buf: pointer to the SME message buffer
5649 *
5650 * This function processes SME request messages from HDD or upper layer
5651 * application.
5652 *
5653 * Return: None
5654 */
5655static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5656 uint32_t *msg_buf)
5657{
5658 struct sir_nss_update_request *nss_update_req_ptr;
5659 tpPESession session_entry = NULL;
5660
5661 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005662 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005663 return;
5664 }
5665
5666 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305667 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005668 nss_update_req_ptr->vdev_id);
5669 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005670 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005671 nss_update_req_ptr->vdev_id);
5672 return;
5673 }
5674
5675 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005676 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005677 GET_LIM_SYSTEM_ROLE(session_entry));
5678 return;
5679 }
5680
5681 /* populate nss field in the beacon */
5682 session_entry->gLimOperatingMode.present = 1;
5683 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05305684 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
5685
5686 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
5687 (session_entry->ch_width > CH_WIDTH_80MHZ))
5688 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
5689
5690 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
5691
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005692 /* Send nss update request from here */
5693 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5694 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005695 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005696 return;
5697 }
5698
5699 lim_send_beacon_ind(mac_ctx, session_entry);
5700}
5701
5702/**
5703 * lim_process_set_ie_req() - process sme set IE request
5704 *
5705 * @mac_ctx: Pointer to Global MAC structure
5706 * @msg_buf: pointer to the SME message buffer
5707 *
5708 * This function processes SME request messages from HDD or upper layer
5709 * application.
5710 *
5711 * Return: None
5712 */
5713static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5714{
5715 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305716 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005717
5718 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005719 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005720 return;
5721 }
5722
5723 msg = (struct send_extcap_ie *)msg_buf;
5724 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305725 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005726 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005727
5728}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005729
5730#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Arif Hussain05fb4872018-01-03 16:02:55 -08005731
5732/**
5733 * obss_color_collision_process_color_disable() - Disable bss color
5734 * @mac_ctx: Pointer to Global MAC structure
5735 * @session: pointer to session
5736 *
5737 * This function will disbale bss color.
5738 *
5739 * Return: None
5740 */
5741static void obss_color_collision_process_color_disable(tpAniSirGlobal mac_ctx,
5742 tpPESession session)
5743{
5744 tUpdateBeaconParams beacon_params;
5745
5746 if (!session) {
5747 pe_err("Invalid session");
5748 return;
5749 }
5750
5751 if (session->valid && !LIM_IS_AP_ROLE(session)) {
5752 pe_err("Invalid SystemRole %d",
5753 GET_LIM_SYSTEM_ROLE(session));
5754 return;
5755 }
5756
5757 if (session->bss_color_changing == 1) {
5758 pe_warn("%d: color change in progress", session->smeSessionId);
5759 /* Continue color collision detection */
5760 lim_send_obss_color_collision_cfg(mac_ctx, session,
5761 OBSS_COLOR_COLLISION_DETECTION);
5762 return;
5763 }
5764
5765 if (session->he_op.bss_col_disabled == 1) {
5766 pe_warn("%d: bss color already disabled",
5767 session->smeSessionId);
5768 /* Continue free color detection */
5769 lim_send_obss_color_collision_cfg(mac_ctx, session,
5770 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5771 return;
5772 }
5773
5774 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5775 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5776 session->he_op.bss_col_disabled = 1;
Arif Hussain05fb4872018-01-03 16:02:55 -08005777 beacon_params.bss_color_disabled = 1;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005778 beacon_params.bss_color = session->he_op.bss_color;
Arif Hussain05fb4872018-01-03 16:02:55 -08005779
5780 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
5781 eSIR_SUCCESS) {
5782 pe_err("Unable to set op mode IE in beacon");
5783 return;
5784 }
5785
5786 lim_send_beacon_params(mac_ctx, &beacon_params, session);
5787 lim_send_obss_color_collision_cfg(mac_ctx, session,
5788 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5789}
5790
5791/**
5792 * obss_color_collision_process_color_change() - Process bss color change
5793 * @mac_ctx: Pointer to Global MAC structure
5794 * @session: pointer to session
5795 * @obss_color_info: obss color collision/free slot indication info
5796 *
5797 * This function selects new color ib case of bss color collision.
5798 *
5799 * Return: None
5800 */
5801static void obss_color_collision_process_color_change(tpAniSirGlobal mac_ctx,
5802 tpPESession session,
5803 struct wmi_obss_color_collision_info *obss_color_info)
5804{
5805 int i, num_bss_color = 0;
5806 uint32_t bss_color_bitmap;
5807 uint8_t bss_color_index_array[MAX_BSS_COLOR_VALUE];
5808 uint32_t rand_byte = 0;
5809 struct sir_set_he_bss_color he_bss_color;
5810 bool is_color_collision = false;
5811
5812
5813 if (session->bss_color_changing == 1) {
5814 pe_err("%d: color change in progress", session->smeSessionId);
5815 return;
5816 }
5817
5818 if (!session->he_op.bss_col_disabled) {
5819 if (session->he_op.bss_color < 32)
5820 is_color_collision = (obss_color_info->
5821 obss_color_bitmap_bit0to31 >>
5822 session->he_op.bss_color) & 0x01;
5823 else
5824 is_color_collision = (obss_color_info->
5825 obss_color_bitmap_bit32to63 >>
5826 (session->he_op.bss_color -
Arif Hussain9e8c5612018-04-12 16:35:48 -07005827 32)) & 0x01;
Arif Hussain05fb4872018-01-03 16:02:55 -08005828 if (!is_color_collision) {
5829 pe_err("%d: color collision not found, curr_color: %d",
5830 session->smeSessionId,
5831 session->he_op.bss_color);
5832 return;
5833 }
5834 }
5835
5836 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit0to31;
5837
5838 /* Skip color zero */
5839 bss_color_bitmap = bss_color_bitmap >> 1;
5840 for (i = 0; (i < 31) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5841 if (!(bss_color_bitmap & 0x01)) {
5842 bss_color_index_array[num_bss_color] = i + 1;
5843 num_bss_color++;
5844 }
5845 bss_color_bitmap = bss_color_bitmap >> 1;
5846 }
5847
5848 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit32to63;
5849 for (i = 0; (i < 32) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5850 if (!(bss_color_bitmap & 0x01)) {
5851 bss_color_index_array[num_bss_color] = i + 32;
5852 num_bss_color++;
5853 }
5854 bss_color_bitmap = bss_color_bitmap >> 1;
5855 }
5856
5857 if (num_bss_color) {
5858 qdf_get_random_bytes((void *) &rand_byte, 1);
5859 i = (rand_byte + qdf_mc_timer_get_system_ticks()) %
5860 num_bss_color;
5861 pe_debug("New bss color = %d", bss_color_index_array[i]);
5862 he_bss_color.session_id = obss_color_info->vdev_id;
5863 he_bss_color.bss_color = bss_color_index_array[i];
5864 lim_process_set_he_bss_color(mac_ctx,
5865 (uint32_t *)&he_bss_color);
5866 } else {
5867 pe_err("Unable to find bss color from bitmasp");
5868 if (obss_color_info->evt_type ==
5869 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY &&
5870 session->obss_color_collision_dec_evt ==
5871 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
5872 /* In dot11BSSColorCollisionAPPeriod and
5873 * timer expired, time to disable bss color.
5874 */
5875 obss_color_collision_process_color_disable(mac_ctx,
5876 session);
5877 else
5878 /*
5879 * Enter dot11BSSColorCollisionAPPeriod period.
5880 */
5881 lim_send_obss_color_collision_cfg(mac_ctx, session,
5882 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY);
5883 }
5884}
5885
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005886void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5887{
5888 struct sir_set_he_bss_color *bss_color;
5889 tpPESession session_entry = NULL;
5890 tUpdateBeaconParams beacon_params;
5891
5892 if (!msg_buf) {
5893 pe_err("Buffer is Pointing to NULL");
5894 return;
5895 }
5896
5897 bss_color = (struct sir_set_he_bss_color *)msg_buf;
5898 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5899 bss_color->session_id);
5900 if (!session_entry) {
5901 pe_err("Session not found for given session_id %d",
5902 bss_color->session_id);
5903 return;
5904 }
5905
5906 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5907 pe_err("Invalid SystemRole %d",
5908 GET_LIM_SYSTEM_ROLE(session_entry));
5909 return;
5910 }
5911
5912 if (bss_color->bss_color == session_entry->he_op.bss_color) {
5913 pe_err("No change in BSS color, current BSS color %d",
5914 bss_color->bss_color);
5915 return;
5916 }
5917 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5918 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5919 session_entry->he_op.bss_col_disabled = 1;
5920 session_entry->he_bss_color_change.countdown =
5921 BSS_COLOR_SWITCH_COUNTDOWN;
5922 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005923 beacon_params.bss_color_disabled = 1;
5924 beacon_params.bss_color = session_entry->he_op.bss_color;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005925 session_entry->bss_color_changing = 1;
5926
5927 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5928 eSIR_SUCCESS) {
5929 pe_err("Unable to set op mode IE in beacon");
5930 return;
5931 }
5932
5933 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
Arif Hussain05fb4872018-01-03 16:02:55 -08005934 lim_send_obss_color_collision_cfg(mac_ctx, session_entry,
5935 OBSS_COLOR_COLLISION_DETECTION_DISABLE);
5936}
5937
5938void lim_send_obss_color_collision_cfg(tpAniSirGlobal mac_ctx,
5939 tpPESession session,
5940 enum wmi_obss_color_collision_evt_type
5941 event_type)
5942{
5943 struct wmi_obss_color_collision_cfg_param *cfg_param;
5944 struct scheduler_msg msg = {0};
5945
5946 if (!session) {
5947 pe_err("Invalid session");
5948 return;
5949 }
5950
5951 if (!session->he_capable ||
5952 !session->is_session_obss_color_collision_det_enabled) {
5953 pe_debug("%d: obss color det not enabled, he_cap:%d, sup:%d:%d",
5954 session->smeSessionId, session->he_capable,
5955 session->is_session_obss_color_collision_det_enabled,
5956 mac_ctx->lim.global_obss_color_collision_det_offload);
5957 return;
5958 }
5959
5960 cfg_param = qdf_mem_malloc(sizeof(*cfg_param));
5961 if (!cfg_param) {
5962 pe_err("Failed to allocate memory");
5963 return;
5964 }
5965
5966 pe_debug("%d: sending event:%d", session->smeSessionId, event_type);
5967 qdf_mem_zero(cfg_param, sizeof(*cfg_param));
5968 cfg_param->vdev_id = session->smeSessionId;
5969 cfg_param->evt_type = event_type;
5970 if (LIM_IS_AP_ROLE(session))
5971 cfg_param->detection_period_ms =
5972 OBSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS;
5973 else
5974 cfg_param->detection_period_ms =
5975 OBSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS;
5976
5977 cfg_param->scan_period_ms = OBSS_COLOR_COLLISION_SCAN_PERIOD_MS;
5978 if (event_type == OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
5979 cfg_param->free_slot_expiry_time_ms =
5980 OBSS_COLOR_COLLISION_FREE_SLOT_EXPIRY_MS;
5981
5982 msg.type = WMA_OBSS_COLOR_COLLISION_REQ;
5983 msg.bodyptr = cfg_param;
5984 msg.reserved = 0;
5985
5986 if (QDF_IS_STATUS_ERROR(scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
5987 pe_err("Failed to post WMA_OBSS_COLOR_COLLISION_REQ to WMA");
5988 qdf_mem_free(cfg_param);
5989 } else {
5990 session->obss_color_collision_dec_evt = event_type;
5991 }
5992}
5993
5994void lim_process_obss_color_collision_info(tpAniSirGlobal mac_ctx,
5995 uint32_t *msg_buf)
5996{
5997 struct wmi_obss_color_collision_info *obss_color_info;
5998 tpPESession session;
5999
6000 if (!msg_buf) {
6001 pe_err("Buffer is Pointing to NULL");
6002 return;
6003 }
6004
6005 obss_color_info = (struct wmi_obss_color_collision_info *)msg_buf;
6006 session = pe_find_session_by_sme_session_id(mac_ctx,
6007 obss_color_info->vdev_id);
6008 if (!session) {
6009 pe_err("Session not found for given session_id %d",
6010 obss_color_info->vdev_id);
6011 return;
6012 }
6013
6014 pe_debug("vdev_id:%d, evt:%d:%d, 0to31:0x%x, 32to63:0x%x, cap:%d:%d:%d",
6015 obss_color_info->vdev_id,
6016 obss_color_info->evt_type,
6017 session->obss_color_collision_dec_evt,
6018 obss_color_info->obss_color_bitmap_bit0to31,
6019 obss_color_info->obss_color_bitmap_bit32to63,
6020 session->he_capable,
6021 session->is_session_obss_color_collision_det_enabled,
6022 mac_ctx->lim.global_obss_color_collision_det_offload);
6023
6024 if (!session->he_capable ||
6025 !session->is_session_obss_color_collision_det_enabled) {
6026 return;
6027 }
6028
6029 switch (obss_color_info->evt_type) {
6030 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
6031 pe_err("%d: FW disabled obss color det. he_cap:%d, sup:%d:%d",
6032 session->smeSessionId, session->he_capable,
6033 session->is_session_obss_color_collision_det_enabled,
6034 mac_ctx->lim.global_obss_color_collision_det_offload);
6035 session->is_session_obss_color_collision_det_enabled = false;
6036 return;
6037 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
6038 case OBSS_COLOR_COLLISION_DETECTION:
6039 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
6040 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6041 pe_debug("Invalid System Role %d",
6042 GET_LIM_SYSTEM_ROLE(session));
6043 return;
6044 }
6045
6046 if (session->obss_color_collision_dec_evt !=
6047 obss_color_info->evt_type) {
6048 pe_debug("%d: Wrong event: %d, skiping",
6049 obss_color_info->vdev_id,
6050 obss_color_info->evt_type);
6051 return;
6052 }
6053 obss_color_collision_process_color_change(mac_ctx, session,
6054 obss_color_info);
6055 break;
6056 default:
6057 pe_err("%d: Invalid event type %d",
6058 obss_color_info->vdev_id, obss_color_info->evt_type);
6059 return;
6060 }
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006061}
6062#endif