blob: 705f10675e9f7fa279b8c696047c6053b8951a05 [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;
Kiran Kumar Lokerebc6fb2f2018-05-09 19:04:11 -0700800 if (!mac_ctx->roam.configParam.enable2x2)
801 session->nss = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800802 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700803 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800804 * parsed (Re)Assoc request structure
805 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700806 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800807 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530808 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700809 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800810 if (NULL == session->parsedAssocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700811 pe_warn("AllocateMemory() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800812 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
813 goto free;
814 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815 }
816
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700817 if (!sme_start_bss_req->channelId &&
818 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700819 pe_err("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800820 ret_code = eSIR_SME_INVALID_PARAMETERS;
821 goto free;
822 }
823 channel_number = sme_start_bss_req->channelId;
824#ifdef QCA_HT_2040_COEX
825 if (sme_start_bss_req->obssEnabled)
826 session->htSupportedChannelWidthSet =
827 session->htCapability;
828 else
829#endif
830 session->htSupportedChannelWidthSet =
831 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
832 session->htSecondaryChannelOffset =
833 sme_start_bss_req->sec_ch_offset;
834 session->htRecommendedTxWidthSet =
835 (session->htSecondaryChannelOffset) ? 1 : 0;
Abhishek Singh4294f802017-08-10 16:37:07 +0530836 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800837 FL("cbMode %u"), sme_start_bss_req->cbMode);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800838 if (lim_is_session_he_capable(session) ||
839 session->vhtCapability || session->htCapability) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800840 chanwidth = sme_start_bss_req->vht_channel_width;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700841 pe_debug("vht_channel_width %u htSupportedChannelWidthSet %d",
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800842 sme_start_bss_req->vht_channel_width,
843 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800844 session->ch_width = chanwidth;
845 if (session->htSupportedChannelWidthSet) {
846 session->ch_center_freq_seg0 =
847 sme_start_bss_req->center_freq_seg0;
848 session->ch_center_freq_seg1 =
849 sme_start_bss_req->center_freq_seg1;
850 } else {
851 session->ch_center_freq_seg0 = 0;
852 session->ch_center_freq_seg1 = 0;
853 }
854 }
855
856 if (session->vhtCapability &&
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800857 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858 session->nss = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700859 pe_debug("nss set to [%d]", session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800860 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700861 pe_debug("vht su tx bformer %d",
Krunal Soni53993f72016-07-08 18:20:03 -0700862 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800863
864 /* Delete pre-auth list if any */
865 lim_delete_pre_auth_list(mac_ctx);
866
Krunal Soni53993f72016-07-08 18:20:03 -0700867 if (session->nss == 1) {
868 session->vht_config.su_beam_former = 0;
869 session->vht_config.tx_stbc = 0;
870 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530871 session->htConfig.ht_tx_stbc = 0;
Arif Hussain53cf5692018-04-05 16:35:54 -0700872 lim_clear_he_tx_stbc(session);
Krunal Soni53993f72016-07-08 18:20:03 -0700873 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800874 /*
875 * keep the RSN/WPA IE information in PE Session Entry
876 * later will be using this to check when received (Re)Assoc req
877 */
878 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
879 &sme_start_bss_req->rsnIE, session);
880
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700881 if (LIM_IS_AP_ROLE(session) ||
882 LIM_IS_IBSS_ROLE(session) ||
883 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800884 session->gLimProtectionControl =
885 sme_start_bss_req->protEnabled;
886 /*
887 * each byte will have the following info
888 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
889 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
890 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530891 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800892 (void *)&sme_start_bss_req->ht_capab,
893 sizeof(uint16_t));
894 /* Initialize WPS PBC session link list */
895 session->pAPWPSPBCSession = NULL;
896 }
897 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530898 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800899 if (NULL == mlm_start_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700900 pe_err("Allocate Memory failed for mlmStartReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800901 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
902 goto free;
903 }
904
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800905 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530906 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800907 (uint8_t *) &sme_start_bss_req->ssId,
908 sme_start_bss_req->ssId.length + 1);
909 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
910 mlm_start_req->obssProtEnabled =
911 sme_start_bss_req->obssProtEnabled;
912
913 mlm_start_req->bssType = session->bssType;
914
915 /* Fill PE session Id from the session Table */
916 mlm_start_req->sessionId = session->peSessionId;
917
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700918 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
919 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920 /*
921 * Copy the BSSId from sessionTable to
922 * mlmStartReq struct
923 */
924 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
925 } else {
926 /* ibss mode */
927 mac_ctx->lim.gLimIbssCoalescingHappened = false;
928
929 ret_status = wlan_cfg_get_int(mac_ctx,
930 WNI_CFG_IBSS_AUTO_BSSID,
931 &auto_gen_bssid);
932 if (ret_status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700933 pe_err("Get Auto Gen BSSID fail,Status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800934 ret_status);
Abhishek Singh4294f802017-08-10 16:37:07 +0530935 ret_code = eSIR_LOGE_EXCEPTION;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800936 goto free;
937 }
938
939 if (!auto_gen_bssid) {
940 /*
941 * We're not auto generating BSSID.
942 * Instead, get it from session entry
943 */
944 sir_copy_mac_addr(mlm_start_req->bssId,
945 session->bssId);
946 /*
947 * Start IBSS group BSSID
948 * Auto Generating BSSID.
949 */
950 auto_gen_bssid = ((mlm_start_req->bssId[0] &
951 0x01) ? true : false);
952 }
953
954 if (auto_gen_bssid) {
955 /*
956 * if BSSID is not any uc id.
957 * then use locally generated BSSID.
958 * Autogenerate the BSSID
959 */
960 lim_get_random_bssid(mac_ctx,
961 mlm_start_req->bssId);
962 mlm_start_req->bssId[0] = 0x02;
963
964 /*
965 * Copy randomly generated BSSID
966 * to the session Table
967 */
968 sir_copy_mac_addr(session->bssId,
969 mlm_start_req->bssId);
970 }
971 }
972 /* store the channel num in mlmstart req structure */
973 mlm_start_req->channelNumber = session->currentOperChannel;
974 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
975 mlm_start_req->beaconPeriod =
976 session->beaconParams.beaconInterval;
Arif Hussain671a1902017-03-17 09:08:32 -0700977 mlm_start_req->cac_duration_ms =
978 sme_start_bss_req->cac_duration_ms;
979 mlm_start_req->dfs_regdomain =
980 sme_start_bss_req->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800981 if (LIM_IS_AP_ROLE(session)) {
982 mlm_start_req->dtimPeriod = session->dtimPeriod;
983 mlm_start_req->wps_state = session->wps_state;
984
985 } else {
986 if (wlan_cfg_get_int(mac_ctx,
987 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700988 pe_err("could not retrieve DTIM Period");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800989 mlm_start_req->dtimPeriod = (uint8_t) val;
990 }
991
992 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
993 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700994 pe_err("could not retrieve Beacon interval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
996
997 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
998 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700999 pe_err("could not retrieve CFPMaxDuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001000 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1001
1002 /*
1003 * this may not be needed anymore now,
1004 * as rateSet is now included in the
1005 * session entry and MLM has session context.
1006 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301007 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008 (void *)&session->rateSet,
1009 sizeof(tSirMacRateSet));
1010
1011 /* Now populate the 11n related parameters */
1012 mlm_start_req->nwType = session->nwType;
1013 mlm_start_req->htCapable = session->htCapability;
1014
1015 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1016 /* Unused */
1017 mlm_start_req->dualCTSProtection =
1018 mac_ctx->lim.gHTDualCTSProtection;
1019 mlm_start_req->txChannelWidthSet =
1020 session->htRecommendedTxWidthSet;
1021
1022 session->limRFBand = lim_get_rf_band(channel_number);
1023
1024 /* Initialize 11h Enable Flag */
1025 session->lim11hEnable = 0;
gaolez76d2a162017-03-21 19:23:58 +08001026 if (mlm_start_req->bssType != eSIR_IBSS_MODE &&
1027 (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001028 BAND_5G == session->limRFBand)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001029 if (wlan_cfg_get_int(mac_ctx,
1030 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001031 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001032 else
1033 session->lim11hEnable = val;
1034
1035 if (session->lim11hEnable &&
1036 (eSIR_INFRA_AP_MODE ==
1037 mlm_start_req->bssType)) {
1038 cfg_get_wmi_dfs_master_param =
1039 wlan_cfg_get_int(mac_ctx,
1040 WNI_CFG_DFS_MASTER_ENABLED,
1041 &val);
1042 session->lim11hEnable = val;
1043 }
1044 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1045 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001046 pe_err("Get Fail, CFG DFS ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001047 }
1048
1049 if (!session->lim11hEnable) {
1050 if (cfg_set_int(mac_ctx,
1051 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1052 eSIR_SUCCESS)
1053 /*
1054 * Failed to set the CFG param
1055 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1056 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001057 pe_err("Set LOCAL_POWER_CONSTRAINT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001058 }
1059
Jiachao Wu712d4fd2017-08-23 16:52:34 +08001060 mlm_start_req->beacon_tx_rate = session->beacon_tx_rate;
1061
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001062 session->limPrevSmeState = session->limSmeState;
1063 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1064 MTRACE(mac_trace
1065 (mac_ctx, TRACE_CODE_SME_STATE,
1066 session->peSessionId,
1067 session->limSmeState));
1068
1069 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1070 (uint32_t *) mlm_start_req);
1071 return;
1072 } else {
1073
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001074 pe_err("Received unexpected START_BSS_REQ, in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001075 mac_ctx->lim.gLimSmeState);
1076 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001077 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001078 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1079
1080free:
1081 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001082 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001083 session->pLimStartBssReq = NULL;
1084 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001085 if (NULL != sme_start_bss_req)
1086 qdf_mem_free(sme_start_bss_req);
1087 if (NULL != mlm_start_req)
1088 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001089 if (NULL != session) {
1090 pe_delete_session(mac_ctx, session);
1091 session = NULL;
1092 }
1093 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1094 session, sme_session_id, sme_transaction_id);
1095}
1096
1097/**
1098 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1099 *
1100 * @pMac: Global MAC context
1101 * @pMsg: Message pointer
1102 *
1103 * Wrapper for the function __lim_handle_sme_start_bss_request
1104 * This message will be defered until softmac come out of
1105 * scan mode or if we have detected radar on the current
1106 * operating channel.
1107 *
1108 * return true - If we consumed the buffer
1109 * false - If have defered the message.
1110 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001111static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1112 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001113{
1114 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1115 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1116 /**
1117 * If message defered, buffer is not consumed yet.
1118 * So return false
1119 */
1120 return false;
1121 }
1122
1123 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1124 return true;
1125}
1126
1127/**
1128 * lim_get_random_bssid()
1129 *
1130 * FUNCTION:This function is called to process generate the random number for bssid
1131 * This function is called to process SME_SCAN_REQ message
1132 * from HDD or upper layer application.
1133 *
1134 * LOGIC:
1135 *
1136 * ASSUMPTIONS:
1137 *
1138 * NOTE:
1139 * 1. geneartes the unique random number for bssid in ibss
1140 *
1141 * @param pMac Pointer to Global MAC structure
1142 * @param *data Pointer to bssid buffer
1143 * @return None
1144 */
1145void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1146{
1147 uint32_t random[2];
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001148
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001149 random[0] = tx_time_get();
1150 random[0] |= (random[0] << 15);
1151 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301152 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001153}
1154
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001155/**
1156 * __lim_process_clear_dfs_channel_list()
1157 *
1158 ***FUNCTION:
Jeff Johnsonc00ae5b2018-05-06 16:06:35 -07001159 ***Clear DFS channel list when country is changed/acquired.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001160 .*This message is sent from SME.
1161 *
1162 ***LOGIC:
1163 *
1164 ***ASSUMPTIONS:
1165 *
1166 ***NOTE:
1167 *
1168 * @param pMac Pointer to Global MAC structure
1169 * @param *pMsgBuf A pointer to the SME message buffer
1170 * @return None
1171 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001172static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1173 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001174{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301175 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001176}
1177
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301178#ifdef WLAN_FEATURE_SAE
1179
1180/**
1181 * lim_update_sae_config()- This API update SAE session info to csr config
1182 * from join request.
1183 * @session: PE session
1184 * @sme_join_req: pointer to join request
1185 *
1186 * Return: None
1187 */
1188static void lim_update_sae_config(tpPESession session,
1189 tpSirSmeJoinReq sme_join_req)
1190{
1191 session->sae_pmk_cached = sme_join_req->sae_pmk_cached;
1192
1193 pe_debug("pmk_cached %d for BSSID=" MAC_ADDRESS_STR,
1194 session->sae_pmk_cached,
1195 MAC_ADDR_ARRAY(sme_join_req->bssDescription.bssId));
1196}
1197#else
1198static inline void lim_update_sae_config(tpPESession session,
1199 tpSirSmeJoinReq sme_join_req)
1200{}
1201#endif
1202
1203
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001204/**
1205 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1206 * @mac_ctx: Pointer to Global MAC structure
1207 * @msg_buf: A pointer to the SME message buffer
1208 *
1209 * This function is called to process SME_JOIN_REQ message
1210 * from HDD or upper layer application.
1211 *
1212 * Return: None
1213 */
1214static void
1215__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1216{
1217 tpSirSmeJoinReq sme_join_req = NULL;
1218 tLimMlmJoinReq *mlm_join_req;
1219 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1220 uint32_t val = 0;
1221 uint16_t n_size;
1222 uint8_t session_id;
1223 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301224 uint8_t sme_session_id = 0;
1225 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001226 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001227 uint16_t ie_len;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001228 const uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001229 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001230 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001231
Arif Hussain995fcaf2016-07-18 11:28:22 -07001232 if (!mac_ctx || !msg_buf) {
1233 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1234 FL("JOIN REQ with invalid data"));
1235 return;
1236 }
1237
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001238/* FEATURE_WLAN_DIAG_SUPPORT */
1239#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1240 /*
1241 * Not sending any session, since it is not created yet.
1242 * The response whould have correct state.
1243 */
1244 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1245#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1246
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247 /*
1248 * Expect Join request in idle state.
1249 * Reassociate request is expected in link established state.
1250 */
1251
1252 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1253 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1254 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1255 msg_buf);
1256
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301257 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001258 if (NULL == sme_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001259 pe_err("AllocateMemory failed for sme_join_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001260 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301261 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001262 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301263 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001264 n_size);
1265
1266 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1267 /* Received invalid eWNI_SME_JOIN_REQ */
1268 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001269 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001270 sme_join_req->sessionId);
1271 ret_code = eSIR_SME_INVALID_PARAMETERS;
1272 goto end;
1273 }
1274
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001275 /*
1276 * Update the capability here itself as this is used in
1277 * lim_extract_ap_capability() below. If not updated issues
1278 * like not honoring power constraint on 1st association after
1279 * driver loading might occur.
1280 */
1281 lim_update_rrm_capability(mac_ctx, sme_join_req);
1282
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001283 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001284 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001285 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286 &session_id);
1287
1288 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001289 pe_err("Session(%d) Already exists for BSSID: "
1290 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001291 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001292 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293 session->limSmeState);
1294
1295 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1296 session->smeSessionId == sme_join_req->sessionId) {
1297 /*
1298 * Received eWNI_SME_JOIN_REQ for same
1299 * BSS as currently associated.
1300 * Log the event and send success
1301 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001302 pe_warn("SessionId: %d", session_id);
1303 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001304 /* Send Join success response to host */
1305 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1306 session = NULL;
1307 goto end;
1308 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001309 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001310 ret_code = eSIR_SME_REFUSED;
1311 session = NULL;
1312 goto end;
1313 }
1314 } else {
1315 /*
1316 * Session Entry does not exist for given BSSId
1317 * Try to Create a new session
1318 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001319 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001320 &session_id, mac_ctx->lim.maxStation,
1321 eSIR_INFRASTRUCTURE_MODE);
1322 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001323 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001324 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1325 goto end;
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301326 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001327 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328 session_id);
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301329 }
1330
1331 /* Update the beacon/probe filter in mac_ctx */
1332 lim_set_bcn_probe_filter(mac_ctx, session,
1333 &sme_join_req->ssId,
1334 bss_desc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001335 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001336 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001337
1338 /*
1339 * Store Session related parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001340 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341
1342 /* store the smejoin req handle in session table */
1343 session->pLimJoinReq = sme_join_req;
1344
1345 /* Store SME session Id in sessionTable */
1346 session->smeSessionId = sme_join_req->sessionId;
1347
1348 /* Store SME transaction Id in session Table */
1349 session->transactionId = sme_join_req->transactionId;
1350
1351 /* Store beaconInterval */
1352 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001353 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001354
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301355 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001356 sizeof(session->htConfig));
1357
Sandeep Puligilla98917432016-06-10 13:50:28 -07001358 qdf_mem_copy(&(session->vht_config),
1359 &(sme_join_req->vht_config),
1360 sizeof(session->vht_config));
1361
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001362 /* Copying of bssId is already done, while creating session */
1363 sir_copy_mac_addr(session->selfMacAddr,
1364 sme_join_req->selfMacAddr);
1365 session->bssType = sme_join_req->bsstype;
1366
1367 session->statypeForBss = STA_ENTRY_PEER;
1368 session->limWmeEnabled = sme_join_req->isWMEenabled;
1369 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301370 session->wps_registration = sme_join_req->wps_registration;
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001371 session->he_with_wep_tkip = sme_join_req->he_with_wep_tkip;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001372
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301373 session->enable_bcast_probe_rsp =
1374 sme_join_req->enable_bcast_probe_rsp;
1375
Jeff Johnson179fd8a2018-05-11 14:20:05 -07001376 /* Store vendor specific IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001377 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001378 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1379
Naveen Rawat08db88f2017-09-08 15:07:48 -07001380 vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001382 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001383
1384 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001385 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001386 session->isCiscoVendorAP = true;
1387 } else {
1388 session->isCiscoVendorAP = false;
1389 }
1390
1391 /* Copy the dot 11 mode in to the session table */
1392
1393 session->dot11mode = sme_join_req->dot11mode;
1394#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1395 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1396#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001397 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001398 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1399 session->enableHtSmps = sme_join_req->enableHtSmps;
1400 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001401 session->send_smps_action =
1402 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001403 /*
1404 * By default supported NSS 1x1 is set to true
1405 * and later on updated while determining session
1406 * supported rates which is the intersection of
1407 * self and peer rates
1408 */
1409 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301410 /*Store Persona */
1411 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001412 pe_debug("enable Smps: %d mode: %d send action: %d supported nss 1x1: %d pePersona %d cbMode %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001413 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001414 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001415 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301416 session->supported_nss_1x1,
1417 session->pePersona,
1418 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001419
1420 /*Store Persona */
1421 session->pePersona = sme_join_req->staPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +05301422 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301423 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d force_24ghz_in_ht20 %d"),
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001424 session->pePersona, sme_join_req->cbMode,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301425 session->nwType, session->dot11mode,
1426 sme_join_req->force_24ghz_in_ht20);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001427
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001428 /* Copy The channel Id to the session Table */
1429 session->currentOperChannel = bss_desc->channelId;
1430 if (IS_5G_CH(session->currentOperChannel))
1431 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001432 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001433 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1434 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1435 session->vdev_nss = vdev_type_nss->p2p_cli;
1436 else
1437 session->vdev_nss = vdev_type_nss->sta;
1438 session->nss = session->vdev_nss;
Kiran Kumar Lokerebc6fb2f2018-05-09 19:04:11 -07001439 if (!mac_ctx->roam.configParam.enable2x2)
1440 session->nss = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441 session->vhtCapability =
1442 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001443 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301444 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001445 session->vht_config.su_beam_formee =
1446 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001447 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001448 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001449 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001450 session->enableVhtpAid =
1451 sme_join_req->enableVhtpAid;
1452 session->enableVhtGid =
1453 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001454 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001455 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001456 }
Krunal Soni53993f72016-07-08 18:20:03 -07001457
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001458 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301459 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001460 session->vht_config.su_beam_formee,
1461 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001462 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001463 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001464 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001465 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301466 session->force_24ghz_in_ht20 =
1467 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001468 /* cbMode is already merged value of peer and self -
1469 * done by csr in csr_get_cb_mode_from_ies */
1470 session->htSupportedChannelWidthSet =
1471 (sme_join_req->cbMode) ? 1 : 0;
1472 session->htRecommendedTxWidthSet =
1473 session->htSupportedChannelWidthSet;
1474 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1475
1476 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1477 session->ch_center_freq_seg0 =
1478 session->currentOperChannel - 2;
1479 session->ch_width = CH_WIDTH_40MHZ;
1480 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1481 sme_join_req->cbMode) {
1482 session->ch_center_freq_seg0 =
1483 session->currentOperChannel + 2;
1484 session->ch_width = CH_WIDTH_40MHZ;
1485 } else {
1486 session->ch_center_freq_seg0 = 0;
1487 session->ch_width = CH_WIDTH_20MHZ;
1488 }
1489
Naveen Rawataeca1b92017-10-16 16:55:31 -07001490 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1491 lim_update_session_he_capable(mac_ctx, session);
1492 lim_copy_join_req_he_cap(session, sme_join_req);
1493 }
1494
1495
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001496 /* Record if management frames need to be protected */
1497#ifdef WLAN_FEATURE_11W
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +05301498 if ((eSIR_ED_AES_128_CMAC ==
1499 sme_join_req->MgmtEncryptionType) ||
1500 (eSIR_ED_AES_GMAC_128 == sme_join_req->MgmtEncryptionType) ||
1501 (eSIR_ED_AES_GMAC_256 == sme_join_req->MgmtEncryptionType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001502 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001503 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001504 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001505#endif
1506
1507#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001508 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001509#endif
1510
1511 /* Copy the SSID from smejoinreq to session entry */
1512 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301513 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001514 session->ssId.length);
1515
1516 /*
1517 * Determin 11r or ESE connection based on input from SME
1518 * which inturn is dependent on the profile the user wants
1519 * to connect to, So input is coming from supplicant
1520 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001522#ifdef FEATURE_WLAN_ESE
1523 session->isESEconnection = sme_join_req->isESEconnection;
1524#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001525 session->isFastTransitionEnabled =
1526 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001527
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001528 session->isFastRoamIniFeatureEnabled =
1529 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001530 session->txLdpcIniFeatureEnabled =
1531 sme_join_req->txLdpcIniFeatureEnabled;
1532
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301533 lim_update_fils_config(session, sme_join_req);
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301534 lim_update_sae_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001535 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1536 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001537 } else {
1538 /*
1539 * Throw an error and return and make
1540 * sure to delete the session.
1541 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001542 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001543 session->bssType);
1544 ret_code = eSIR_SME_INVALID_PARAMETERS;
1545 goto end;
1546 }
1547
1548 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301549 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001550 &sme_join_req->addIEScan, sizeof(tSirAddie));
1551
1552 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301553 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001554 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1555
1556 val = sizeof(tLimMlmJoinReq) +
1557 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301558 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001559 if (NULL == mlm_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001560 pe_err("AllocateMemory failed for mlmJoinReq");
Nitesh Shah0102cac2016-07-13 14:38:30 +05301561 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1562 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001563 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001564
1565 /* PE SessionId is stored as a part of JoinReq */
1566 mlm_join_req->sessionId = session->peSessionId;
1567
1568 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1569 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1570 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001571 pe_err("couldn't retrieve JoinFailureTimer value"
1572 " setting to default value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001573 mlm_join_req->joinFailureTimeout =
1574 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1575 }
1576
1577 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301578 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001579 (void *)&sme_join_req->operationalRateSet,
1580 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301581 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582 (void *)&sme_join_req->extendedRateSet,
1583 sizeof(tSirMacRateSet));
1584 /*
1585 * this may not be needed anymore now, as rateSet is now
1586 * included in the session entry and MLM has session context.
1587 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301588 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001589 (void *)&session->rateSet,
1590 sizeof(tSirMacRateSet));
1591
1592 session->encryptType = sme_join_req->UCEncryptionType;
1593
1594 mlm_join_req->bssDescription.length =
1595 session->pLimJoinReq->bssDescription.length;
1596
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301597 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001598 (uint8_t *)
1599 &session->pLimJoinReq->bssDescription.bssId,
1600 session->pLimJoinReq->bssDescription.length + 2);
1601
1602 session->limCurrentBssCaps =
1603 session->pLimJoinReq->bssDescription.capabilityInfo;
1604
1605 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1606 session->currentOperChannel);
1607 local_power_constraint = reg_max;
1608
1609 lim_extract_ap_capability(mac_ctx,
1610 (uint8_t *)
1611 session->pLimJoinReq->bssDescription.ieFields,
1612 lim_get_ielen_from_bss_description(
1613 &session->pLimJoinReq->bssDescription),
1614 &session->limCurrentBssQosCaps,
1615 &session->limCurrentBssPropCap,
1616 &session->gLimCurrentBssUapsd,
1617 &local_power_constraint, session);
1618
Krunal Soni53993f72016-07-08 18:20:03 -07001619 /*
1620 * Once the AP capabilities are available then set the
1621 * beam forming capabilities accordingly.
1622 */
1623 if (session->nss == 1) {
1624 session->vht_config.su_beam_former = 0;
1625 session->vht_config.tx_stbc = 0;
1626 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301627 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001628 }
1629
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001630 session->maxTxPower = lim_get_max_tx_power(reg_max,
1631 local_power_constraint,
1632 mac_ctx->roam.configParam.nTxPowerCap);
Abhinav Kumard528d192018-03-09 17:31:12 +05301633 session->def_max_tx_pwr = session->maxTxPower;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301634
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001635 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301636 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301638 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1639 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1640 pe_debug("Update MaxTxPower in join Req to %d",
1641 sme_join_req->powerCap.maxTxPower);
1642 }
1643
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001644 if (session->gLimCurrentBssUapsd) {
1645 session->gUapsdPerAcBitmask =
1646 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001647 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001648 session->gUapsdPerAcBitmask);
1649
1650 /* resetting the dynamic uapsd mask */
1651 session->gUapsdPerAcDeliveryEnableMask = 0;
1652 session->gUapsdPerAcTriggerEnableMask = 0;
1653 }
1654
1655 session->limRFBand =
1656 lim_get_rf_band(session->currentOperChannel);
1657
1658 /* Initialize 11h Enable Flag */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001659 if (BAND_5G == session->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001660 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1661 &val) != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001662 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001663 session->lim11hEnable =
1664 WNI_CFG_11H_ENABLED_STADEF;
1665 } else {
1666 session->lim11hEnable = val;
1667 }
1668 } else {
1669 session->lim11hEnable = 0;
1670 }
1671
1672 /*
1673 * To care of the scenario when STA transitions from
1674 * IBSS to Infrastructure mode.
1675 */
1676 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1677
1678 session->limPrevSmeState = session->limSmeState;
1679 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1680 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1681 session->peSessionId,
1682 session->limSmeState));
1683
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001684 /* Indicate whether spectrum management is enabled */
1685 session->spectrumMgtEnabled =
1686 sme_join_req->spectrumMgtIndicator;
1687
1688 /* Enable the spectrum management if this is a DFS channel */
1689 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001690 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001691 session->currentOperChannel))
1692 session->spectrumMgtEnabled = true;
1693
1694 session->isOSENConnection = sme_join_req->isOSENConnection;
1695
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001696 /* Issue LIM_MLM_JOIN_REQ to MLM */
1697 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1698 (uint32_t *) mlm_join_req);
1699 return;
1700
1701 } else {
1702 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001703 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001704 mac_ctx->lim.gLimSmeState);
1705 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1706 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1707 session = NULL;
1708 goto end;
1709 }
1710
1711end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301712 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1713 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001714
1715 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301716 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717 sme_join_req = NULL;
1718 if (NULL != session)
1719 session->pLimJoinReq = NULL;
1720 }
1721 if (ret_code != eSIR_SME_SUCCESS) {
1722 if (NULL != session) {
1723 pe_delete_session(mac_ctx, session);
1724 session = NULL;
1725 }
1726 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001727 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001728 sme_session_id, ret_code);
1729 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1730 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1731 sme_transaction_id);
1732}
1733
Amar Singhala297bfa2015-10-15 15:07:29 -07001734uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001735 uint8_t iniTxPower)
1736{
1737 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301738 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001739
Anurag Chouhan6d760662016-02-20 16:05:43 +05301740 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001741 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1742 maxTxPower = txPower;
1743 else if (txPower < MIN_TX_PWR_CAP)
1744 maxTxPower = MIN_TX_PWR_CAP;
1745 else
1746 maxTxPower = MAX_TX_PWR_CAP;
1747
1748 return maxTxPower;
1749}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001750
1751/**
1752 * __lim_process_sme_reassoc_req() - process reassoc req
1753 *
1754 * @mac_ctx: Pointer to Global MAC structure
1755 * @msg_buf: pointer to the SME message buffer
1756 *
1757 * This function is called to process SME_REASSOC_REQ message
1758 * from HDD or upper layer application.
1759 *
1760 * Return: None
1761 */
1762
1763static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
1764 uint32_t *msg_buf)
1765{
1766 uint16_t caps;
1767 uint32_t val;
1768 tpSirSmeJoinReq reassoc_req = NULL;
1769 tLimMlmReassocReq *mlm_reassoc_req;
1770 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1771 tpPESession session_entry = NULL;
1772 uint8_t session_id;
1773 uint8_t sme_session_id;
1774 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001775 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001776 uint32_t tele_bcn_en = 0;
1777 uint16_t size;
1778
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001779 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301780 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001781 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001782 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001783
1784 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1785 goto end;
1786 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301787 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001788
1789 if (!lim_is_sme_join_req_valid(mac_ctx,
1790 (tpSirSmeJoinReq)reassoc_req)) {
1791 /*
1792 * Received invalid eWNI_SME_REASSOC_REQ
1793 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001794 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001795
1796 ret_code = eSIR_SME_INVALID_PARAMETERS;
1797 goto end;
1798 }
1799
1800 session_entry = pe_find_session_by_bssid(mac_ctx,
1801 reassoc_req->bssDescription.bssId,
1802 &session_id);
1803 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001804 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001805 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
1806 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001808 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
1809 &sme_session_id, &transaction_id);
1810 session_entry =
1811 pe_find_session_by_sme_session_id(mac_ctx,
1812 sme_session_id);
1813 if (session_entry != NULL)
1814 lim_handle_sme_join_result(mac_ctx,
1815 eSIR_SME_INVALID_PARAMETERS,
1816 eSIR_MAC_UNSPEC_FAILURE_STATUS,
1817 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001818 goto end;
1819 }
1820#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
1821 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
1822 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
1823#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1824 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
1825
1826 /* Store the reassoc handle in the session Table */
1827 session_entry->pLimReAssocReq = reassoc_req;
1828
1829 session_entry->dot11mode = reassoc_req->dot11mode;
1830 session_entry->vhtCapability =
1831 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001832
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301833 if (session_entry->vhtCapability) {
1834 if (session_entry->pePersona == QDF_STA_MODE) {
1835 session_entry->vht_config.su_beam_formee =
1836 reassoc_req->vht_config.su_beam_formee;
1837 } else {
1838 reassoc_req->vht_config.su_beam_formee = 0;
1839 }
1840 session_entry->enableVhtpAid =
1841 reassoc_req->enableVhtpAid;
1842 session_entry->enableVhtGid =
1843 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001844 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301845 }
1846
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001847 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301848 session_entry->vhtCapability,
1849 session_entry->vht_config.su_beam_formee,
1850 session_entry->vht_config.su_beam_former);
1851
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001852 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
1853 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001854 session_entry->send_smps_action =
1855 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001856 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001857 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001858 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001859 session_entry->send_smps_action,
1860 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001861 /*
1862 * Reassociate request is expected
1863 * in link established state only.
1864 */
1865
1866 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001867 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
1868 /*
1869 * May be from 11r FT pre-auth. So lets check it
1870 * before we bail out
1871 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001872 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001873 session_entry->peSessionId);
1874
1875 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301876 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001877 session_entry->limReAssocbssId,
1878 6)) {
1879 lim_print_mac_addr(mac_ctx,
1880 reassoc_req->bssDescription.
1881 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001882 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001883 ret_code = eSIR_SME_INVALID_PARAMETERS;
1884 goto end;
1885 }
1886
1887 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
1888 session_entry);
1889 return;
1890 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891 /*
1892 * Should not have received eWNI_SME_REASSOC_REQ
1893 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001894 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001895 session_entry->limSmeState);
1896 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
1897
1898 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1899 goto end;
1900 }
1901
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301902 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001903 session_entry->pLimReAssocReq->bssDescription.bssId,
1904 sizeof(tSirMacAddr));
1905
1906 session_entry->limReassocChannelId =
1907 session_entry->pLimReAssocReq->bssDescription.channelId;
1908
1909 session_entry->reAssocHtSupportedChannelWidthSet =
1910 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
1911 session_entry->reAssocHtRecommendedTxWidthSet =
1912 session_entry->reAssocHtSupportedChannelWidthSet;
1913 session_entry->reAssocHtSecondaryChannelOffset =
1914 session_entry->pLimReAssocReq->cbMode;
1915
1916 session_entry->limReassocBssCaps =
1917 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
1918 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1919 session_entry->currentOperChannel);
1920 local_pwr_constraint = reg_max;
1921
1922 lim_extract_ap_capability(mac_ctx,
1923 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
1924 lim_get_ielen_from_bss_description(
1925 &session_entry->pLimReAssocReq->bssDescription),
1926 &session_entry->limReassocBssQosCaps,
1927 &session_entry->limReassocBssPropCap,
1928 &session_entry->gLimCurrentBssUapsd,
1929 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05301930 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001931 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301932 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001933 /* Copy the SSID from session entry to local variable */
1934 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301935 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001936 reassoc_req->ssId.ssId,
1937 session_entry->limReassocSSID.length);
1938 if (session_entry->gLimCurrentBssUapsd) {
1939 session_entry->gUapsdPerAcBitmask =
1940 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001941 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001942 session_entry->gUapsdPerAcBitmask);
1943 }
1944
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301945 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001946 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001947 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001948
1949 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1950 goto end;
1951 }
1952
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301953 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001954 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
1955
1956 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
1957 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001958 eSIR_SUCCESS)
1959 pe_err("could not retrieve ReassocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001960
1961 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001962 eSIR_SUCCESS)
1963 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301964
1965 lim_update_caps_info_for_bss(mac_ctx, &caps,
1966 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001967 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301968
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001969 mlm_reassoc_req->capabilityInfo = caps;
1970
1971 /* Update PE session_id */
1972 mlm_reassoc_req->sessionId = session_id;
1973
1974 /*
1975 * If telescopic beaconing is enabled, set listen interval to
1976 * WNI_CFG_TELE_BCN_MAX_LI
1977 */
1978 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
1979 &tele_bcn_en) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001980 pe_err("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001981
1982 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
1983
1984 if (tele_bcn_en) {
1985 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
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 } else {
1989 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
1990 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001991 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001992 }
1993
1994 mlm_reassoc_req->listenInterval = (uint16_t) val;
1995
1996 /* Indicate whether spectrum management is enabled */
1997 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
1998
1999 /* Enable the spectrum management if this is a DFS channel */
2000 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002001 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002002 session_entry->currentOperChannel))
2003 session_entry->spectrumMgtEnabled = true;
2004
2005 session_entry->limPrevSmeState = session_entry->limSmeState;
2006 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2007
2008 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2009 session_entry->peSessionId,
2010 session_entry->limSmeState));
2011
2012 lim_post_mlm_message(mac_ctx,
2013 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2014 return;
2015end:
2016 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302017 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002018 if (session_entry)
2019 session_entry->pLimReAssocReq = NULL;
2020 }
2021
2022 if (session_entry) {
2023 /*
2024 * error occurred after we determined the session so extract
2025 * session and transaction info from there
2026 */
2027 sme_session_id = session_entry->smeSessionId;
2028 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002029 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002030 /*
2031 * error occurred before or during the time we determined
2032 * the session so extract the session and transaction info
2033 * from the message
2034 */
2035 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2036 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002037 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002038 /*
2039 * Send Reassoc failure response to host
2040 * (note session_entry may be NULL, but that's OK)
2041 */
2042 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2043 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2044 session_entry, sme_session_id,
2045 transaction_id);
2046}
2047
2048bool send_disassoc_frame = 1;
2049/**
2050 * __lim_process_sme_disassoc_req()
2051 *
2052 ***FUNCTION:
2053 * This function is called to process SME_DISASSOC_REQ message
2054 * from HDD or upper layer application.
2055 *
2056 ***LOGIC:
2057 *
2058 ***ASSUMPTIONS:
2059 *
2060 ***NOTE:
2061 *
2062 * @param pMac Pointer to Global MAC structure
2063 * @param *pMsgBuf A pointer to the SME message buffer
2064 * @return None
2065 */
2066
2067static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2068{
2069 uint16_t disassocTrigger, reasonCode;
2070 tLimMlmDisassocReq *pMlmDisassocReq;
2071 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2072 tSirSmeDisassocReq smeDisassocReq;
2073 tpPESession psessionEntry = NULL;
2074 uint8_t sessionId;
2075 uint8_t smesessionId;
2076 uint16_t smetransactionId;
2077
2078 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002079 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002080 return;
2081 }
2082
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302083 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002084 smesessionId = smeDisassocReq.sessionId;
2085 smetransactionId = smeDisassocReq.transactionId;
2086 if (!lim_is_sme_disassoc_req_valid(pMac,
2087 &smeDisassocReq,
2088 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002089 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002090 if (pMac->lim.gLimRspReqd) {
2091 pMac->lim.gLimRspReqd = false;
2092
2093 retCode = eSIR_SME_INVALID_PARAMETERS;
2094 disassocTrigger = eLIM_HOST_DISASSOC;
2095 goto sendDisassoc;
2096 }
2097
2098 return;
2099 }
2100
2101 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002102 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103 &sessionId);
2104 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002105 pe_err("session does not exist for given bssId "
2106 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002107 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002108 retCode = eSIR_SME_INVALID_PARAMETERS;
2109 disassocTrigger = eLIM_HOST_DISASSOC;
2110 goto sendDisassoc;
2111 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002112 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2113 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002114 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2115 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002116 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002117
2118#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2119 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2120 0, smeDisassocReq.reasonCode);
2121#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2122
2123 /* Update SME session Id and SME transaction ID */
2124
2125 psessionEntry->smeSessionId = smesessionId;
2126 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002127 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002128 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002129
2130 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2131 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002132 switch (psessionEntry->limSmeState) {
2133 case eLIM_SME_ASSOCIATED_STATE:
2134 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002135 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002136 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002137 psessionEntry->limPrevSmeState =
2138 psessionEntry->limSmeState;
2139 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002140 /* Delete all TDLS peers connected before leaving BSS */
2141 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002142 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2143 psessionEntry->peSessionId,
2144 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002145 break;
2146
2147 case eLIM_SME_WT_DEAUTH_STATE:
2148 /* PE shall still process the DISASSOC_REQ and proceed with
2149 * link tear down even if it had already sent a DEAUTH_IND to
2150 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2151 * its been set when PE entered WT_DEAUTH_STATE.
2152 */
2153 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2154 MTRACE(mac_trace
2155 (pMac, TRACE_CODE_SME_STATE,
2156 psessionEntry->peSessionId,
2157 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002158 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002159 break;
2160
2161 case eLIM_SME_WT_DISASSOC_STATE:
Jeff Johnson47d75242018-05-12 15:58:53 -07002162 /* PE Received a Disassoc frame. Normally it gets DISASSOC_CNF but it
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002163 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2164 * PE can continue processing DISASSOC_REQ and send the response instead
2165 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2166 * for disassoc frame.
2167 *
2168 * It will send a disassoc, which is ok. However, we can use the global flag
2169 * sendDisassoc to not send disassoc frame.
2170 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002171 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002172 break;
2173
2174 case eLIM_SME_JOIN_FAILURE_STATE: {
2175 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002176 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002177 if (pMac->lim.gLimRspReqd) {
2178 retCode = eSIR_SME_SUCCESS;
2179 disassocTrigger = eLIM_HOST_DISASSOC;
2180 goto sendDisassoc;
2181 }
2182 }
2183 break;
2184 default:
2185 /**
2186 * STA is not currently associated.
2187 * Log error and send response to host
2188 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002189 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190 psessionEntry->limSmeState);
2191 lim_print_sme_state(pMac, LOGE,
2192 psessionEntry->limSmeState);
2193
2194 if (pMac->lim.gLimRspReqd) {
2195 if (psessionEntry->limSmeState !=
2196 eLIM_SME_WT_ASSOC_STATE)
2197 pMac->lim.gLimRspReqd = false;
2198
2199 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2200 disassocTrigger = eLIM_HOST_DISASSOC;
2201 goto sendDisassoc;
2202 }
2203
2204 return;
2205 }
2206
2207 break;
2208
2209 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002210 /* Fall through */
2211 break;
2212
2213 case eLIM_STA_IN_IBSS_ROLE:
2214 default:
2215 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002216 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002217 GET_LIM_SYSTEM_ROLE(psessionEntry));
2218
2219 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2220 disassocTrigger = eLIM_HOST_DISASSOC;
2221 goto sendDisassoc;
2222 } /* end switch (pMac->lim.gLimSystemRole) */
2223
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302224 disassocTrigger = eLIM_HOST_DISASSOC;
2225 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002226
2227 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002228 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002229 send_disassoc_frame = 0;
2230 }
2231 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002232 pe_debug("Sending Disasscoc with disassoc Trigger"
2233 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002234 disassocTrigger, reasonCode);
2235
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302236 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002237 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002238 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002239 return;
2240 }
2241
Anurag Chouhanc5548422016-02-24 18:33:27 +05302242 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002243 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002244
2245 pMlmDisassocReq->reasonCode = reasonCode;
2246 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2247
2248 /* Update PE session ID */
2249 pMlmDisassocReq->sessionId = sessionId;
2250
2251 lim_post_mlm_message(pMac,
2252 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2253 return;
2254
2255sendDisassoc:
2256 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002257 lim_send_sme_disassoc_ntf(pMac,
2258 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002259 retCode,
2260 disassocTrigger,
2261 1, smesessionId, smetransactionId,
2262 psessionEntry);
2263 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002264 lim_send_sme_disassoc_ntf(pMac,
2265 smeDisassocReq.peer_macaddr.bytes,
2266 retCode, disassocTrigger, 1,
2267 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002268
2269} /*** end __lim_process_sme_disassoc_req() ***/
2270
2271/** -----------------------------------------------------------------
2272 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2273
2274 This function is called to process SME_DISASSOC_CNF message
2275 from HDD or upper layer application.
2276
2277 \param pMac - global mac structure
2278 \param pStaDs - station dph hash node
2279 \return none
2280 \sa
2281 ----------------------------------------------------------------- */
2282static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2283{
2284 tSirSmeDisassocCnf smeDisassocCnf;
2285 uint16_t aid;
2286 tpDphHashNode pStaDs;
2287 tpPESession psessionEntry;
2288 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302289 uint32_t *msg = NULL;
2290 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002291
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302292 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002293 sizeof(struct sSirSmeDisassocCnf));
2294
2295 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002296 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002297 &sessionId);
2298 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002299 pe_err("session does not exist for given bssId");
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302300 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302301 smeDisassocCnf.sme_session_id,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302302 eSIR_SME_INVALID_SESSION,
2303 NULL);
2304 if (QDF_IS_STATUS_SUCCESS(status))
2305 lim_send_sme_disassoc_deauth_ntf(pMac,
2306 QDF_STATUS_SUCCESS,
2307 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002308 return;
2309 }
2310
2311 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002312 pe_err("received invalid SME_DISASSOC_CNF message");
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302313 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2314 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302315 eSIR_SME_INVALID_PARAMETERS,
2316 &smeDisassocCnf.bssid.bytes[0]);
2317 if (QDF_IS_STATUS_SUCCESS(status))
2318 lim_send_sme_disassoc_deauth_ntf(pMac,
2319 QDF_STATUS_SUCCESS,
2320 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002321 return;
2322 }
2323#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2324 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2325 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2326 psessionEntry,
2327 (uint16_t) smeDisassocCnf.statusCode, 0);
2328 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2329 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2330 psessionEntry,
2331 (uint16_t) smeDisassocCnf.statusCode, 0);
2332#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2333
2334 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2335 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002336 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2337 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2338 && (psessionEntry->limSmeState !=
2339 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002340 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002341 psessionEntry->limSmeState);
2342 lim_print_sme_state(pMac, LOGE,
2343 psessionEntry->limSmeState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302344 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302345 psessionEntry->smeSessionId,
2346 eSIR_SME_INVALID_STATE,
2347 &smeDisassocCnf.bssid.bytes[0]);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302348 if (QDF_IS_STATUS_SUCCESS(status))
2349 lim_send_sme_disassoc_deauth_ntf(pMac,
2350 QDF_STATUS_SUCCESS,
2351 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002352 return;
2353 }
2354 break;
2355
2356 case eLIM_AP_ROLE:
2357 /* Fall through */
2358 break;
2359
2360 case eLIM_STA_IN_IBSS_ROLE:
2361 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002362 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002363 GET_LIM_SYSTEM_ROLE(psessionEntry));
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302364 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2365 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302366 eSIR_SME_INVALID_STATE,
2367 &smeDisassocCnf.bssid.bytes[0]);
2368 if (QDF_IS_STATUS_SUCCESS(status))
2369 lim_send_sme_disassoc_deauth_ntf(pMac,
2370 QDF_STATUS_SUCCESS,
2371 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002372 return;
2373 }
2374
2375 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2376 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2377 LIM_IS_AP_ROLE(psessionEntry)) {
2378 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002379 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002380 &psessionEntry->dph.dphHashTable);
2381 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002382 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2383 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002384 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302385 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302386 psessionEntry->smeSessionId,
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05302387 eSIR_SME_INVALID_PARAMETERS,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302388 &smeDisassocCnf.bssid.bytes[0]);
2389 if (QDF_IS_STATUS_SUCCESS(status))
2390 lim_send_sme_disassoc_deauth_ntf(pMac,
2391 QDF_STATUS_SUCCESS,
2392 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002393 return;
2394 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302395
2396 if ((pStaDs->mlmStaContext.mlmState ==
2397 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2398 (pStaDs->mlmStaContext.mlmState ==
Arif Hussain5fa13782018-05-10 11:29:52 -07002399 eLIM_MLM_WT_DEL_BSS_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002400 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002401 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302402 pStaDs->mlmStaContext.mlmState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302403 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302404 psessionEntry->smeSessionId,
2405 eSIR_SME_SUCCESS,
2406 NULL);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302407 if (QDF_IS_STATUS_SUCCESS(status))
2408 lim_send_sme_disassoc_deauth_ntf(pMac,
2409 QDF_STATUS_SUCCESS,
2410 (uint32_t *)msg);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302411 return;
2412 }
2413
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002414 /* Delete FT session if there exists one */
2415 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002416 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2417
2418 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002419 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002420 }
2421
2422 return;
2423}
2424
2425/**
2426 * __lim_process_sme_deauth_req() - process sme deauth req
2427 * @mac_ctx: Pointer to Global MAC structure
2428 * @msg_buf: pointer to the SME message buffer
2429 *
2430 * This function is called to process SME_DEAUTH_REQ message
2431 * from HDD or upper layer application.
2432 *
2433 * Return: None
2434 */
2435
2436static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2437 uint32_t *msg_buf)
2438{
2439 uint16_t deauth_trigger, reason_code;
2440 tLimMlmDeauthReq *mlm_deauth_req;
2441 tSirSmeDeauthReq sme_deauth_req;
2442 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2443 tpPESession session_entry;
2444 uint8_t session_id; /* PE sessionId */
2445 uint8_t sme_session_id;
2446 uint16_t sme_transaction_id;
2447
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302448 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002449 sme_session_id = sme_deauth_req.sessionId;
2450 sme_transaction_id = sme_deauth_req.transactionId;
2451
2452 /*
2453 * We need to get a session first but we don't even know
2454 * if the message is correct.
2455 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002456 session_entry = pe_find_session_by_bssid(mac_ctx,
2457 sme_deauth_req.bssid.bytes,
2458 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002459 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002460 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002461 ret_code = eSIR_SME_INVALID_PARAMETERS;
2462 deauth_trigger = eLIM_HOST_DEAUTH;
2463 goto send_deauth;
2464 }
2465
2466 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2467 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002468 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002469 mac_ctx->lim.gLimRspReqd = false;
2470
2471 ret_code = eSIR_SME_INVALID_PARAMETERS;
2472 deauth_trigger = eLIM_HOST_DEAUTH;
2473 goto send_deauth;
2474 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002475 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2476 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002477 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2478 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002479 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002480#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2481 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2482 session_entry, 0, sme_deauth_req.reasonCode);
2483#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2484
2485 /* Update SME session ID and Transaction ID */
2486 session_entry->smeSessionId = sme_session_id;
2487 session_entry->transactionId = sme_transaction_id;
2488
2489 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2490 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002491 switch (session_entry->limSmeState) {
2492 case eLIM_SME_ASSOCIATED_STATE:
2493 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302494 /* Delete all TDLS peers connected before leaving BSS */
2495 lim_delete_tdls_peers(mac_ctx, session_entry);
Abhinav Kumarac12c762018-05-02 13:51:02 +05302496 /* fallthrough */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002497 case eLIM_SME_WT_ASSOC_STATE:
2498 case eLIM_SME_JOIN_FAILURE_STATE:
2499 case eLIM_SME_IDLE_STATE:
2500 session_entry->limPrevSmeState =
2501 session_entry->limSmeState;
2502 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2503 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2504 session_entry->peSessionId,
2505 session_entry->limSmeState));
2506 /* Send Deauthentication request to MLM below */
2507 break;
2508 case eLIM_SME_WT_DEAUTH_STATE:
2509 case eLIM_SME_WT_DISASSOC_STATE:
2510 /*
Jeff Johnson47d75242018-05-12 15:58:53 -07002511 * PE Received a Deauth/Disassoc frame. Normally it get
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002512 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2513 * Which means host is also trying to disconnect.
2514 * PE can continue processing DEAUTH_REQ and send
2515 * the response instead of failing the request.
2516 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2517 * was sent for deauth/disassoc frame.
2518 */
2519 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002520 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002521 break;
2522 default:
2523 /*
2524 * STA is not in a state to deauthenticate with
2525 * peer. Log error and send response to host.
2526 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002527 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002528 session_entry->limSmeState);
2529 lim_print_sme_state(mac_ctx, LOGE,
2530 session_entry->limSmeState);
2531
2532 if (mac_ctx->lim.gLimRspReqd) {
2533 mac_ctx->lim.gLimRspReqd = false;
2534
2535 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2536 deauth_trigger = eLIM_HOST_DEAUTH;
2537
wadesong42968e92017-06-08 14:11:21 +08002538 /*
2539 * here we received deauth request from AP so
2540 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2541 * have ISSUED delSta then mlm state should be
2542 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2543 * delBSS rsp then mlm state should be
2544 * eLIM_MLM_IDLE_STATE so the below condition
2545 * captures the state where delSta not done
2546 * and firmware still in connected state.
2547 */
2548 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002549 eLIM_SME_WT_DEAUTH_STATE &&
2550 session_entry->limMlmState !=
2551 eLIM_MLM_IDLE_STATE &&
2552 session_entry->limMlmState !=
2553 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002554 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002555 goto send_deauth;
2556 }
2557 return;
2558 }
2559 break;
2560
2561 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002562 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002563 if (mac_ctx->lim.gLimRspReqd) {
2564 mac_ctx->lim.gLimRspReqd = false;
2565 ret_code = eSIR_SME_INVALID_PARAMETERS;
2566 deauth_trigger = eLIM_HOST_DEAUTH;
2567 goto send_deauth;
2568 }
2569 return;
2570 case eLIM_AP_ROLE:
2571 break;
2572 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002573 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002574 GET_LIM_SYSTEM_ROLE(session_entry));
2575 if (mac_ctx->lim.gLimRspReqd) {
2576 mac_ctx->lim.gLimRspReqd = false;
2577 ret_code = eSIR_SME_INVALID_PARAMETERS;
2578 deauth_trigger = eLIM_HOST_DEAUTH;
2579 goto send_deauth;
2580 }
2581 return;
2582 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2583
2584 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2585 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002586 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002587 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2588 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2589 } else {
2590 deauth_trigger = eLIM_HOST_DEAUTH;
2591 reason_code = sme_deauth_req.reasonCode;
2592 }
2593
2594 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302595 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002596 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002597 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002598 if (mac_ctx->lim.gLimRspReqd) {
2599 mac_ctx->lim.gLimRspReqd = false;
2600 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2601 deauth_trigger = eLIM_HOST_DEAUTH;
2602 goto send_deauth;
2603 }
2604 return;
2605 }
2606
Anurag Chouhanc5548422016-02-24 18:33:27 +05302607 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002608 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002609
2610 mlm_deauth_req->reasonCode = reason_code;
2611 mlm_deauth_req->deauthTrigger = deauth_trigger;
2612
2613 /* Update PE session Id */
2614 mlm_deauth_req->sessionId = session_id;
2615
2616 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2617 (uint32_t *)mlm_deauth_req);
2618 return;
2619
2620send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002621 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2622 ret_code, deauth_trigger, 1,
2623 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002624}
2625
2626/**
2627 * __lim_process_sme_set_context_req()
2628 *
2629 * @mac_ctx: Pointer to Global MAC structure
2630 * @msg_buf: pointer to the SME message buffer
2631 *
2632 * This function is called to process SME_SETCONTEXT_REQ message
2633 * from HDD or upper layer application.
2634 *
2635 * Return: None
2636 */
2637
2638static void
2639__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2640{
2641 tpSirSmeSetContextReq set_context_req;
2642 tLimMlmSetKeysReq *mlm_set_key_req;
2643 tpPESession session_entry;
2644 uint8_t session_id; /* PE sessionID */
2645 uint8_t sme_session_id;
2646 uint16_t sme_transaction_id;
2647
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002648 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002649 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002650 return;
2651 }
2652
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302653 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002654 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002655 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002656 return;
2657 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302658 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002659 sizeof(struct sSirSmeSetContextReq));
2660 sme_session_id = set_context_req->sessionId;
2661 sme_transaction_id = set_context_req->transactionId;
2662
2663 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002664 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002665 goto end;
2666 }
2667
2668 if (set_context_req->keyMaterial.numKeys >
2669 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002670 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002671 set_context_req->keyMaterial.numKeys);
2672 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002673 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002674 eSIR_SME_INVALID_PARAMETERS, NULL,
2675 sme_session_id, sme_transaction_id);
2676 goto end;
2677 }
2678
2679 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002680 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002681 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002682 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002683 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002684 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002685 eSIR_SME_INVALID_PARAMETERS, NULL,
2686 sme_session_id, sme_transaction_id);
2687 goto end;
2688 }
2689#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2690 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2691 session_entry, 0, 0);
2692#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2693
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002694 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002695 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2696 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002697 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002698 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2699 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302700 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002701 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002702 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002703 goto end;
2704 }
2705 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2706 mlm_set_key_req->numKeys =
2707 set_context_req->keyMaterial.numKeys;
2708 if (mlm_set_key_req->numKeys >
2709 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002710 pe_err("no.of keys exceeded max num of default keys limit");
Jingxiang Ge4168a232018-01-03 18:47:15 +08002711 qdf_mem_free(mlm_set_key_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002712 goto end;
2713 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302714 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002715 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002716
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302717 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002718 (uint8_t *) &set_context_req->keyMaterial.key,
2719 sizeof(tSirKeys) *
2720 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2721 numKeys : 1));
2722
2723 mlm_set_key_req->sessionId = session_id;
2724 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002725 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002726 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002727
2728 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2729 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2730 LIM_IS_AP_ROLE(session_entry)) {
2731 if (set_context_req->keyMaterial.key[0].keyLength) {
2732 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002733
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002734 key_id =
2735 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302736 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002737 &session_entry->WEPKeyMaterial[key_id],
2738 (uint8_t *) &set_context_req->keyMaterial,
2739 sizeof(tSirKeyMaterial));
2740 } else {
2741 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002742
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002743 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2744 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302745 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002746 &mlm_set_key_req->key[i],
2747 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2748 sizeof(tSirKeys));
2749 }
2750 }
2751 }
2752 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2753 (uint32_t *) mlm_set_key_req);
2754 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002755 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002756 GET_LIM_SYSTEM_ROLE(session_entry),
2757 session_entry->limSmeState);
2758 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2759
2760 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002761 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002762 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2763 session_entry, sme_session_id,
2764 sme_transaction_id);
2765 }
2766end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302767 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002768 return;
2769}
2770
2771/**
2772 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2773 *
2774 * @mac_ctx: Pointer to Global MAC structure
2775 * @msg_buf: pointer to the SME message buffer
2776 *
2777 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2778 * from HDD or upper layer application.
2779 *
2780 * Return: None
2781 */
2782
Jeff Johnson801f1532016-10-07 07:54:50 -07002783static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2784 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002785{
2786 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2787 tpDphHashNode sta_ds = NULL;
2788 tpPESession session_entry = NULL;
2789 tSap_Event sap_event;
2790 tpWLAN_SAPEventCB sap_event_cb = NULL;
2791 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2792 uint8_t session_id = CSR_SESSION_ID_INVALID;
2793 uint8_t assoc_id = 0;
2794 uint8_t sta_cnt = 0;
2795
2796 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002797 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002798 return;
2799 }
2800
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302801 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002802 sizeof(struct sSirSmeGetAssocSTAsReq));
2803 /*
2804 * Get Associated stations from PE.
2805 * Find PE session Entry
2806 */
2807 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08002808 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002809 &session_id);
2810 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002811 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002812 goto lim_assoc_sta_end;
2813 }
2814
2815 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002816 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002817 session_entry->limSmeState,
2818 GET_LIM_SYSTEM_ROLE(session_entry));
2819 goto lim_assoc_sta_end;
2820 }
2821 /* Retrieve values obtained in the request message */
2822 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
2823 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2824
2825 if (NULL == assoc_sta_tmp)
2826 goto lim_assoc_sta_end;
2827 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
2828 assoc_id++) {
2829 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
2830 &session_entry->dph.dphHashTable);
2831 if (NULL == sta_ds)
2832 continue;
2833 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302834 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002835 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302836 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002837 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
2838 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
2839
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302840 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002841 (uint8_t *)&sta_ds->supportedRates,
2842 sizeof(tSirSupportedRates));
2843 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
2844 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
2845 assoc_sta_tmp->Support40Mhz =
2846 sta_ds->htDsssCckRate40MHzSupport;
2847
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002848 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002849 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002850 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002851 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002852 pe_debug("Association Id: %d Station Index: %d",
2853 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002854 assoc_sta_tmp++;
2855 sta_cnt++;
2856 }
2857 }
2858lim_assoc_sta_end:
2859 /*
2860 * Call hdd callback with sap event to send the list of
2861 * associated stations from PE
2862 */
2863 if (sap_event_cb != NULL) {
2864 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
2865 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302866 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002867 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
2868 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
2869 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2870 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
2871 }
2872}
2873
2874/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002875 * __lim_counter_measures()
2876 *
2877 * FUNCTION:
2878 * This function is called to "implement" MIC counter measure
2879 * and is *temporary* only
2880 *
2881 * LOGIC: on AP, disassoc all STA associated thru TKIP,
2882 * we don't do the proper STA disassoc sequence since the
Jeff Johnsond460e842018-05-11 13:25:53 -07002883 * BSS will be stopped anyway
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002884 *
2885 ***ASSUMPTIONS:
2886 *
2887 ***NOTE:
2888 *
2889 * @param pMac Pointer to Global MAC structure
2890 * @return None
2891 */
2892
2893static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
2894{
2895 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002896
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002897 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002898 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
2899 mac, psessionEntry, false);
2900};
2901
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002902static void
2903__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2904{
2905 tSirSmeStopBssReq stopBssReq;
2906 tSirRetStatus status;
2907 tLimSmeStates prevState;
2908 tpPESession psessionEntry;
2909 uint8_t smesessionId;
2910 uint8_t sessionId;
2911 uint16_t smetransactionId;
2912 uint8_t i = 0;
2913 tpDphHashNode pStaDs = NULL;
2914
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302915 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002916 smesessionId = stopBssReq.sessionId;
2917 smetransactionId = stopBssReq.transactionId;
2918
2919 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002920 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002921 /* Send Stop BSS response to host */
2922 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2923 eSIR_SME_INVALID_PARAMETERS, smesessionId,
2924 smetransactionId);
2925 return;
2926 }
2927
2928 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08002929 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002930 &sessionId);
2931 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002932 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002933 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2934 eSIR_SME_INVALID_PARAMETERS, smesessionId,
2935 smetransactionId);
2936 return;
2937 }
2938#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2939 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
2940 0, 0);
2941#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2942
2943 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
2944 LIM_IS_STA_ROLE(psessionEntry)) {
2945 /**
2946 * Should not have received STOP_BSS_REQ in states
2947 * other than 'normal' state or on STA in Infrastructure
2948 * mode. Log error and return response to host.
2949 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002950 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002951 psessionEntry->limSmeState,
2952 GET_LIM_SYSTEM_ROLE(psessionEntry));
2953 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
2954 /* / Send Stop BSS response to host */
2955 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2956 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
2957 smetransactionId);
2958 return;
2959 }
2960
2961 if (LIM_IS_AP_ROLE(psessionEntry))
2962 lim_wpspbc_close(pMac, psessionEntry);
2963
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002964 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002965 stopBssReq.reasonCode);
2966
2967 prevState = psessionEntry->limSmeState;
2968
2969 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
2970 MTRACE(mac_trace
2971 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
2972 psessionEntry->limSmeState));
2973
2974 /* Update SME session Id and Transaction Id */
2975 psessionEntry->smeSessionId = smesessionId;
2976 psessionEntry->transactionId = smetransactionId;
2977
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002978 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
2979 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
2980 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002981 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002982
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002983 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
2984 /* Send disassoc all stations associated thru TKIP */
2985 __lim_counter_measures(pMac, psessionEntry);
2986 else
2987 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002988 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
2989 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002990 }
2991
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002992 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
2993 /* Free the buffer allocated in START_BSS_REQ */
2994 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
2995 psessionEntry->addIeParams.probeRespDataLen = 0;
2996 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002997
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002998 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
2999 psessionEntry->addIeParams.assocRespDataLen = 0;
3000 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003001
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003002 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3003 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3004 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003005
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003006 /*
3007 * lim_del_bss is also called as part of coalescing,
3008 * when we send DEL BSS followed by Add Bss msg.
3009 */
3010 pMac->lim.gLimIbssCoalescingHappened = false;
3011 }
Sandeep Puligillaa894ffc2018-06-01 15:33:36 -07003012 for (i = 1; i < psessionEntry->dph.dphHashTable.size; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003013 pStaDs =
3014 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3015 if (NULL == pStaDs)
3016 continue;
3017 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3018 if (eSIR_SUCCESS == status) {
3019 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3020 pStaDs->assocId, psessionEntry);
3021 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3022 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003023 pe_err("lim_del_sta failed with Status: %d", status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303024 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003025 }
3026 }
3027 /* send a delBss to HAL and wait for a response */
3028 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3029
3030 if (status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003031 pe_err("delBss failed for bss %d", psessionEntry->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003032 psessionEntry->limSmeState = prevState;
3033
3034 MTRACE(mac_trace
3035 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3036 psessionEntry->limSmeState));
3037
3038 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3039 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3040 smetransactionId);
3041 }
3042}
3043
3044/**
3045 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3046 * @pMac: Global MAC context
3047 * @pMsg: Message from SME
3048 *
3049 * Wrapper for the function __lim_handle_sme_stop_bss_request
3050 * This message will be defered until softmac come out of
3051 * scan mode. Message should be handled even if we have
3052 * detected radar in the current operating channel.
3053 *
3054 * Return: true - If we consumed the buffer
3055 * false - If have defered the message.
3056 */
3057
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003058static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3059 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003060{
3061 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3062 /**
3063 * If message defered, buffer is not consumed yet.
3064 * So return false
3065 */
3066 return false;
3067 }
3068 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3069 return true;
3070} /*** end __lim_process_sme_stop_bss_req() ***/
3071
3072void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3073 uint32_t body, tpPESession psessionEntry)
3074{
3075
3076 (void)body;
3077 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3078 lim_ibss_delete(pMac, psessionEntry);
3079 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3080 lim_delete_pre_auth_list(pMac);
3081 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3082 psessionEntry->smeSessionId,
3083 psessionEntry->transactionId);
3084 return;
3085}
3086
3087/**
3088 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3089 *
3090 * @mac_ctx: pointer to mac context
3091 * @msg_type: message type
3092 * @msg_buf: pointer to the SME message buffer
3093 *
3094 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3095 * in BTAMP AP.
3096 *
3097 * Return: None
3098 */
3099
3100void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3101 uint32_t *msg_buf)
3102{
3103 tSirSmeAssocCnf assoc_cnf;
3104 tpDphHashNode sta_ds = NULL;
3105 tpPESession session_entry = NULL;
3106 uint8_t session_id;
3107 tpSirAssocReq assoc_req;
3108
3109 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003110 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003111 goto end;
3112 }
3113
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303114 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003115 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003116 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003117 goto end;
3118 }
3119
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003120 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003121 &session_id);
3122 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003123 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003124 goto end;
3125 }
3126
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003127 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003128 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3129 (session_entry->limSmeState !=
3130 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003131 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003132 msg_type, session_entry->limSmeState,
3133 GET_LIM_SYSTEM_ROLE(session_entry));
3134 goto end;
3135 }
3136 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3137 &session_entry->dph.dphHashTable);
3138 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003139 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003140 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303141 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003142
3143 /*
3144 * send a DISASSOC_IND message to WSM to make sure
3145 * the state in WSM and LIM is the same
3146 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003147 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003148 eSIR_SME_STA_NOT_ASSOCIATED,
3149 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3150 session_entry->smeSessionId,
3151 session_entry->transactionId,
3152 session_entry);
3153 goto end;
3154 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303155 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003156 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303157 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003158 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003159 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303160 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003161 goto end;
3162 }
3163
3164 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3165 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3166 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3167 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3168 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003169 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3170 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003171 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303172 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003173 goto end;
3174 }
3175 /*
3176 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3177 * has been received
3178 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003179 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003180 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3181 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3182
3183 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3184 /*
3185 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3186 * when it had received Assoc Request frame. Now, PE just needs
3187 * to send association rsp frame to the requesting BTAMP-STA.
3188 */
3189 sta_ds->mlmStaContext.mlmState =
3190 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003191 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192 sta_ds->assocId);
3193 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3194 sta_ds->assocId, sta_ds->staAddr,
3195 sta_ds->mlmStaContext.subType, sta_ds,
3196 session_entry);
3197 goto end;
3198 } else {
3199 /*
3200 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3201 * to be associated since the HAL sta entry is created for
3202 * denied STA we need to remove this HAL entry.
3203 * So to do that set updateContext to 1
3204 */
3205 if (!sta_ds->mlmStaContext.updateContext)
3206 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003207 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003208 assoc_cnf.statusCode, sta_ds->assocId);
3209 lim_reject_association(mac_ctx, sta_ds->staAddr,
3210 sta_ds->mlmStaContext.subType,
3211 true, sta_ds->mlmStaContext.authType,
3212 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003213 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003214 session_entry);
3215 }
3216end:
3217 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3218 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3219 assoc_req = (tpSirAssocReq)
3220 session_entry->parsedAssocReq[sta_ds->assocId];
3221 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303222 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003223 assoc_req->assocReqFrame = NULL;
3224 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303225 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3227 }
3228}
3229
3230static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3231{
3232 tpDphHashNode pStaDs;
3233 tSirMacAddr peerMac;
3234 tpSirAddtsReq pSirAddts;
3235 uint32_t timeout;
3236 tpPESession psessionEntry;
3237 uint8_t sessionId; /* PE sessionId */
3238 uint8_t smesessionId;
3239 uint16_t smetransactionId;
3240
3241 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003242 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243 return;
3244 }
3245
3246 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3247 &smetransactionId);
3248
3249 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3250
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003251 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3252 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003254 pe_err("Session Does not exist for given bssId");
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303255 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3256 NULL, pSirAddts->req.tspec,
3257 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003258 return;
3259 }
3260#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3261 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3262 0);
3263#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3264
3265 /* if sta
3266 * - verify assoc state
3267 * - send addts request to ap
3268 * - wait for addts response from ap
3269 * if ap, just ignore with error log
3270 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003271 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3272 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3273 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003274
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003275 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003276 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303277 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003278 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279
3280 pStaDs =
3281 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3282 &psessionEntry->dph.dphHashTable);
3283
3284 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003285 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303286 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003287 }
3288
3289 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3290 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003291 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303292 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003293 }
3294
3295 pSirAddts->req.wsmTspecPresent = 0;
3296 pSirAddts->req.wmeTspecPresent = 0;
3297 pSirAddts->req.lleTspecPresent = 0;
3298
3299 if ((pStaDs->wsmEnabled) &&
3300 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3301 SIR_MAC_ACCESSPOLICY_EDCA))
3302 pSirAddts->req.wsmTspecPresent = 1;
3303 else if (pStaDs->wmeEnabled)
3304 pSirAddts->req.wmeTspecPresent = 1;
3305 else if (pStaDs->lleEnabled)
3306 pSirAddts->req.lleTspecPresent = 1;
3307 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003308 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303309 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003310 }
3311
3312 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3313 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003314 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003315 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303316 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003317 }
3318
3319 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003320 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321 pMac->lim.gLimAddtsReq.req.dialogToken,
3322 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3323 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3324 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303325 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003326 }
3327
3328 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3329
3330 /* save the addts request */
3331 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303332 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003333 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3334
3335 /* ship out the message now */
3336 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3337 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303338 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003339 /* start a timer to wait for the response */
3340 if (pSirAddts->timeout)
3341 timeout = pSirAddts->timeout;
3342 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3343 eSIR_SUCCESS) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303344 pe_debug("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003345 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303346 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003347 }
3348
3349 timeout = SYS_MS_TO_TICKS(timeout);
3350 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3351 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003352 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303353 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003354 }
3355 pMac->lim.gLimAddtsRspTimerCount++;
3356 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3357 pMac->lim.gLimAddtsRspTimerCount) !=
3358 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003359 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303360 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003361 }
3362 MTRACE(mac_trace
3363 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3364 eLIM_ADDTS_RSP_TIMER));
3365
3366 /* add the sessionId to the timer object */
3367 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3368 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3369 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003370 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303371 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003372 }
3373 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303374
3375send_failure_addts_rsp:
3376 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3377 psessionEntry, pSirAddts->req.tspec,
3378 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003379}
3380
3381static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3382{
3383 tSirMacAddr peerMacAddr;
3384 uint8_t ac;
3385 tSirMacTSInfo *pTsinfo;
3386 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3387 tpDphHashNode pStaDs = NULL;
3388 tpPESession psessionEntry;
3389 uint8_t sessionId;
3390 uint32_t status = eSIR_SUCCESS;
3391 uint8_t smesessionId;
3392 uint16_t smetransactionId;
3393
3394 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3395 &smetransactionId);
3396
3397 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003398 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003399 &sessionId);
3400 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003401 pe_err("Session Does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003402 status = eSIR_FAILURE;
3403 goto end;
3404 }
3405#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3406 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3407 0);
3408#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3409
3410 if (eSIR_SUCCESS !=
3411 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003412 pe_err("lim_validate_delts_req failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003413 status = eSIR_FAILURE;
3414 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3415 smesessionId, smetransactionId);
3416 return;
3417 }
3418
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003419 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3420 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003421 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3422
3423 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3424 pDeltsReq->req.wmeTspecPresent,
3425 &pDeltsReq->req.tsinfo,
3426 &pDeltsReq->req.tspec, psessionEntry);
3427
3428 pTsinfo =
3429 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3430 tsinfo : &pDeltsReq->req.tsinfo;
3431
3432 /* We've successfully send DELTS frame to AP. Update the
3433 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3434 * is no longer trigger enabled or delivery enabled
3435 */
3436 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3437 pTsinfo, CLEAR_UAPSD_MASK);
3438
3439 /* We're deleting the TSPEC, so this particular AC is no longer
3440 * admitted. PE needs to downgrade the EDCA
3441 * parameters(for the AC for which TS is being deleted) to the
3442 * next best AC for which ACM is not enabled, and send the
3443 * updated values to HAL.
3444 */
3445 ac = upToAc(pTsinfo->traffic.userPrio);
3446
3447 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3448 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3449 ~(1 << ac);
3450 } else if (pTsinfo->traffic.direction ==
3451 SIR_MAC_DIRECTION_DNLINK) {
3452 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3453 ~(1 << ac);
3454 } else if (pTsinfo->traffic.direction ==
3455 SIR_MAC_DIRECTION_BIDIR) {
3456 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3457 ~(1 << ac);
3458 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3459 ~(1 << ac);
3460 }
3461
3462 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3463 psessionEntry);
3464
3465 pStaDs =
3466 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3467 &psessionEntry->dph.dphHashTable);
3468 if (pStaDs != NULL) {
3469 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003470 pStaDs->bssId, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003471 status = eSIR_SUCCESS;
3472 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003473 pe_err("Self entry missing in Hash Table");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003474 status = eSIR_FAILURE;
3475 }
3476#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003477 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003478#endif
3479
3480 /* send an sme response back */
3481end:
3482 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3483 smesessionId, smetransactionId);
3484}
3485
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303486void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003487{
3488 /* fetch the sessionEntry based on the sessionId */
3489 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003490
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003491 psessionEntry = pe_find_session_by_session_id(pMac,
3492 pMac->lim.limTimers.gLimAddtsRspTimer.
3493 sessionId);
3494 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003495 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496 return;
3497 }
3498
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003499 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003500 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003501 GET_LIM_SYSTEM_ROLE(psessionEntry));
3502 pMac->lim.gLimAddtsSent = false;
3503 return;
3504 }
3505
3506 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003507 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003508 return;
3509 }
3510
3511 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003512 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003513 pMac->lim.gLimAddtsRspTimerCount);
3514 return;
3515 }
3516 /* this a real response timeout */
3517 pMac->lim.gLimAddtsSent = false;
3518 pMac->lim.gLimAddtsRspTimerCount++;
3519
3520 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3521 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3522 psessionEntry->smeSessionId,
3523 psessionEntry->transactionId);
3524}
3525
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003526#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003527/**
3528 * __lim_process_sme_get_statistics_request()
3529 *
3530 ***FUNCTION:
3531 *
3532 *
3533 ***NOTE:
3534 *
3535 * @param pMac Pointer to Global MAC structure
3536 * @param *pMsgBuf A pointer to the SME message buffer
3537 * @return None
3538 */
3539static void
3540__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3541{
3542 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003543 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003544
3545 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3546
3547 msgQ.type = WMA_GET_STATISTICS_REQ;
3548
3549 msgQ.reserved = 0;
3550 msgQ.bodyptr = pMsgBuf;
3551 msgQ.bodyval = 0;
3552 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3553
3554 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303555 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003556 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003557 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003558 return;
3559 }
3560
3561 return;
3562}
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003563#else
3564static void __lim_process_sme_get_statistics_request(
3565 struct sAniSirGlobal *mac_ctx, uint32_t *pMsgBuf) {}
3566#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003567
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003568#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003569/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003570 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003571 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003572 * @pMac: Pointer to Global MAC structure
3573 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003574 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003575 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003576 */
3577static void
3578__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3579{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003580 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003581
3582 msgQ.type = WMA_TSM_STATS_REQ;
3583 msgQ.reserved = 0;
3584 msgQ.bodyptr = pMsgBuf;
3585 msgQ.bodyval = 0;
3586 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3587
3588 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303589 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003590 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003591 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003592 return;
3593 }
3594}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003595#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003596
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08003597static void lim_process_sme_set_addba_accept(tpAniSirGlobal mac_ctx,
3598 struct sme_addba_accept *msg)
3599{
3600 if (!msg) {
3601 pe_err("Msg Buffer is NULL");
3602 return;
3603 }
3604 if (!msg->addba_accept)
3605 mac_ctx->reject_addba_req = 1;
3606 else
3607 mac_ctx->reject_addba_req = 0;
3608}
3609
Arif Hussaineb8ba362018-03-07 19:15:13 -08003610static void lim_process_sme_update_edca_params(tpAniSirGlobal mac_ctx,
3611 uint32_t sme_session_id)
3612{
3613 tpPESession pe_session;
3614 tpDphHashNode sta_ds_ptr;
3615
3616 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3617 if (!pe_session) {
3618 pe_err("Session does not exist: sme_id %d", sme_session_id);
3619 return;
3620 }
3621 pe_session->gLimEdcaParamsActive[EDCA_AC_BE].no_ack =
3622 mac_ctx->no_ack_policy_cfg[EDCA_AC_BE];
3623 pe_session->gLimEdcaParamsActive[EDCA_AC_BK].no_ack =
3624 mac_ctx->no_ack_policy_cfg[EDCA_AC_BK];
3625 pe_session->gLimEdcaParamsActive[EDCA_AC_VI].no_ack =
3626 mac_ctx->no_ack_policy_cfg[EDCA_AC_VI];
3627 pe_session->gLimEdcaParamsActive[EDCA_AC_VO].no_ack =
3628 mac_ctx->no_ack_policy_cfg[EDCA_AC_VO];
3629 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3630 &pe_session->dph.dphHashTable);
3631 if (sta_ds_ptr)
3632 lim_send_edca_params(mac_ctx,
3633 pe_session->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003634 sta_ds_ptr->bssId, false);
Arif Hussaineb8ba362018-03-07 19:15:13 -08003635 else
3636 pe_err("Self entry missing in Hash Table");
3637}
3638
Naveen Rawat8029a402017-06-01 10:54:19 -07003639static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3640 struct update_config *msg)
3641{
3642 tpPESession pe_session;
3643
3644 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3645 if (msg == NULL) {
3646 pe_err("Buffer is Pointing to NULL");
3647 return;
3648 }
3649
3650 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3651 msg->sme_session_id);
3652 if (pe_session == NULL) {
3653 pe_warn("Session does not exist for given BSSID");
3654 return;
3655 }
3656
3657 switch (msg->capab) {
3658 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3659 pe_session->htConfig.ht_rx_ldpc = msg->value;
3660 break;
3661 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3662 pe_session->htConfig.ht_tx_stbc = msg->value;
3663 break;
3664 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3665 pe_session->htConfig.ht_rx_stbc = msg->value;
3666 break;
3667 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3668 pe_session->htConfig.ht_sgi20 = msg->value;
3669 break;
3670 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3671 pe_session->htConfig.ht_sgi40 = msg->value;
3672 break;
3673 }
3674
3675 if (LIM_IS_AP_ROLE(pe_session)) {
3676 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3677 lim_send_beacon_ind(mac_ctx, pe_session);
3678 }
3679}
3680
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003681void
3682lim_send_vdev_restart(tpAniSirGlobal pMac,
3683 tpPESession psessionEntry, uint8_t sessionId)
3684{
3685 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003686 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003687 tSirRetStatus retCode = eSIR_SUCCESS;
3688
3689 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003690 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003691 return;
3692 }
3693
3694 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303695 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003696 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003697 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003698 return;
3699 }
3700
3701 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3702 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003703 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003704
3705 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3706 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3707 msgQ.bodyval = 0;
3708
3709 retCode = wma_post_ctrl_msg(pMac, &msgQ);
3710 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003711 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303712 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003713 }
3714}
3715
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303716/**
3717 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3718 * @mac_ctx: Pointer to Global MAC structure
3719 * @msg_buf: Pointer to SME message buffer
3720 *
3721 * Return: None
3722 */
3723static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3724 uint32_t *msg_buf)
3725{
3726 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003727 struct scheduler_msg wma_msg = {0};
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303728 tSirRetStatus status;
3729 tSirRoamOffloadScanReq *req_buffer;
3730 uint16_t local_ie_len;
3731 uint8_t *local_ie_buf;
3732
3733 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3734 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3735 req_buffer->sessionId);
3736
3737 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3738 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003739 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303740 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303741 return;
3742 }
3743
3744 local_ie_len = req_buffer->assoc_ie.length;
3745 /* Update ext cap IE if present */
3746 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003747 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3748 local_ie_buf, &local_ie_len)) {
3749 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003750 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3751 req_buffer->assoc_ie.length = local_ie_len;
3752 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3753 local_ie_buf, local_ie_len);
3754 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303755 }
3756 qdf_mem_free(local_ie_buf);
3757
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303758 if (pe_session)
3759 lim_update_fils_rik(pe_session, req_buffer);
3760
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303761 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3762 wma_msg.bodyptr = req_buffer;
3763
3764 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
3765 if (eSIR_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003766 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303767 qdf_mem_free(req_buffer);
3768 }
3769}
3770
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303771/*
3772 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3773 * @mac_ctx: Pointer to global mac context
3774 * @session: Pointer to PE session
3775 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3776 * 1 - Disable broadcast SSID
3777 *
3778 * Return: None
3779 */
3780static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3781 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003782{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003783 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003784 session->ssidHidden, ssid_hidden);
3785
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003786 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303787 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003788 } else {
3789 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05303790 return;
3791 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003792
3793 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303794 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003795
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003796 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303797}
3798
3799/**
3800 * __lim_process_sme_session_update - process SME session update msg
3801 *
3802 * @mac_ctx: Pointer to global mac context
3803 * @msg_buf: Pointer to the received message buffer
3804 *
3805 * Return: None
3806 */
3807static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
3808 uint32_t *msg_buf)
3809{
3810 struct sir_update_session_param *msg;
3811 tpPESession session;
3812
3813 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003814 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303815 return;
3816 }
3817
3818 msg = (struct sir_update_session_param *) msg_buf;
3819
3820 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
3821 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003822 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303823 msg->session_id);
3824 return;
3825 }
3826
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003827 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303828 msg->param_type, msg->param_val);
3829 switch (msg->param_type) {
3830 case SIR_PARAM_SSID_HIDDEN:
3831 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
3832 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303833 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
3834 session->ignore_assoc_disallowed = msg->param_val;
3835 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303836 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003837 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303838 break;
3839 }
3840}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003841
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003842/*
3843 Update the beacon Interval dynamically if beaconInterval is different in MCC
3844 */
3845static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3846{
3847 tpSirChangeBIParams pChangeBIParams;
3848 tpPESession psessionEntry;
3849 uint8_t sessionId = 0;
3850 tUpdateBeaconParams beaconParams;
3851
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003852 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003853
3854 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003855 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003856 return;
3857 }
3858
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303859 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003860 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
3861
3862 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08003863 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003864 &sessionId);
3865 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003866 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003867 return;
3868 }
3869
3870 /*Update sessionEntry Beacon Interval */
3871 if (psessionEntry->beaconParams.beaconInterval !=
3872 pChangeBIParams->beaconInterval) {
3873 psessionEntry->beaconParams.beaconInterval =
3874 pChangeBIParams->beaconInterval;
3875 }
3876
3877 /*Update sch beaconInterval */
3878 if (pMac->sch.schObject.gSchBeaconInterval !=
3879 pChangeBIParams->beaconInterval) {
3880 pMac->sch.schObject.gSchBeaconInterval =
3881 pChangeBIParams->beaconInterval;
3882
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003883 pe_debug("LIM send update BeaconInterval Indication: %d",
3884 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003885
3886 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
3887 /* Update beacon */
3888 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3889
3890 beaconParams.bssIdx = psessionEntry->bssIdx;
3891 /* Set change in beacon Interval */
3892 beaconParams.beaconInterval =
3893 pChangeBIParams->beaconInterval;
3894 beaconParams.paramChangeBitmap =
3895 PARAM_BCN_INTERVAL_CHANGED;
3896 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
3897 }
3898 }
3899
3900 return;
3901} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
3902
3903#ifdef QCA_HT_2040_COEX
3904static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
3905 uint32_t *pMsgBuf)
3906{
3907 tpSirSetHT2040Mode pSetHT2040Mode;
3908 tpPESession psessionEntry;
3909 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003910 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003911 tUpdateVHTOpMode *pHtOpMode = NULL;
3912 uint16_t staId = 0;
3913 tpDphHashNode pStaDs = NULL;
3914
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003915 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003916 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003917 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003918 return;
3919 }
3920
3921 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
3922
3923 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08003924 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003925 &sessionId);
3926 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003927 pe_debug("Session does not exist for given BSSID");
3928 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003929 return;
3930 }
3931
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003932 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003933 pSetHT2040Mode->cbMode);
3934 /*Update sessionEntry HT related fields */
3935 switch (pSetHT2040Mode->cbMode) {
3936 case PHY_SINGLE_CHANNEL_CENTERED:
3937 psessionEntry->htSecondaryChannelOffset =
3938 PHY_SINGLE_CHANNEL_CENTERED;
3939 psessionEntry->htRecommendedTxWidthSet = 0;
3940 if (pSetHT2040Mode->obssEnabled)
3941 psessionEntry->htSupportedChannelWidthSet
3942 = eHT_CHANNEL_WIDTH_40MHZ;
3943 else
3944 psessionEntry->htSupportedChannelWidthSet
3945 = eHT_CHANNEL_WIDTH_20MHZ;
3946 break;
3947 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
3948 psessionEntry->htSecondaryChannelOffset =
3949 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3950 psessionEntry->htRecommendedTxWidthSet = 1;
3951 break;
3952 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
3953 psessionEntry->htSecondaryChannelOffset =
3954 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3955 psessionEntry->htRecommendedTxWidthSet = 1;
3956 break;
3957 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003958 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003959 return;
3960 }
3961
3962 /* Update beacon */
3963 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3964 lim_send_beacon_ind(pMac, psessionEntry);
3965
3966 /* update OP Mode for each associated peer */
3967 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
3968 pStaDs = dph_get_hash_entry(pMac, staId,
3969 &psessionEntry->dph.dphHashTable);
3970 if (NULL == pStaDs)
3971 continue;
3972
3973 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303974 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003975 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003976 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003977 return;
3978 }
3979 pHtOpMode->opMode =
3980 (psessionEntry->htSecondaryChannelOffset ==
3981 PHY_SINGLE_CHANNEL_CENTERED) ?
3982 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
3983 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303984 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003985 sizeof(tSirMacAddr));
3986 pHtOpMode->smesessionId = sessionId;
3987
3988 msg.type = WMA_UPDATE_OP_MODE;
3989 msg.reserved = 0;
3990 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003991 if (!QDF_IS_STATUS_SUCCESS
3992 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
3993 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303994 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003995 return;
3996 }
Jeff Johnson47d75242018-05-12 15:58:53 -07003997 pe_debug("Notified FW about OP mode: %d for staId=%d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003998 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003999
4000 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004001 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004002 }
4003
4004 return;
4005}
4006#endif
4007
4008/* -------------------------------------------------------------------- */
4009/**
4010 * __lim_process_report_message
4011 *
4012 * FUNCTION: Processes the next received Radio Resource Management message
4013 *
4014 * LOGIC:
4015 *
4016 * ASSUMPTIONS:
4017 *
4018 * NOTE:
4019 *
4020 * @param None
4021 * @return None
4022 */
4023
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004024static void __lim_process_report_message(tpAniSirGlobal pMac,
4025 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004026{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004027 switch (pMsg->type) {
4028 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4029 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4030 break;
4031 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004032 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004033 break;
4034 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004035 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004036 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004037}
4038
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004039/* -------------------------------------------------------------------- */
4040/**
4041 * lim_send_set_max_tx_power_req
4042 *
4043 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4044 *
4045 * LOGIC:
4046 *
4047 * ASSUMPTIONS:
4048 *
4049 * NOTE:
4050 *
4051 * @param txPower txPower to be set.
4052 * @param pSessionEntry session entry.
4053 * @return None
4054 */
4055tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004056lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004057 tpPESession pSessionEntry)
4058{
4059 tpMaxTxPowerParams pMaxTxParams = NULL;
4060 tSirRetStatus retCode = eSIR_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004061 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004062
4063 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004064 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004065 return eSIR_FAILURE;
4066 }
4067
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304068 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004069 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004070 pe_err("Unable to allocate memory for pMaxTxParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004071 return eSIR_MEM_ALLOC_FAILED;
4072
4073 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004074 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304075 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304076 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304077 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004078 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304079 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004080
4081 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4082 msgQ.bodyptr = pMaxTxParams;
4083 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004084 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004085 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4086 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4087 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004088 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304089 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004090 }
4091 return retCode;
4092}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004093
4094/**
4095 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4096 *
4097 * @mac_ctx: Pointer to Global MAC structure
4098 * @msg_buf: pointer to the SME message buffer
4099 *
4100 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4101 * from SME. It Register this information within PE.
4102 *
4103 * Return: None
4104 */
4105static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4106 uint32_t *msg_buf)
4107{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304108 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004109 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4110 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4111 struct mgmt_frm_reg_info *next = NULL;
4112 bool match = false;
4113
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004114 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004115 sme_req->registerFrame, sme_req->frameType,
4116 sme_req->matchLen);
4117 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304118 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304119 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4120 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304121 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004122
4123 while (lim_mgmt_regn != NULL) {
4124 if (lim_mgmt_regn->frameType != sme_req->frameType)
4125 goto skip_match;
4126 if (sme_req->matchLen) {
4127 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304128 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004129 sme_req->matchData,
4130 lim_mgmt_regn->matchLen))) {
4131 /* found match! */
4132 match = true;
4133 break;
4134 }
4135 } else {
4136 /* found match! */
4137 match = true;
4138 break;
4139 }
4140skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304141 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304142 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004143 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304144 (qdf_list_node_t *)lim_mgmt_regn,
4145 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304146 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004147 lim_mgmt_regn = next;
4148 next = NULL;
4149 }
4150 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304151 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004152 if (QDF_STATUS_SUCCESS ==
4153 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004154 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004155 (qdf_list_node_t *)lim_mgmt_regn))
4156 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304157 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004158 }
4159
4160 if (sme_req->registerFrame) {
4161 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304162 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004163 sme_req->matchLen);
4164 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004165 lim_mgmt_regn->frameType = sme_req->frameType;
4166 lim_mgmt_regn->matchLen = sme_req->matchLen;
4167 lim_mgmt_regn->sessionId = sme_req->sessionId;
4168 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304169 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004170 sme_req->matchData,
4171 sme_req->matchLen);
4172 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304173 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004174 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304175 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004176 gLimMgmtFrameRegistratinQueue,
4177 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304178 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004179 &mac_ctx->lim.lim_frame_register_lock);
4180 }
4181 }
4182 return;
4183}
4184
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004185static void
4186__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4187{
4188 tpSirResetAPCapsChange pResetCapsChange;
4189 tpPESession psessionEntry;
4190 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004191
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004192 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004193 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004194 return;
4195 }
4196
4197 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4198 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004199 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4200 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004202 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004203 return;
4204 }
4205
4206 psessionEntry->limSentCapsChangeNtf = false;
4207 return;
4208}
4209
4210/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304211 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4212 * indication callback in PE.
4213 * @mac_ptr: Mac pointer
4214 * @msg_buf: Msg pointer containing the callback
4215 *
4216 * This function is used save the Management frame
4217 * indication callback in PE.
4218 *
4219 * Return: None
4220 */
4221static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4222 uint32_t *msg_buf)
4223{
4224 struct sir_sme_mgmt_frame_cb_req *sme_req =
4225 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4226
4227 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004228 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304229 return;
4230 }
4231 if (sme_req->callback)
4232 mac_ctx->mgmt_frame_ind_cb =
4233 (sir_mgmt_frame_ind_callback)sme_req->callback;
4234 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004235 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304236}
4237
4238/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304239 *__lim_process_send_disassoc_frame: function processes disassoc frame
4240 * @mac_ctx: pointer to mac context
4241 * @msg_buf: message buffer
4242 *
4243 * function processes disassoc request received from SME
4244 *
4245 * return: none
4246 */
4247static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4248 uint32_t *msg_buf)
4249{
4250 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4251 tSirRetStatus status;
4252 tpPESession session_entry = NULL;
4253 uint8_t sme_session_id;
4254 uint16_t sme_trans_id;
4255
4256 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004257 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304258 return;
4259 }
4260
4261 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4262 &sme_trans_id);
4263
4264 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4265 &sme_send_disassoc_frame_req,
4266 (uint8_t *)msg_buf);
4267
4268 if ((eSIR_FAILURE == status) ||
4269 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4270 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004271 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304272 return;
4273 }
4274
4275 session_entry = pe_find_session_by_sme_session_id(
4276 mac_ctx, sme_session_id);
4277 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004278 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304279 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4280 return;
4281 }
4282
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004283 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 +05304284 sme_send_disassoc_frame_req.msg_type,
4285 sme_send_disassoc_frame_req.length,
4286 sme_send_disassoc_frame_req.session_id,
4287 sme_send_disassoc_frame_req.trans_id,
4288 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4289 sme_send_disassoc_frame_req.reason,
4290 sme_send_disassoc_frame_req.wait_for_ack);
4291
4292 lim_send_disassoc_mgmt_frame(mac_ctx,
4293 sme_send_disassoc_frame_req.reason,
4294 sme_send_disassoc_frame_req.peer_mac,
4295 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4296}
4297
4298/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004299 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4300 * @mac_ctx: Pointer to Global MAC structure
4301 * @pdev_id: pdev id to set the IE.
4302 * @nss: Nss values to prepare the HT IE.
4303 *
4304 * Prepares the HT IE with self capabilities for different
4305 * Nss values and sends the set HT IE req to FW.
4306 *
4307 * Return: None
4308 */
4309static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4310 uint8_t nss)
4311{
4312 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004313 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004314 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004315 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004316 tHtCaps *p_ht_cap;
4317 int i;
4318
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004319 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004320 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4321 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004322 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004323 return;
4324 }
4325 ie_params->nss = i;
4326 ie_params->pdev_id = pdev_id;
4327 ie_params->ie_type = DOT11_HT_IE;
4328 /* 2 for IE len and EID */
4329 ie_params->ie_len = 2 + sizeof(tHtCaps);
4330 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4331 if (NULL == ie_params->ie_ptr) {
4332 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004333 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004334 return;
4335 }
4336 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4337 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4338 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4339 ie_params->ie_len);
4340
4341 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004342 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4343 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004344 if (NULL == p_ie) {
4345 qdf_mem_free(ie_params->ie_ptr);
4346 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004347 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004348 return;
4349 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004350 p_ht_cap = (tHtCaps *)&p_ie[2];
4351 p_ht_cap->supportedMCSSet[1] = 0;
4352 p_ht_cap->txSTBC = 0;
4353 }
4354
4355 msg.type = WMA_SET_PDEV_IE_REQ;
4356 msg.bodyptr = ie_params;
4357 msg.bodyval = 0;
4358
4359 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4360 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004361 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004362 qdf_mem_free(ie_params->ie_ptr);
4363 qdf_mem_free(ie_params);
4364 return;
4365 }
4366 }
4367}
4368
4369/**
4370 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4371 * @mac_ctx: Pointer to Global MAC structure
4372 * @pdev_id: pdev id to set the IE.
4373 * @nss: Nss values to prepare the VHT IE.
4374 *
4375 * Prepares the VHT IE with self capabilities for different
4376 * Nss values and sends the set VHT IE req to FW.
4377 *
4378 * Return: None
4379 */
4380static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4381 uint8_t nss)
4382{
4383 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004384 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004385 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004386 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004387 tSirMacVHTCapabilityInfo *vht_cap;
4388 int i;
4389 tSirVhtMcsInfo *vht_mcs;
4390
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004391 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004392 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4393 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004394 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004395 return;
4396 }
4397 ie_params->nss = i;
4398 ie_params->pdev_id = pdev_id;
4399 ie_params->ie_type = DOT11_VHT_IE;
4400 /* 2 for IE len and EID */
4401 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4402 sizeof(tSirVhtMcsInfo);
4403 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4404 if (NULL == ie_params->ie_ptr) {
4405 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004406 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004407 return;
4408 }
4409 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4410 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4411 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4412 ie_params->ie_len);
4413
4414 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004415 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4416 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004417 if (NULL == p_ie) {
4418 qdf_mem_free(ie_params->ie_ptr);
4419 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004420 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004421 return;
4422 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004423 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4424 vht_cap->txSTBC = 0;
4425 vht_mcs =
4426 (tSirVhtMcsInfo *)&p_ie[2 +
4427 sizeof(tSirMacVHTCapabilityInfo)];
4428 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4429 vht_mcs->rxHighest =
4430 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4431 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4432 vht_mcs->txHighest =
4433 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4434 }
4435 msg.type = WMA_SET_PDEV_IE_REQ;
4436 msg.bodyptr = ie_params;
4437 msg.bodyval = 0;
4438
4439 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4440 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004441 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004442 qdf_mem_free(ie_params->ie_ptr);
4443 qdf_mem_free(ie_params);
4444 return;
4445 }
4446 }
4447}
4448
4449/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004450 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4451 * @mac_ctx: Pointer to Global MAC structure
4452 * @msg_buf: Pointer to the SME message buffer
4453 *
4454 * This function is called by limProcessMessageQueue(). This function sets the
4455 * VDEV IEs to the FW.
4456 *
4457 * Return: None
4458 */
4459static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4460 uint32_t *msg_buf)
4461{
4462 struct sir_set_vdev_ies_per_band *p_msg =
4463 (struct sir_set_vdev_ies_per_band *)msg_buf;
4464
4465 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004466 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004467 return;
4468 }
4469
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004470 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004471 p_msg->vdev_id);
4472 /* intentionally using NULL here so that self capabilty are sent */
4473 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4474 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004475 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004476}
4477
4478/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004479 * lim_process_set_pdev_IEs() - process the set pdev IE req
4480 * @mac_ctx: Pointer to Global MAC structure
4481 * @msg_buf: Pointer to the SME message buffer
4482 *
4483 * This function is called by limProcessMessageQueue(). This
4484 * function sets the PDEV IEs to the FW.
4485 *
4486 * Return: None
4487 */
4488static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4489{
4490 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4491
4492 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4493
4494 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004495 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004496 return;
4497 }
4498
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004499 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004500 ht_vht_cfg->nss);
4501 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4502
4503 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4504 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4505 ht_vht_cfg->nss);
4506}
4507
4508/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304509 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4510 *
4511 * access policy
4512 * @mac_ctx: pointer to mac context
4513 * @msg: message buffer
4514 *
4515 * function processes vendor IE and access policy from SME and updates PE
4516 *
4517 * session entry
4518 *
4519 * return: none
4520*/
4521static void lim_process_sme_update_access_policy_vendor_ie(
4522 tpAniSirGlobal mac_ctx,
4523 uint32_t *msg)
4524{
4525 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4526 struct sPESession *pe_session_entry;
Pragaspathi Thilagaraj9b7a1162018-05-07 16:28:13 +05304527 uint16_t num_bytes;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304528
4529 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004530 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304531 return;
4532 }
4533 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4534 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4535 update_vendor_ie->sme_session_id);
4536
4537 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004538 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304539 update_vendor_ie->sme_session_id);
4540 return;
4541 }
4542 if (pe_session_entry->access_policy_vendor_ie)
4543 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4544
4545 num_bytes = update_vendor_ie->ie[1] + 2;
4546 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4547
4548 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004549 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304550 return;
4551 }
4552 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4553 &update_vendor_ie->ie[0], num_bytes);
4554
4555 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4556}
4557
4558/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004559 * lim_process_sme_req_messages()
4560 *
4561 ***FUNCTION:
4562 * This function is called by limProcessMessageQueue(). This
4563 * function processes SME request messages from HDD or upper layer
4564 * application.
4565 *
4566 ***LOGIC:
4567 *
4568 ***ASSUMPTIONS:
4569 *
4570 ***NOTE:
4571 *
4572 * @param pMac Pointer to Global MAC structure
4573 * @param msgType Indicates the SME message type
4574 * @param *pMsgBuf A pointer to the SME message buffer
4575 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4576 * false - if pMsgBuf is not to be freed.
4577 */
4578
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004579bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4580 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004581{
Jeff Johnson33142e62018-05-06 17:58:36 -07004582 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 -08004583 uint32_t *pMsgBuf = pMsg->bodyptr;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004584
4585 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004586 lim_msg_str(pMsg->type), pMsg->type,
4587 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4588 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004589
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004590 /* If no insert NOA required then execute the code below */
4591
4592 switch (pMsg->type) {
4593 case eWNI_SME_SYS_READY_IND:
4594 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4595 break;
4596
4597 case eWNI_SME_START_BSS_REQ:
4598 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4599 break;
4600
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004601 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4602 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4603 break;
4604 case eWNI_SME_JOIN_REQ:
4605 __lim_process_sme_join_req(pMac, pMsgBuf);
4606 break;
4607
4608 case eWNI_SME_REASSOC_REQ:
4609 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4610 break;
4611
4612 case eWNI_SME_DISASSOC_REQ:
4613 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4614 break;
4615
4616 case eWNI_SME_DISASSOC_CNF:
4617 case eWNI_SME_DEAUTH_CNF:
4618 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4619 break;
4620
4621 case eWNI_SME_DEAUTH_REQ:
4622 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4623 break;
4624
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304625 case eWNI_SME_SEND_DISASSOC_FRAME:
4626 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4627 break;
4628
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004629 case eWNI_SME_SETCONTEXT_REQ:
4630 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4631 break;
4632
4633 case eWNI_SME_STOP_BSS_REQ:
4634 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4635 break;
4636
4637 case eWNI_SME_ASSOC_CNF:
4638 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004639 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004640 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4641 pMsgBuf);
4642 break;
4643
4644 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004645 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004646 __lim_process_sme_addts_req(pMac, pMsgBuf);
4647 break;
4648
4649 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004650 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004651 __lim_process_sme_delts_req(pMac, pMsgBuf);
4652 break;
4653
4654 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004655 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004656 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4657 break;
4658
4659 case eWNI_SME_GET_STATISTICS_REQ:
4660 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4661 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4662 bufConsumed = false;
4663 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004664#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004665 case eWNI_SME_GET_TSM_STATS_REQ:
4666 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4667 bufConsumed = false;
4668 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004669#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004670 case eWNI_SME_GET_ASSOC_STAS_REQ:
4671 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4672 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304673 case eWNI_SME_SESSION_UPDATE_PARAM:
4674 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004675 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304676 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4677 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4678 bufConsumed = false;
4679 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004680 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4681 /* Update the beaconInterval */
4682 __lim_process_sme_change_bi(pMac, pMsgBuf);
4683 break;
4684
4685#ifdef QCA_HT_2040_COEX
4686 case eWNI_SME_SET_HT_2040_MODE:
4687 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4688 break;
4689#endif
4690
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004691 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4692 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4693 __lim_process_report_message(pMac, pMsg);
4694 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004695
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004696 case eWNI_SME_FT_PRE_AUTH_REQ:
4697 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4698 break;
4699 case eWNI_SME_FT_UPDATE_KEY:
4700 lim_process_ft_update_key(pMac, pMsgBuf);
4701 break;
4702
4703 case eWNI_SME_FT_AGGR_QOS_REQ:
4704 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4705 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004706
4707 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4708 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4709 break;
4710#ifdef FEATURE_WLAN_TDLS
4711 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4712 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4713 break;
4714 case eWNI_SME_TDLS_ADD_STA_REQ:
4715 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4716 break;
4717 case eWNI_SME_TDLS_DEL_STA_REQ:
4718 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4719 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004720#endif
4721 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4722 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4723 break;
4724
4725 case eWNI_SME_CHANNEL_CHANGE_REQ:
4726 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4727 break;
4728
4729 case eWNI_SME_START_BEACON_REQ:
4730 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4731 break;
4732
4733 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4734 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4735 break;
4736
4737 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4738 lim_process_update_add_ies(pMac, pMsgBuf);
4739 break;
4740
4741 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4742 lim_process_modify_add_ies(pMac, pMsgBuf);
4743 break;
4744 case eWNI_SME_SET_HW_MODE_REQ:
4745 lim_process_set_hw_mode(pMac, pMsgBuf);
4746 break;
4747 case eWNI_SME_NSS_UPDATE_REQ:
4748 lim_process_nss_update_request(pMac, pMsgBuf);
4749 break;
4750 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4751 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4752 break;
4753 case eWNI_SME_SET_IE_REQ:
4754 lim_process_set_ie_req(pMac, pMsgBuf);
4755 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304756 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4757 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
4758 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304759 case eWNI_SME_EXT_CHANGE_CHANNEL:
4760 lim_process_ext_change_channel(pMac, pMsgBuf);
4761 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08004762 case eWNI_SME_SET_ANTENNA_MODE_REQ:
4763 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
4764 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004765 case eWNI_SME_PDEV_SET_HT_VHT_IE:
4766 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07004767 break;
4768 case eWNI_SME_SET_VDEV_IES_PER_BAND:
4769 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
4770 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304771 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
4772 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
4773 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07004774 case eWNI_SME_UPDATE_CONFIG:
4775 lim_process_sme_update_config(pMac,
4776 (struct update_config *)pMsgBuf);
4777 break;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004778 case eWNI_SME_SET_ADDBA_ACCEPT:
4779 lim_process_sme_set_addba_accept(pMac,
4780 (struct sme_addba_accept *)pMsgBuf);
4781 break;
Arif Hussaineb8ba362018-03-07 19:15:13 -08004782 case eWNI_SME_UPDATE_EDCA_PROFILE:
4783 lim_process_sme_update_edca_params(pMac, pMsg->bodyval);
4784 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004785 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304786 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004787 pMsg->bodyptr = NULL;
4788 break;
4789 } /* switch (msgType) */
4790
4791 return bufConsumed;
4792} /*** end lim_process_sme_req_messages() ***/
4793
4794/**
4795 * lim_process_sme_start_beacon_req()
4796 *
4797 ***FUNCTION:
4798 * This function is called by limProcessMessageQueue(). This
4799 * function processes SME request messages from HDD or upper layer
4800 * application.
4801 *
4802 ***LOGIC:
4803 *
4804 ***ASSUMPTIONS:
4805 *
4806 ***NOTE:
4807 *
4808 * @param pMac Pointer to Global MAC structure
4809 * @param msgType Indicates the SME message type
4810 * @param *pMsgBuf A pointer to the SME message buffer
4811 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4812 * false - if pMsgBuf is not to be freed.
4813 */
4814static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
4815{
4816 tpSirStartBeaconIndication pBeaconStartInd;
4817 tpPESession psessionEntry;
4818 uint8_t sessionId; /* PE sessionID */
4819
4820 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004821 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004822 return;
4823 }
4824
4825 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
4826 psessionEntry = pe_find_session_by_bssid(pMac,
4827 pBeaconStartInd->bssid,
4828 &sessionId);
4829 if (psessionEntry == NULL) {
4830 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004831 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004832 return;
4833 }
4834
4835 if (pBeaconStartInd->beaconStartStatus == true) {
4836 /*
4837 * Currently this Indication comes from SAP
4838 * to start Beacon Tx on a DFS channel
4839 * since beaconing has to be done on DFS
4840 * channel only after CAC WAIT is completed.
4841 * On a DFS Channel LIM does not start beacon
4842 * Tx right after the WMA_ADD_BSS_RSP.
4843 */
4844 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05304845 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004846 FL("Start Beacon with ssid %s Ch %d"),
4847 psessionEntry->ssId.ssId,
4848 psessionEntry->currentOperChannel);
4849 lim_send_beacon_ind(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08004850 lim_enable_obss_detection_config(pMac, psessionEntry);
Arif Hussain05fb4872018-01-03 16:02:55 -08004851 lim_send_obss_color_collision_cfg(pMac, psessionEntry,
4852 OBSS_COLOR_COLLISION_DETECTION);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004853 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004854 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004855 return;
4856 }
4857}
4858
4859/**
4860 * lim_process_sme_channel_change_request() - process sme ch change req
4861 *
4862 * @mac_ctx: Pointer to Global MAC structure
4863 * @msg_buf: pointer to the SME message buffer
4864 *
4865 * This function is called to process SME_CHANNEL_CHANGE_REQ message
4866 *
4867 * Return: None
4868 */
4869static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
4870 uint32_t *msg_buf)
4871{
4872 tpSirChanChangeRequest ch_change_req;
4873 tpPESession session_entry;
4874 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07004875 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004876 uint32_t val = 0;
4877
4878 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004879 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004880 return;
4881 }
4882 ch_change_req = (tpSirChanChangeRequest)msg_buf;
4883
4884 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
4885 ch_change_req->targetChannel);
4886
4887 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
4888 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004889 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004890 return;
4891 }
4892
4893 session_entry = pe_find_session_by_bssid(mac_ctx,
4894 ch_change_req->bssid, &session_id);
4895 if (session_entry == NULL) {
4896 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004897 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004898 return;
4899 }
4900
Manjunathappa Prakash34fda792018-02-07 18:23:42 -08004901 if ((session_entry->currentOperChannel ==
4902 ch_change_req->targetChannel) &&
4903 (session_entry->ch_width == ch_change_req->ch_width)) {
4904 pe_err("Target channel and mode is same as current channel and mode channel %d and mode %d",
4905 session_entry->currentOperChannel, session_entry->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004906 return;
4907 }
4908
4909 if (LIM_IS_AP_ROLE(session_entry))
4910 session_entry->channelChangeReasonCode =
4911 LIM_SWITCH_CHANNEL_SAP_DFS;
4912 else
4913 session_entry->channelChangeReasonCode =
4914 LIM_SWITCH_CHANNEL_OPERATION;
4915
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004916 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004917 session_entry->currentOperChannel,
4918 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004919 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004920
4921 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004922 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004923 session_entry->ch_center_freq_seg0 =
4924 ch_change_req->center_freq_seg_0;
4925 session_entry->ch_center_freq_seg1 =
4926 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004927 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004928 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004929 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004930 session_entry->htRecommendedTxWidthSet =
4931 session_entry->htSupportedChannelWidthSet;
4932 session_entry->currentOperChannel =
4933 ch_change_req->targetChannel;
4934 session_entry->limRFBand =
4935 lim_get_rf_band(session_entry->currentOperChannel);
Vignesh Viswanathan153ae932018-04-11 14:24:13 +05304936
4937 /* Update the global beacon filter */
4938 lim_update_bcn_probe_filter(mac_ctx, session_entry);
4939
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004940 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08004941 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004942 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004943 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
4944 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004945 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004946 }
4947
4948 session_entry->lim11hEnable = val;
4949 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304950 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004951 &ch_change_req->operational_rateset,
4952 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304953 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004954 &ch_change_req->extended_rateset,
4955 sizeof(session_entry->extRateSet));
4956 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
4957 session_entry->ch_center_freq_seg0,
4958 session_entry->ch_center_freq_seg1,
4959 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07004960 max_tx_pwr, session_entry->peSessionId,
4961 ch_change_req->cac_duration_ms,
4962 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004963}
4964
4965/******************************************************************************
4966* lim_start_bss_update_add_ie_buffer()
4967*
4968***FUNCTION:
4969* This function checks the src buffer and its length and then malloc for
4970* dst buffer update the same
4971*
4972***LOGIC:
4973*
4974***ASSUMPTIONS:
4975*
4976***NOTE:
4977*
4978* @param pMac Pointer to Global MAC structure
4979* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
4980* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
4981* @param *pSrcData_buff A pointer of uint8_t src buffer
4982* @param srcDataLen src buffer length
4983******************************************************************************/
4984
4985static void
4986lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
4987 uint8_t **pDstData_buff,
4988 uint16_t *pDstDataLen,
4989 uint8_t *pSrcData_buff, uint16_t srcDataLen)
4990{
4991
4992 if (srcDataLen > 0 && pSrcData_buff != NULL) {
4993 *pDstDataLen = srcDataLen;
4994
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304995 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004996
4997 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004998 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004999 return;
5000 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305001 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005002 } else {
5003 *pDstData_buff = NULL;
5004 *pDstDataLen = 0;
5005 }
5006}
5007
5008/******************************************************************************
5009* lim_update_add_ie_buffer()
5010*
5011***FUNCTION:
5012* This function checks the src buffer and length if src buffer length more
5013* than dst buffer length then free the dst buffer and malloc for the new src
5014* length, and update the dst buffer and length. But if dst buffer is bigger
5015* than src buffer length then it just update the dst buffer and length
5016*
5017***LOGIC:
5018*
5019***ASSUMPTIONS:
5020*
5021***NOTE:
5022*
5023* @param pMac Pointer to Global MAC structure
5024* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5025* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5026* @param *pSrcData_buff A pointer of uint8_t src buffer
5027* @param srcDataLen src buffer length
5028******************************************************************************/
5029
5030static void
5031lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5032 uint8_t **pDstData_buff,
5033 uint16_t *pDstDataLen,
5034 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5035{
5036
5037 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005038 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005039 return;
5040 }
5041
5042 if (srcDataLen > *pDstDataLen) {
5043 *pDstDataLen = srcDataLen;
5044 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305045 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005046 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305047 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005048
5049 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005050 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005051 *pDstDataLen = 0;
5052 return;
5053 }
5054 }
5055
5056 /* copy the content of buffer into dst buffer
5057 */
5058 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305059 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005060
5061}
5062
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005063/**
5064 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5065 * @pMac : Pointer to Global MAC structure
5066 * @pDstData_buff : A pointer to pointer of dst buffer
5067 * @pDstDataLen : A pointer to pointer of dst buffer length
5068 * @pModifyIE : A pointer to tSirModifyIE
5069 *
5070 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5071 *
5072 * Return:
5073 * True or false depending upon whether IE is updated or not
5074 */
5075static bool
5076lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5077 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5078{
Hong Shi1553d692016-09-28 12:16:19 +08005079 int32_t oui_length;
5080 uint8_t *ibss_ie = NULL;
5081 uint8_t *vendor_ie;
5082#define MAC_VENDOR_OUI "\x00\x16\x32"
5083#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005084
5085 ibss_ie = pModifyIE->pIEBuffer;
5086 oui_length = pModifyIE->oui_length;
5087
5088 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005089 pe_err("Invalid set IBSS vendor IE command length %d",
5090 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005091 return false;
5092 }
5093
Hong Shi1553d692016-09-28 12:16:19 +08005094 /*
5095 * Why replace only beacon OUI data here:
5096 * 1. other ie (such as wpa) shall not be overwritten here.
5097 * 2. per spec, beacon oui ie might be set twice and original one
5098 * shall be updated.
5099 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005100 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005101 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5102 if (vendor_ie) {
5103 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5104 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5105 pModifyIE->ieBufferlength);
5106 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005107 uint16_t new_length;
5108 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005109
Naveen Rawat668dee32017-09-29 14:39:40 -07005110 /*
5111 * check for uint16 overflow before using sum of two numbers as
5112 * length of size to malloc
5113 */
5114 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5115 pe_err("U16 overflow due to %d + %d",
5116 pModifyIE->ieBufferlength, *pDstDataLen);
5117 return false;
5118 }
5119
5120 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5121 new_ptr = qdf_mem_malloc(new_length);
Hong Shi1553d692016-09-28 12:16:19 +08005122 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005123 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005124 return false;
5125 }
5126 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5127 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5128 pModifyIE->ieBufferlength);
5129 qdf_mem_free(*pDstData_buff);
5130 *pDstDataLen = new_length;
5131 *pDstData_buff = new_ptr;
5132 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005133 return true;
5134}
5135
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005136/*
5137* lim_process_modify_add_ies() - process modify additional IE req.
5138*
5139* @mac_ctx: Pointer to Global MAC structure
5140* @msg_buf: pointer to the SME message buffer
5141*
5142* This function update the PE buffers for additional IEs.
5143*
5144* Return: None
5145*/
5146static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5147 uint32_t *msg_buf)
5148{
5149 tpSirModifyIEsInd modify_add_ies;
5150 tpPESession session_entry;
5151 uint8_t session_id;
5152 bool ret = false;
5153 tSirAddIeParams *add_ie_params;
5154
5155 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005156 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005157 return;
5158 }
5159
5160 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5161 /* Incoming message has smeSession, use BSSID to find PE session */
5162 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005163 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005164
5165 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005166 pe_err("Session not found for given bssid"
5167 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005168 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005169 goto end;
5170 }
5171 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5172 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5173 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005174 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005175 modify_add_ies->modifyIE.pIEBuffer,
5176 modify_add_ies->modifyIE.ieBufferlength,
5177 modify_add_ies->modifyIE.ieID,
5178 modify_add_ies->modifyIE.ieIDLen,
5179 modify_add_ies->updateType);
5180 goto end;
5181 }
5182 add_ie_params = &session_entry->addIeParams;
5183 switch (modify_add_ies->updateType) {
5184 case eUPDATE_IE_PROBE_RESP:
5185 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005186 if (LIM_IS_IBSS_ROLE(session_entry)) {
5187 lim_update_ibss_prop_add_ies(mac_ctx,
5188 &add_ie_params->probeRespData_buff,
5189 &add_ie_params->probeRespDataLen,
5190 &modify_add_ies->modifyIE);
5191 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005192 break;
5193 case eUPDATE_IE_ASSOC_RESP:
5194 /* assoc resp IE */
5195 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305196 QDF_TRACE(QDF_MODULE_ID_PE,
5197 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005198 "assoc resp add ie not present %d"),
5199 add_ie_params->assocRespDataLen);
5200 }
5201 /* search through the buffer and modify the IE */
5202 break;
5203 case eUPDATE_IE_PROBE_BCN:
5204 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005205 if (LIM_IS_IBSS_ROLE(session_entry)) {
5206 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5207 &add_ie_params->probeRespBCNData_buff,
5208 &add_ie_params->probeRespBCNDataLen,
5209 &modify_add_ies->modifyIE);
5210 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005211 if (ret == true && modify_add_ies->modifyIE.notify) {
5212 lim_handle_param_update(mac_ctx,
5213 modify_add_ies->updateType);
5214 }
5215 break;
5216 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005217 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005218 modify_add_ies->updateType);
5219 break;
5220 }
5221end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305222 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005223 modify_add_ies->modifyIE.pIEBuffer = NULL;
5224}
5225
5226/*
5227* lim_process_update_add_ies() - process additional IE update req
5228*
5229* @mac_ctx: Pointer to Global MAC structure
5230* @msg_buf: pointer to the SME message buffer
5231*
5232* This function update the PE buffers for additional IEs.
5233*
5234* Return: None
5235*/
5236static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5237 uint32_t *msg_buf)
5238{
5239 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5240 uint8_t session_id;
5241 tpPESession session_entry;
5242 tSirAddIeParams *addn_ie;
5243 uint16_t new_length = 0;
5244 uint8_t *new_ptr = NULL;
5245 tSirUpdateIE *update_ie;
5246
5247 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005248 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005249 return;
5250 }
5251 update_ie = &update_add_ies->updateIE;
5252 /* incoming message has smeSession, use BSSID to find PE session */
5253 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005254 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005255
5256 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005257 pe_err("Session not found for given bssid"
5258 MAC_ADDRESS_STR,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005259 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005260 goto end;
5261 }
5262 addn_ie = &session_entry->addIeParams;
5263 /* if len is 0, upper layer requested freeing of buffer */
5264 if (0 == update_ie->ieBufferlength) {
5265 switch (update_add_ies->updateType) {
5266 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305267 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005268 addn_ie->probeRespData_buff = NULL;
5269 addn_ie->probeRespDataLen = 0;
5270 break;
5271 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305272 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005273 addn_ie->assocRespData_buff = NULL;
5274 addn_ie->assocRespDataLen = 0;
5275 break;
5276 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305277 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005278 addn_ie->probeRespBCNData_buff = NULL;
5279 addn_ie->probeRespBCNDataLen = 0;
5280
5281 if (update_ie->notify)
5282 lim_handle_param_update(mac_ctx,
5283 update_add_ies->updateType);
5284 break;
5285 default:
5286 break;
5287 }
5288 return;
5289 }
5290 switch (update_add_ies->updateType) {
5291 case eUPDATE_IE_PROBE_RESP:
5292 if (update_ie->append) {
5293 /*
5294 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005295 * with combined length.
5296 * Multiple back to back append commands
5297 * can lead to a huge length.So, check
5298 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005299 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005300 if (addn_ie->probeRespDataLen >
5301 (USHRT_MAX - update_ie->ieBufferlength)) {
5302 pe_err("IE Length overflow, curr:%d, new:%d",
5303 addn_ie->probeRespDataLen,
5304 update_ie->ieBufferlength);
5305 goto end;
5306 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005307 new_length = update_ie->ieBufferlength +
5308 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305309 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005310 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005311 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005312 goto end;
5313 }
5314 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305315 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005316 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305317 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005318 update_ie->pAdditionIEBuffer,
5319 update_ie->ieBufferlength);
5320 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305321 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005322 /* adjust length accordingly */
5323 addn_ie->probeRespDataLen = new_length;
5324 /* save refernece of local buffer in PE session */
5325 addn_ie->probeRespData_buff = new_ptr;
5326 goto end;
5327 }
5328 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5329 &addn_ie->probeRespDataLen,
5330 update_ie->pAdditionIEBuffer,
5331 update_ie->ieBufferlength);
5332 break;
5333 case eUPDATE_IE_ASSOC_RESP:
5334 /* assoc resp IE */
5335 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5336 &addn_ie->assocRespDataLen,
5337 update_ie->pAdditionIEBuffer,
5338 update_ie->ieBufferlength);
5339 break;
5340 case eUPDATE_IE_PROBE_BCN:
5341 /* probe resp Bcn IE */
5342 lim_update_add_ie_buffer(mac_ctx,
5343 &addn_ie->probeRespBCNData_buff,
5344 &addn_ie->probeRespBCNDataLen,
5345 update_ie->pAdditionIEBuffer,
5346 update_ie->ieBufferlength);
5347 if (update_ie->notify)
5348 lim_handle_param_update(mac_ctx,
5349 update_add_ies->updateType);
5350 break;
5351 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005352 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005353 break;
5354 }
5355end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305356 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005357 update_ie->pAdditionIEBuffer = NULL;
5358}
5359
5360/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305361 * send_extended_chan_switch_action_frame()- function to send ECSA
5362 * action frame for each sta connected to SAP/GO and AP in case of
5363 * STA .
5364 * @mac_ctx: pointer to global mac structure
5365 * @new_channel: new channel to switch to.
5366 * @ch_bandwidth: BW of channel to calculate op_class
5367 * @session_entry: pe session
5368 *
5369 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5370 *
5371 * Return: void
5372 */
5373
5374static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5375 uint16_t new_channel, uint8_t ch_bandwidth,
5376 tpPESession session_entry)
5377{
5378 uint16_t op_class;
5379 uint8_t switch_mode = 0, i;
5380 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005381 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305382
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005383 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305384 mac_ctx->scan.countryCodeCurrent,
5385 new_channel,
5386 ch_bandwidth);
5387
5388 if (LIM_IS_AP_ROLE(session_entry) &&
5389 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005390 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305391
gaoleze2920bd2017-03-21 17:38:42 +08005392 switch_count = session_entry->gLimChannelSwitch.switchCount;
5393
Abhishek Singh518323d2015-10-19 17:42:01 +05305394 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005395 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305396 psta =
5397 session_entry->dph.dphHashTable.pDphNodeArray + i;
5398 if (psta && psta->added)
5399 lim_send_extended_chan_switch_action_frame(
5400 mac_ctx,
5401 psta->staAddr,
5402 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005403 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305404 }
5405 } else if (LIM_IS_STA_ROLE(session_entry)) {
5406 lim_send_extended_chan_switch_action_frame(mac_ctx,
5407 session_entry->bssId,
5408 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005409 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305410 }
5411
5412}
5413
gaolez76d2a162017-03-21 19:23:58 +08005414void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5415 uint16_t new_channel,
5416 uint8_t ch_bandwidth,
5417 tpPESession session_entry)
5418{
5419 uint16_t op_class;
5420 uint8_t switch_mode = 0, i;
5421 uint8_t switch_count;
5422 tpDphHashNode psta;
5423 tpDphHashNode dph_node_array_ptr;
5424
5425 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5426
5427 op_class = wlan_reg_dmn_get_opclass_from_channel(
5428 mac_ctx->scan.countryCodeCurrent,
5429 new_channel, ch_bandwidth);
5430
5431 if (LIM_IS_AP_ROLE(session_entry) &&
5432 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5433 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5434
5435 switch_count = session_entry->gLimChannelSwitch.switchCount;
5436
5437 if (LIM_IS_AP_ROLE(session_entry)) {
5438 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5439 psta = dph_node_array_ptr + i;
5440 if (!(psta && psta->added))
5441 continue;
5442 if (session_entry->lim_non_ecsa_cap_num == 0)
5443 lim_send_extended_chan_switch_action_frame
5444 (mac_ctx, psta->staAddr, switch_mode,
5445 op_class, new_channel, switch_count,
5446 session_entry);
5447 else
5448 lim_send_channel_switch_mgmt_frame
5449 (mac_ctx, psta->staAddr, switch_mode,
5450 new_channel, switch_count,
5451 session_entry);
5452 }
5453 } else if (LIM_IS_STA_ROLE(session_entry)) {
5454 lim_send_extended_chan_switch_action_frame
5455 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5456 new_channel, switch_count, session_entry);
5457 }
5458}
5459
5460/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005461 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5462 *
5463 * @mac_ctx: Pointer to Global MAC structure
5464 * @msg_buf: pointer to the SME message buffer
5465 *
5466 * This function processes SME request messages from HDD or upper layer
5467 * application.
5468 *
5469 * Return: None
5470 */
5471static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5472 uint32_t *msg_buf)
5473{
5474 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5475 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005476 uint8_t session_id;
5477 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005478 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005479
5480 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005481 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005482 return;
5483 }
5484
5485 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5486 session_entry = pe_find_session_by_bssid(mac_ctx,
5487 dfs_csa_ie_req->bssid, &session_id);
5488 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005489 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005490 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5491 return;
5492 }
5493
5494 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005495 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005496 GET_LIM_SYSTEM_ROLE(session_entry));
5497 return;
5498 }
5499
5500 /* target channel */
5501 session_entry->gLimChannelSwitch.primaryChannel =
5502 dfs_csa_ie_req->targetChannel;
5503
5504 /* Channel switch announcement needs to be included in beacon */
5505 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005506 session_entry->gLimChannelSwitch.switchCount =
5507 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005508 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005509 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305510 session_entry->gLimChannelSwitch.sec_ch_offset =
5511 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005512 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005513 session_entry->gLimChannelSwitch.switchMode =
5514 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005515
5516 /*
5517 * Validate if SAP is operating HT or VHT mode and set the Channel
5518 * Switch Wrapper element with the Wide Band Switch subelement.
5519 */
5520 if (true != session_entry->vhtCapability)
5521 goto skip_vht;
5522
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005523 /* Now encode the Wider Ch BW element depending on the ch width */
5524 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005525 switch (dfs_csa_ie_req->ch_params.ch_width) {
5526 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005527 /*
5528 * Wide channel BW sublement in channel wrapper element is not
5529 * required in case of 20 Mhz operation. Currently It is set
5530 * only set in case of 40/80 Mhz Operation.
5531 */
5532 session_entry->dfsIncludeChanWrapperIe = false;
5533 wider_bw_ch_switch->newChanWidth =
5534 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5535 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005536 case CH_WIDTH_40MHZ:
5537 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005538 wider_bw_ch_switch->newChanWidth =
5539 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5540 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005541 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005542 session_entry->dfsIncludeChanWrapperIe = true;
5543 wider_bw_ch_switch->newChanWidth =
5544 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5545 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005546 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005547 session_entry->dfsIncludeChanWrapperIe = true;
5548 wider_bw_ch_switch->newChanWidth =
5549 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5550 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005551 case CH_WIDTH_80P80MHZ:
5552 session_entry->dfsIncludeChanWrapperIe = true;
5553 wider_bw_ch_switch->newChanWidth =
5554 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005555 /*
5556 * This is not applicable for 20/40/80 Mhz.
5557 * Only used when we support 80+80 Mhz operation.
5558 * In case of 80+80 Mhz, this parameter indicates
5559 * center channel frequency index of 80 Mhz channel of
5560 * frequency segment 1.
5561 */
5562 wider_bw_ch_switch->newCenterChanFreq1 =
5563 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005564 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005565 default:
5566 session_entry->dfsIncludeChanWrapperIe = false;
5567 /*
5568 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5569 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5570 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005571 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005572 break;
5573 }
5574 /* Fetch the center channel based on the channel width */
5575 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005576 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005577skip_vht:
5578 /* Send CSA IE request from here */
5579 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5580 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005581 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005582 return;
5583 }
5584
5585 /*
5586 * First beacon update request is sent here, the remaining updates are
5587 * done when the FW responds back after sending the first beacon after
5588 * the template update
5589 */
5590 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305591
5592 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5593 ch_offset = BW80;
5594 else
5595 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5596
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005597 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305598 session_entry->gLimChannelSwitch.switchCount,
5599 session_entry->gLimChannelSwitch.primaryChannel,
5600 session_entry->gLimChannelSwitch.ch_width,
5601 session_entry->dfsIncludeChanWrapperIe,
5602 ch_offset);
5603
gaolez76d2a162017-03-21 19:23:58 +08005604 /* Send ECSA/CSA Action frame after updating the beacon */
5605 if (CHAN_HOP_ALL_BANDS_ENABLE)
5606 lim_send_chan_switch_action_frame(mac_ctx,
5607 session_entry->gLimChannelSwitch.primaryChannel,
5608 ch_offset, session_entry);
5609 else
5610 send_extended_chan_switch_action_frame(mac_ctx,
5611 session_entry->gLimChannelSwitch.primaryChannel,
5612 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005613}
5614
5615/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305616 * lim_process_ext_change_channel()- function to send ECSA
5617 * action frame for STA/CLI .
5618 * @mac_ctx: pointer to global mac structure
5619 * @msg: params from sme for new channel.
5620 *
5621 * This function is called to send ECSA frame for STA/CLI.
5622 *
5623 * Return: void
5624 */
5625
5626static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5627 uint32_t *msg)
5628{
5629 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5630 (struct sir_sme_ext_cng_chan_req *) msg;
5631 tpPESession session_entry = NULL;
5632
5633 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005634 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305635 return;
5636 }
5637 session_entry =
5638 pe_find_session_by_sme_session_id(mac_ctx,
5639 ext_chng_channel->session_id);
5640 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005641 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305642 ext_chng_channel->session_id);
5643 return;
5644 }
5645 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005646 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305647 return;
5648 }
5649 send_extended_chan_switch_action_frame(mac_ctx,
5650 ext_chng_channel->new_channel,
5651 0, session_entry);
5652}
5653
5654/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005655 * lim_process_nss_update_request() - process sme nss update req
5656 *
5657 * @mac_ctx: Pointer to Global MAC structure
5658 * @msg_buf: pointer to the SME message buffer
5659 *
5660 * This function processes SME request messages from HDD or upper layer
5661 * application.
5662 *
5663 * Return: None
5664 */
5665static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5666 uint32_t *msg_buf)
5667{
5668 struct sir_nss_update_request *nss_update_req_ptr;
5669 tpPESession session_entry = NULL;
5670
5671 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005672 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005673 return;
5674 }
5675
5676 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305677 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005678 nss_update_req_ptr->vdev_id);
5679 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005680 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005681 nss_update_req_ptr->vdev_id);
5682 return;
5683 }
5684
5685 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005686 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005687 GET_LIM_SYSTEM_ROLE(session_entry));
5688 return;
5689 }
5690
5691 /* populate nss field in the beacon */
5692 session_entry->gLimOperatingMode.present = 1;
5693 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05305694 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
5695
5696 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
5697 (session_entry->ch_width > CH_WIDTH_80MHZ))
5698 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
5699
5700 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
5701
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005702 /* Send nss update request from here */
5703 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5704 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005705 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005706 return;
5707 }
5708
5709 lim_send_beacon_ind(mac_ctx, session_entry);
5710}
5711
5712/**
5713 * lim_process_set_ie_req() - process sme set IE request
5714 *
5715 * @mac_ctx: Pointer to Global MAC structure
5716 * @msg_buf: pointer to the SME message buffer
5717 *
5718 * This function processes SME request messages from HDD or upper layer
5719 * application.
5720 *
5721 * Return: None
5722 */
5723static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5724{
5725 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305726 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005727
5728 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005729 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005730 return;
5731 }
5732
5733 msg = (struct send_extcap_ie *)msg_buf;
5734 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305735 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005736 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005737
5738}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005739
5740#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Arif Hussain05fb4872018-01-03 16:02:55 -08005741
5742/**
5743 * obss_color_collision_process_color_disable() - Disable bss color
5744 * @mac_ctx: Pointer to Global MAC structure
5745 * @session: pointer to session
5746 *
5747 * This function will disbale bss color.
5748 *
5749 * Return: None
5750 */
5751static void obss_color_collision_process_color_disable(tpAniSirGlobal mac_ctx,
5752 tpPESession session)
5753{
5754 tUpdateBeaconParams beacon_params;
5755
5756 if (!session) {
5757 pe_err("Invalid session");
5758 return;
5759 }
5760
5761 if (session->valid && !LIM_IS_AP_ROLE(session)) {
5762 pe_err("Invalid SystemRole %d",
5763 GET_LIM_SYSTEM_ROLE(session));
5764 return;
5765 }
5766
5767 if (session->bss_color_changing == 1) {
5768 pe_warn("%d: color change in progress", session->smeSessionId);
5769 /* Continue color collision detection */
5770 lim_send_obss_color_collision_cfg(mac_ctx, session,
5771 OBSS_COLOR_COLLISION_DETECTION);
5772 return;
5773 }
5774
5775 if (session->he_op.bss_col_disabled == 1) {
5776 pe_warn("%d: bss color already disabled",
5777 session->smeSessionId);
5778 /* Continue free color detection */
5779 lim_send_obss_color_collision_cfg(mac_ctx, session,
5780 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5781 return;
5782 }
5783
5784 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5785 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5786 session->he_op.bss_col_disabled = 1;
Arif Hussain05fb4872018-01-03 16:02:55 -08005787 beacon_params.bss_color_disabled = 1;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005788 beacon_params.bss_color = session->he_op.bss_color;
Arif Hussain05fb4872018-01-03 16:02:55 -08005789
5790 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
5791 eSIR_SUCCESS) {
5792 pe_err("Unable to set op mode IE in beacon");
5793 return;
5794 }
5795
5796 lim_send_beacon_params(mac_ctx, &beacon_params, session);
5797 lim_send_obss_color_collision_cfg(mac_ctx, session,
5798 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5799}
5800
5801/**
5802 * obss_color_collision_process_color_change() - Process bss color change
5803 * @mac_ctx: Pointer to Global MAC structure
5804 * @session: pointer to session
5805 * @obss_color_info: obss color collision/free slot indication info
5806 *
5807 * This function selects new color ib case of bss color collision.
5808 *
5809 * Return: None
5810 */
5811static void obss_color_collision_process_color_change(tpAniSirGlobal mac_ctx,
5812 tpPESession session,
5813 struct wmi_obss_color_collision_info *obss_color_info)
5814{
5815 int i, num_bss_color = 0;
5816 uint32_t bss_color_bitmap;
5817 uint8_t bss_color_index_array[MAX_BSS_COLOR_VALUE];
5818 uint32_t rand_byte = 0;
5819 struct sir_set_he_bss_color he_bss_color;
5820 bool is_color_collision = false;
5821
5822
5823 if (session->bss_color_changing == 1) {
5824 pe_err("%d: color change in progress", session->smeSessionId);
5825 return;
5826 }
5827
5828 if (!session->he_op.bss_col_disabled) {
5829 if (session->he_op.bss_color < 32)
5830 is_color_collision = (obss_color_info->
5831 obss_color_bitmap_bit0to31 >>
5832 session->he_op.bss_color) & 0x01;
5833 else
5834 is_color_collision = (obss_color_info->
5835 obss_color_bitmap_bit32to63 >>
5836 (session->he_op.bss_color -
Arif Hussain9e8c5612018-04-12 16:35:48 -07005837 32)) & 0x01;
Arif Hussain05fb4872018-01-03 16:02:55 -08005838 if (!is_color_collision) {
5839 pe_err("%d: color collision not found, curr_color: %d",
5840 session->smeSessionId,
5841 session->he_op.bss_color);
5842 return;
5843 }
5844 }
5845
5846 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit0to31;
5847
5848 /* Skip color zero */
5849 bss_color_bitmap = bss_color_bitmap >> 1;
5850 for (i = 0; (i < 31) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5851 if (!(bss_color_bitmap & 0x01)) {
5852 bss_color_index_array[num_bss_color] = i + 1;
5853 num_bss_color++;
5854 }
5855 bss_color_bitmap = bss_color_bitmap >> 1;
5856 }
5857
5858 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit32to63;
5859 for (i = 0; (i < 32) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5860 if (!(bss_color_bitmap & 0x01)) {
5861 bss_color_index_array[num_bss_color] = i + 32;
5862 num_bss_color++;
5863 }
5864 bss_color_bitmap = bss_color_bitmap >> 1;
5865 }
5866
5867 if (num_bss_color) {
5868 qdf_get_random_bytes((void *) &rand_byte, 1);
5869 i = (rand_byte + qdf_mc_timer_get_system_ticks()) %
5870 num_bss_color;
5871 pe_debug("New bss color = %d", bss_color_index_array[i]);
5872 he_bss_color.session_id = obss_color_info->vdev_id;
5873 he_bss_color.bss_color = bss_color_index_array[i];
5874 lim_process_set_he_bss_color(mac_ctx,
5875 (uint32_t *)&he_bss_color);
5876 } else {
5877 pe_err("Unable to find bss color from bitmasp");
5878 if (obss_color_info->evt_type ==
5879 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY &&
5880 session->obss_color_collision_dec_evt ==
5881 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
5882 /* In dot11BSSColorCollisionAPPeriod and
5883 * timer expired, time to disable bss color.
5884 */
5885 obss_color_collision_process_color_disable(mac_ctx,
5886 session);
5887 else
5888 /*
5889 * Enter dot11BSSColorCollisionAPPeriod period.
5890 */
5891 lim_send_obss_color_collision_cfg(mac_ctx, session,
5892 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY);
5893 }
5894}
5895
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005896void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5897{
5898 struct sir_set_he_bss_color *bss_color;
5899 tpPESession session_entry = NULL;
5900 tUpdateBeaconParams beacon_params;
5901
5902 if (!msg_buf) {
5903 pe_err("Buffer is Pointing to NULL");
5904 return;
5905 }
5906
5907 bss_color = (struct sir_set_he_bss_color *)msg_buf;
5908 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5909 bss_color->session_id);
5910 if (!session_entry) {
5911 pe_err("Session not found for given session_id %d",
5912 bss_color->session_id);
5913 return;
5914 }
5915
5916 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5917 pe_err("Invalid SystemRole %d",
5918 GET_LIM_SYSTEM_ROLE(session_entry));
5919 return;
5920 }
5921
5922 if (bss_color->bss_color == session_entry->he_op.bss_color) {
5923 pe_err("No change in BSS color, current BSS color %d",
5924 bss_color->bss_color);
5925 return;
5926 }
5927 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5928 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5929 session_entry->he_op.bss_col_disabled = 1;
5930 session_entry->he_bss_color_change.countdown =
5931 BSS_COLOR_SWITCH_COUNTDOWN;
5932 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005933 beacon_params.bss_color_disabled = 1;
5934 beacon_params.bss_color = session_entry->he_op.bss_color;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005935 session_entry->bss_color_changing = 1;
5936
5937 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5938 eSIR_SUCCESS) {
5939 pe_err("Unable to set op mode IE in beacon");
5940 return;
5941 }
5942
5943 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
Arif Hussain05fb4872018-01-03 16:02:55 -08005944 lim_send_obss_color_collision_cfg(mac_ctx, session_entry,
5945 OBSS_COLOR_COLLISION_DETECTION_DISABLE);
5946}
5947
5948void lim_send_obss_color_collision_cfg(tpAniSirGlobal mac_ctx,
5949 tpPESession session,
5950 enum wmi_obss_color_collision_evt_type
5951 event_type)
5952{
5953 struct wmi_obss_color_collision_cfg_param *cfg_param;
5954 struct scheduler_msg msg = {0};
5955
5956 if (!session) {
5957 pe_err("Invalid session");
5958 return;
5959 }
5960
5961 if (!session->he_capable ||
5962 !session->is_session_obss_color_collision_det_enabled) {
5963 pe_debug("%d: obss color det not enabled, he_cap:%d, sup:%d:%d",
5964 session->smeSessionId, session->he_capable,
5965 session->is_session_obss_color_collision_det_enabled,
5966 mac_ctx->lim.global_obss_color_collision_det_offload);
5967 return;
5968 }
5969
5970 cfg_param = qdf_mem_malloc(sizeof(*cfg_param));
5971 if (!cfg_param) {
5972 pe_err("Failed to allocate memory");
5973 return;
5974 }
5975
5976 pe_debug("%d: sending event:%d", session->smeSessionId, event_type);
5977 qdf_mem_zero(cfg_param, sizeof(*cfg_param));
5978 cfg_param->vdev_id = session->smeSessionId;
5979 cfg_param->evt_type = event_type;
5980 if (LIM_IS_AP_ROLE(session))
5981 cfg_param->detection_period_ms =
5982 OBSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS;
5983 else
5984 cfg_param->detection_period_ms =
5985 OBSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS;
5986
5987 cfg_param->scan_period_ms = OBSS_COLOR_COLLISION_SCAN_PERIOD_MS;
5988 if (event_type == OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
5989 cfg_param->free_slot_expiry_time_ms =
5990 OBSS_COLOR_COLLISION_FREE_SLOT_EXPIRY_MS;
5991
5992 msg.type = WMA_OBSS_COLOR_COLLISION_REQ;
5993 msg.bodyptr = cfg_param;
5994 msg.reserved = 0;
5995
5996 if (QDF_IS_STATUS_ERROR(scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
5997 pe_err("Failed to post WMA_OBSS_COLOR_COLLISION_REQ to WMA");
5998 qdf_mem_free(cfg_param);
5999 } else {
6000 session->obss_color_collision_dec_evt = event_type;
6001 }
6002}
6003
6004void lim_process_obss_color_collision_info(tpAniSirGlobal mac_ctx,
6005 uint32_t *msg_buf)
6006{
6007 struct wmi_obss_color_collision_info *obss_color_info;
6008 tpPESession session;
6009
6010 if (!msg_buf) {
6011 pe_err("Buffer is Pointing to NULL");
6012 return;
6013 }
6014
6015 obss_color_info = (struct wmi_obss_color_collision_info *)msg_buf;
6016 session = pe_find_session_by_sme_session_id(mac_ctx,
6017 obss_color_info->vdev_id);
6018 if (!session) {
6019 pe_err("Session not found for given session_id %d",
6020 obss_color_info->vdev_id);
6021 return;
6022 }
6023
6024 pe_debug("vdev_id:%d, evt:%d:%d, 0to31:0x%x, 32to63:0x%x, cap:%d:%d:%d",
6025 obss_color_info->vdev_id,
6026 obss_color_info->evt_type,
6027 session->obss_color_collision_dec_evt,
6028 obss_color_info->obss_color_bitmap_bit0to31,
6029 obss_color_info->obss_color_bitmap_bit32to63,
6030 session->he_capable,
6031 session->is_session_obss_color_collision_det_enabled,
6032 mac_ctx->lim.global_obss_color_collision_det_offload);
6033
6034 if (!session->he_capable ||
6035 !session->is_session_obss_color_collision_det_enabled) {
6036 return;
6037 }
6038
6039 switch (obss_color_info->evt_type) {
6040 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
6041 pe_err("%d: FW disabled obss color det. he_cap:%d, sup:%d:%d",
6042 session->smeSessionId, session->he_capable,
6043 session->is_session_obss_color_collision_det_enabled,
6044 mac_ctx->lim.global_obss_color_collision_det_offload);
6045 session->is_session_obss_color_collision_det_enabled = false;
6046 return;
6047 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
6048 case OBSS_COLOR_COLLISION_DETECTION:
6049 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
6050 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6051 pe_debug("Invalid System Role %d",
6052 GET_LIM_SYSTEM_ROLE(session));
6053 return;
6054 }
6055
6056 if (session->obss_color_collision_dec_evt !=
6057 obss_color_info->evt_type) {
6058 pe_debug("%d: Wrong event: %d, skiping",
6059 obss_color_info->vdev_id,
6060 obss_color_info->evt_type);
6061 return;
6062 }
6063 obss_color_collision_process_color_change(mac_ctx, session,
6064 obss_color_info);
6065 break;
6066 default:
6067 pe_err("%d: Invalid event type %d",
6068 obss_color_info->vdev_id, obss_color_info->evt_type);
6069 return;
6070 }
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006071}
6072#endif