blob: 358b08186ed0411a26d17fa7f39c127447590735 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Jingxiang Ge4168a232018-01-03 18:47:15 +08002 * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
19/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020 * This file lim_process_sme_req_messages.cc contains the code
21 * for processing SME request messages.
22 * Author: Chandra Modumudi
23 * Date: 02/11/02
24 * History:-
25 * Date Modified by Modification Information
26 * --------------------------------------------------------------------
27 *
28 */
29
30#include "cds_api.h"
31#include "wni_api.h"
32#include "wni_cfg.h"
33#include "cfg_api.h"
34#include "sir_api.h"
35#include "sch_api.h"
36#include "utils_api.h"
37#include "lim_types.h"
38#include "lim_utils.h"
39#include "lim_assoc_utils.h"
40#include "lim_security_utils.h"
41#include "lim_ser_des_utils.h"
42#include "lim_sme_req_utils.h"
43#include "lim_ibss_peer_mgmt.h"
44#include "lim_admit_control.h"
45#include "dph_hash_table.h"
46#include "lim_send_messages.h"
47#include "lim_api.h"
48#include "wmm_apsd.h"
49#include "sir_mac_prot_def.h"
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -080050#include "rrm_api.h"
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070051#include "nan_datapath.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080052
53#include "sap_api.h"
54
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080055
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080056#include <lim_ft.h>
Naveen Rawat3b6068c2016-04-14 19:01:06 -070057#include "cds_regdomain.h"
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053058#include "lim_process_fils.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070059#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060
61/*
62 * This overhead is time for sending NOA start to host in case of GO/sending
63 * NULL data & receiving ACK in case of P2P Client and starting actual scanning
64 * with init scan req/rsp plus in case of concurrency, taking care of sending
65 * null data and receiving ACK to/from AP/Also SetChannel with calibration
66 * is taking around 7ms .
67 */
68#define SCAN_MESSAGING_OVERHEAD 20 /* in msecs */
69#define JOIN_NOA_DURATION 2000 /* in msecs */
70#define OEM_DATA_NOA_DURATION 60 /* in msecs */
71#define DEFAULT_PASSIVE_MAX_CHANNEL_TIME 110 /* in msecs */
72
73#define CONV_MS_TO_US 1024 /* conversion factor from ms to us */
74
Paul Zhangd2315472017-02-22 10:02:50 +080075#define BEACON_INTERVAL_THRESHOLD 50 /* in msecs */
76#define STA_BURST_SCAN_DURATION 120 /* in msecs */
77
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080078/* SME REQ processing function templates */
79static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080080static bool __lim_process_sme_start_bss_req(tpAniSirGlobal,
81 struct scheduler_msg *pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080082static void __lim_process_sme_join_req(tpAniSirGlobal, uint32_t *);
83static void __lim_process_sme_reassoc_req(tpAniSirGlobal, uint32_t *);
84static void __lim_process_sme_disassoc_req(tpAniSirGlobal, uint32_t *);
85static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal, uint32_t *);
86static void __lim_process_sme_deauth_req(tpAniSirGlobal, uint32_t *);
87static void __lim_process_sme_set_context_req(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080088static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal,
89 struct scheduler_msg *pMsg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053090static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
91 uint32_t *msg_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080092static void lim_process_sme_channel_change_request(tpAniSirGlobal pMac,
93 uint32_t *pMsg);
94static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg);
95static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal pMac, uint32_t *pMsg);
96static void lim_process_nss_update_request(tpAniSirGlobal pMac, uint32_t *pMsg);
97static void lim_process_set_ie_req(tpAniSirGlobal pMac, uint32_t *pMsg);
98
99static void lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
100 uint8_t **pDstData_buff,
101 uint16_t *pDstDataLen,
102 uint8_t *pSrcData_buff,
103 uint16_t srcDataLen);
104
105static void lim_update_add_ie_buffer(tpAniSirGlobal pMac,
106 uint8_t **pDstData_buff,
107 uint16_t *pDstDataLen,
108 uint8_t *pSrcData_buff, uint16_t srcDataLen);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800109static bool lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac,
110 uint8_t **pDstData_buff,
111 uint16_t *pDstDataLen,
112 tSirModifyIE *pModifyIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800113static void lim_process_modify_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
114
115static void lim_process_update_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
116
Abhishek Singh518323d2015-10-19 17:42:01 +0530117static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
118 uint32_t *msg);
119
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800120/**
121 * lim_process_set_hw_mode() - Send set HW mode command to WMA
122 * @mac: Globacl MAC pointer
123 * @msg: Message containing the hw mode index
124 *
125 * Send the set HW mode command to WMA
126 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530127 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800128 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530129static QDF_STATUS lim_process_set_hw_mode(tpAniSirGlobal mac, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800130{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530131 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700132 struct scheduler_msg message = {0};
Tushnim Bhattacharyya66348bd2017-03-09 15:02:10 -0800133 struct policy_mgr_hw_mode *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800134 uint32_t len;
135 struct s_sir_set_hw_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700136 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800137 struct sir_set_hw_mode_resp *param;
138
139 buf = (struct s_sir_set_hw_mode *) msg;
140 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700141 pe_err("Set HW mode param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800142 /* To free the active command list */
143 goto fail;
144 }
145
146 len = sizeof(*req_msg);
147
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530148 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700150 pe_err("qdf_mem_malloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800151 /* Free the active command list
152 * Probably the malloc is going to fail there as well?!
153 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530154 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800155 }
156
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800157 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530158 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159 /* Other parameters are not needed for WMA */
160
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800161 message.bodyptr = req_msg;
162 message.type = SIR_HAL_PDEV_SET_HW_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800163
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700164 pe_debug("Posting SIR_HAL_SOC_SET_HW_MOD to WMA");
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800165 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530166 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700167 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530169 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170 goto fail;
171 }
172 return status;
173fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530174 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800175 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700176 pe_err("HW mode resp failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530177 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800178 }
179 param->status = SET_HW_MODE_STATUS_ECANCELED;
180 param->cfgd_hw_mode_index = 0;
181 param->num_vdev_mac_entries = 0;
182 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
183 resp_msg.bodyptr = param;
184 resp_msg.bodyval = 0;
185 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530186 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800187}
188
189/**
190 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
191 * @mac: Global MAC pointer
192 * @msg: Message containing the dual mac config parameter
193 *
194 * Send the set dual mac config command to WMA
195 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530196 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800197 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530198static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800199 uint32_t *msg)
200{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530201 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700202 struct scheduler_msg message = {0};
Srinivas Girigowdaeb6ecf32018-02-15 17:04:22 -0800203 struct policy_mgr_dual_mac_config *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800204 uint32_t len;
205 struct sir_set_dual_mac_cfg *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700206 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800207 struct sir_dual_mac_config_resp *param;
208
209 buf = (struct sir_set_dual_mac_cfg *) msg;
210 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700211 pe_err("Set Dual mac config is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800212 /* To free the active command list */
213 goto fail;
214 }
215
216 len = sizeof(*req_msg);
217
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530218 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800219 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700220 pe_err("qdf_mem_malloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800221 /* Free the active command list
222 * Probably the malloc is going to fail there as well?!
223 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530224 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225 }
226
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 req_msg->scan_config = buf->set_dual_mac.scan_config;
228 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
229 /* Other parameters are not needed for WMA */
230
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800231 message.bodyptr = req_msg;
232 message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800233
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700234 pe_debug("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235 req_msg->scan_config, req_msg->fw_mode_config);
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800236 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530237 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700238 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800239 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530240 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800241 goto fail;
242 }
243 return status;
244fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530245 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800246 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700247 pe_err("Dual mac config resp failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530248 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249 }
250 param->status = SET_HW_MODE_STATUS_ECANCELED;
251 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
252 resp_msg.bodyptr = param;
253 resp_msg.bodyval = 0;
254 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530255 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800256}
257
258/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800259 * lim_process_set_antenna_mode_req() - Set antenna mode command
260 * to WMA
261 * @mac: Global MAC pointer
262 * @msg: Message containing the antenna mode parameter
263 *
264 * Send the set antenna mode command to WMA
265 *
266 * Return: QDF_STATUS_SUCCESS if message posting is successful
267 */
268static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
269 uint32_t *msg)
270{
271 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700272 struct scheduler_msg message = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800273 struct sir_antenna_mode_param *req_msg;
274 struct sir_set_antenna_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700275 struct scheduler_msg resp_msg = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800276 struct sir_antenna_mode_resp *param;
277
278 buf = (struct sir_set_antenna_mode *) msg;
279 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700280 pe_err("Set antenna mode is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800281 /* To free the active command list */
282 goto fail;
283 }
284
285 req_msg = qdf_mem_malloc(sizeof(*req_msg));
286 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700287 pe_err("qdf_mem_malloc failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800288 return QDF_STATUS_E_NOMEM;
289 }
290
291 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
292 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
293
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800294 message.bodyptr = req_msg;
295 message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800296
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700297 pe_debug("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800298 req_msg->num_rx_chains,
299 req_msg->num_tx_chains);
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800300 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800301 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700302 pe_err("scheduler_post_msg failed!(err=%d)",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800303 status);
304 qdf_mem_free(req_msg);
305 goto fail;
306 }
307 return status;
308fail:
309 param = qdf_mem_malloc(sizeof(*param));
310 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700311 pe_err("antenna mode resp failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800312 return QDF_STATUS_E_NOMEM;
313 }
314 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
315 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
316 resp_msg.bodyptr = param;
317 resp_msg.bodyval = 0;
318 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
319 return QDF_STATUS_SUCCESS;
320}
321
322/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800323 * __lim_is_sme_assoc_cnf_valid()
324 *
325 ***FUNCTION:
326 * This function is called by __lim_process_sme_assoc_cnf_new() upon
327 * receiving SME_ASSOC_CNF.
328 *
329 ***LOGIC:
330 * Message validity checks are performed in this function
331 *
332 ***ASSUMPTIONS:
333 *
334 ***NOTE:
335 *
336 * @param pMeasReq Pointer to Received ASSOC_CNF message
337 * @return true When received SME_ASSOC_CNF is formatted
338 * correctly
339 * false otherwise
340 */
341
342static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
343{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530344 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800345 return false;
346 else
347 return true;
348} /*** end __lim_is_sme_assoc_cnf_valid() ***/
349
350/**
351 * __lim_get_sme_join_req_size_for_alloc()
352 *
353 ***FUNCTION:
354 * This function is called in various places to get IE length
355 * from tSirBssDescription structure
356 * number being scanned.
357 *
358 ***PARAMS:
359 *
360 ***LOGIC:
361 *
362 ***ASSUMPTIONS:
363 * NA
364 *
365 ***NOTE:
366 * NA
367 *
368 * @param pBssDescr
369 * @return Total IE length
370 */
371
372static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
373{
374 uint16_t len = 0;
375
376 if (!pBuf)
377 return len;
378
379 pBuf += sizeof(uint16_t);
380 len = lim_get_u16(pBuf);
Arif Hussainc9651922017-04-16 14:08:23 -0700381 return len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800382}
383
384/**
385 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
386 * @pMac: Global MAC context
387 * @pMsg: Pointer to message posted from SME to LIM.
388 *
389 * Has role only if 11h is enabled. Not used on STA side.
390 * Defers the message if SME is in learn state and brings
391 * the LIM back to normal mode.
392 *
393 * Return: true - If defered false - Otherwise
394 */
395
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800396static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac,
397 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800398{
399 if (lim_is_system_in_scan_state(pMac)) {
400 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700401 pe_err("Could not defer Msg: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800402 return false;
403 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700404 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800405 pMsg->type);
406 return true;
407 }
408 return false;
409}
410
411/**
412 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
413 * @mac_ctx: Pointer to Global MAC structure
414 * @message: Pointer to message posted from SME to LIM.
415 *
416 * Has role only if 11h is enabled. Not used on STA side.
417 * Defers the message if radar is detected.
418 *
419 * Return: true, if defered otherwise return false.
420 */
421static bool
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800422__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx,
423 struct scheduler_msg *message)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800424{
425 /*
426 * fRadarDetCurOperChan will be set only if we
427 * detect radar in current operating channel and
428 * System Role == AP ROLE
429 *
430 * TODO: Need to take care radar detection.
431 *
432 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
433 */
434 if (0) {
435 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700436 pe_err("Could not defer Msg: %d", message->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437 return false;
438 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700439 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800440 message->type);
441 return true;
442 }
443 return false;
444}
445
446/**
447 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
448 * @pMac: Global MAC context
449 * @pMsgBuf: Message from WMA
450 *
451 * handles the notification from HDD. PE just forwards this message to HAL.
452 *
453 * Return: true-Posting to HAL failed, so PE will consume the buffer.
454 * false-Posting to HAL successful, so HAL will consume the buffer.
455 */
456
457static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
458{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700459 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800460 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
461
462 msg.type = WMA_SYS_READY_IND;
463 msg.reserved = 0;
464 msg.bodyptr = pMsgBuf;
465 msg.bodyval = 0;
466
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700467 if (ANI_DRIVER_TYPE(pMac) != QDF_DRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800468 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +0530469 pe_register_mgmt_rx_frm_callback(pMac);
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700470 pe_register_callbacks_with_wma(pMac, ready_req);
Sandeep Puligilla1426d612017-04-12 18:22:06 -0700471 pMac->lim.sme_msg_callback = ready_req->sme_msg_cb;
Vignesh Viswanathan3d478032018-08-02 20:18:53 +0530472 pMac->lim.stop_roaming_callback = ready_req->stop_roaming_cb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800473 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700474
475 pe_debug("sending WMA_SYS_READY_IND msg to HAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800476 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
477
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700478 if (QDF_STATUS_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700479 pe_err("wma_post_ctrl_msg failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800480 return true;
481 }
482 return false;
483}
484
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800485/**
486 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
487 *@mac_ctx: Pointer to Global MAC structure
488 *@session: A pointer to session entry
489 *@sme_start_bss_req: Start BSS Request from upper layers.
490 *
491 * This function is used to configure the start bss parameters
492 * in to the session.
493 *
494 * Return: None.
495 */
496static void
497lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
498 tpSirSmeStartBssReq sme_start_bss_req)
499{
500 session->limSystemRole = eLIM_AP_ROLE;
501 session->privacy = sme_start_bss_req->privacy;
502 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
503 session->authType = sme_start_bss_req->authType;
504 /* Store the DTIM period */
505 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
506 /* Enable/disable UAPSD */
507 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530508 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800509 session->proxyProbeRspEn = 0;
510 } else {
511 /*
512 * To detect PBC overlap in SAP WPS mode,
513 * Host handles Probe Requests.
514 */
515 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
516 session->proxyProbeRspEn = 1;
517 else
518 session->proxyProbeRspEn = 0;
519 }
520 session->ssidHidden = sme_start_bss_req->ssidHidden;
521 session->wps_state = sme_start_bss_req->wps_state;
522 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530523 session->vendor_vht_sap =
524 sme_start_bss_req->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800525 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
526 &session->shortSlotTimeSupported);
527 session->isCoalesingInIBSSAllowed =
528 sme_start_bss_req->isCoalesingInIBSSAllowed;
529
Jiachao Wu712d4fd2017-08-23 16:52:34 +0800530 session->beacon_tx_rate = sme_start_bss_req->beacon_tx_rate;
531
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800532}
533
534/**
Arif Hussain53cf5692018-04-05 16:35:54 -0700535 * lim_clear_he_tx_stbc() - Clear tx stbc for a given session
536 * @session: Session
537 *
538 * Clear tx stbc for a given session
539 *
540 * Return: None
541 */
542#ifdef WLAN_FEATURE_11AX
543static void lim_clear_he_tx_stbc(tpPESession session)
544{
545 if (session) {
546 session->he_config.tx_stbc_lt_80mhz = 0;
547 session->he_config.tx_stbc_gt_80mhz = 0;
548 }
549}
550#else
551static void lim_clear_he_tx_stbc(tpPESession session)
552{}
553#endif
554
555/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800556 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
557 *@mac_ctx: Pointer to Global MAC structure
558 *@msg_buf: A pointer to the SME message buffer
559 *
560 * This function is called to process SME_START_BSS_REQ message
561 * from HDD or upper layer application.
562 *
563 * Return: None
564 */
565static void
566__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
567{
568 uint16_t size;
569 uint32_t val = 0;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700570 QDF_STATUS ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800571 tSirMacChanNum channel_number;
572 tLimMlmStartReq *mlm_start_req = NULL;
573 tpSirSmeStartBssReq sme_start_bss_req = NULL;
574 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
575 /* Flag Used in case of IBSS to Auto generate BSSID. */
576 uint32_t auto_gen_bssid = false;
577 uint8_t session_id;
578 tpPESession session = NULL;
Krunal Sonib37bb352016-12-20 14:12:21 -0800579 uint8_t sme_session_id = 0xFF;
580 uint16_t sme_transaction_id = 0xFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800581 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700582 struct vdev_type_nss *vdev_type_nss;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700583 QDF_STATUS cfg_get_wmi_dfs_master_param = QDF_STATUS_SUCCESS;
gaurank kathpaliad88ef882018-08-14 15:20:11 +0530584 struct policy_mgr_hw_mode_params hw_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800585
586/* FEATURE_WLAN_DIAG_SUPPORT */
587#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
588 /*
589 * Since the session is not created yet, sending NULL.
590 * The response should have the correct state.
591 */
592 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
593 NULL, 0, 0);
594#endif /* FEATURE_WLAN_DIAG_SUPPORT */
595
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700596 pe_debug("Received START_BSS_REQ");
Krunal Sonib37bb352016-12-20 14:12:21 -0800597 size = sizeof(tSirSmeStartBssReq);
598 sme_start_bss_req = qdf_mem_malloc(size);
599 if (NULL == sme_start_bss_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700600 pe_err("Allocate Memory fail for LimStartBssReq");
Krunal Sonib37bb352016-12-20 14:12:21 -0800601 /* Send failure response to host */
602 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
603 goto free;
604 }
605 qdf_mem_copy(sme_start_bss_req, msg_buf, sizeof(tSirSmeStartBssReq));
606 sme_session_id = sme_start_bss_req->sessionId;
607 sme_transaction_id = sme_start_bss_req->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800608
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800609 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
610 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800611 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
612 sme_start_bss_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700613 pe_warn("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800614 ret_code = eSIR_SME_INVALID_PARAMETERS;
615 goto free;
616 }
617
618 /*
619 * This is the place where PE is going to create a session.
620 * If session is not existed, then create a new session
621 */
622 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800623 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800624 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700625 pe_warn("Session Already exists for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800626 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
627 session = NULL;
628 goto free;
629 } else {
630 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800631 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800632 &session_id, mac_ctx->lim.maxStation,
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +0530633 sme_start_bss_req->bssType,
634 sme_start_bss_req->sessionId);
635 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700636 pe_warn("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800637 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
638 goto free;
639 }
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +0530640
641 /* Update the beacon/probe filter in mac_ctx */
642 lim_set_bcn_probe_filter(mac_ctx, session,
643 &sme_start_bss_req->ssId,
644 sme_start_bss_req->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800645 }
646
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700647 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
648 /* Probe resp add ie */
649 lim_start_bss_update_add_ie_buffer(mac_ctx,
650 &session->addIeParams.probeRespData_buff,
651 &session->addIeParams.probeRespDataLen,
652 sme_start_bss_req->addIeParams.
653 probeRespData_buff,
654 sme_start_bss_req->addIeParams.
655 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800656
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700657 /* Probe Beacon add ie */
658 lim_start_bss_update_add_ie_buffer(mac_ctx,
659 &session->addIeParams.probeRespBCNData_buff,
660 &session->addIeParams.probeRespBCNDataLen,
661 sme_start_bss_req->addIeParams.
662 probeRespBCNData_buff,
663 sme_start_bss_req->addIeParams.
664 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800665
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700666 /* Assoc resp IE */
667 lim_start_bss_update_add_ie_buffer(mac_ctx,
668 &session->addIeParams.assocRespData_buff,
669 &session->addIeParams.assocRespDataLen,
670 sme_start_bss_req->addIeParams.
671 assocRespData_buff,
672 sme_start_bss_req->addIeParams.
673 assocRespDataLen);
674 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800675 /* Store the session related params in newly created session */
676 session->pLimStartBssReq = sme_start_bss_req;
677
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800678 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 }
gaurank kathpaliad88ef882018-08-14 15:20:11 +0530855 if (policy_mgr_is_hw_dbs_capable(mac_ctx->psoc) &&
856 (policy_mgr_get_current_hw_mode(mac_ctx->psoc, &hw_mode) ==
857 QDF_STATUS_SUCCESS) &&
858 hw_mode.dbs_cap) {
859 session->nss = 1;
860 pe_debug("HW is in DBS mode. Nss set to [%d]",
861 session->nss);
862 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800863 if (session->vhtCapability &&
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800864 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800865 session->nss = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700866 pe_debug("nss set to [%d]", session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800867 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700868 pe_debug("vht su tx bformer %d",
Krunal Soni53993f72016-07-08 18:20:03 -0700869 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800870
871 /* Delete pre-auth list if any */
872 lim_delete_pre_auth_list(mac_ctx);
873
Krunal Soni53993f72016-07-08 18:20:03 -0700874 if (session->nss == 1) {
875 session->vht_config.su_beam_former = 0;
876 session->vht_config.tx_stbc = 0;
877 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530878 session->htConfig.ht_tx_stbc = 0;
Arif Hussain53cf5692018-04-05 16:35:54 -0700879 lim_clear_he_tx_stbc(session);
Krunal Soni53993f72016-07-08 18:20:03 -0700880 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800881 /*
882 * keep the RSN/WPA IE information in PE Session Entry
883 * later will be using this to check when received (Re)Assoc req
884 */
885 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
886 &sme_start_bss_req->rsnIE, session);
887
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700888 if (LIM_IS_AP_ROLE(session) ||
889 LIM_IS_IBSS_ROLE(session) ||
890 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800891 session->gLimProtectionControl =
892 sme_start_bss_req->protEnabled;
893 /*
894 * each byte will have the following info
895 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
896 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
897 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530898 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800899 (void *)&sme_start_bss_req->ht_capab,
900 sizeof(uint16_t));
901 /* Initialize WPS PBC session link list */
902 session->pAPWPSPBCSession = NULL;
903 }
904 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530905 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800906 if (NULL == mlm_start_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700907 pe_err("Allocate Memory failed for mlmStartReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800908 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
909 goto free;
910 }
911
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800912 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530913 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800914 (uint8_t *) &sme_start_bss_req->ssId,
915 sme_start_bss_req->ssId.length + 1);
916 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
917 mlm_start_req->obssProtEnabled =
918 sme_start_bss_req->obssProtEnabled;
919
920 mlm_start_req->bssType = session->bssType;
921
922 /* Fill PE session Id from the session Table */
923 mlm_start_req->sessionId = session->peSessionId;
924
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700925 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
926 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800927 /*
928 * Copy the BSSId from sessionTable to
929 * mlmStartReq struct
930 */
931 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
932 } else {
933 /* ibss mode */
934 mac_ctx->lim.gLimIbssCoalescingHappened = false;
935
936 ret_status = wlan_cfg_get_int(mac_ctx,
937 WNI_CFG_IBSS_AUTO_BSSID,
938 &auto_gen_bssid);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700939 if (ret_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700940 pe_err("Get Auto Gen BSSID fail,Status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800941 ret_status);
Abhishek Singh4294f802017-08-10 16:37:07 +0530942 ret_code = eSIR_LOGE_EXCEPTION;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800943 goto free;
944 }
945
946 if (!auto_gen_bssid) {
947 /*
948 * We're not auto generating BSSID.
949 * Instead, get it from session entry
950 */
951 sir_copy_mac_addr(mlm_start_req->bssId,
952 session->bssId);
953 /*
954 * Start IBSS group BSSID
955 * Auto Generating BSSID.
956 */
957 auto_gen_bssid = ((mlm_start_req->bssId[0] &
958 0x01) ? true : false);
959 }
960
961 if (auto_gen_bssid) {
962 /*
963 * if BSSID is not any uc id.
964 * then use locally generated BSSID.
965 * Autogenerate the BSSID
966 */
967 lim_get_random_bssid(mac_ctx,
968 mlm_start_req->bssId);
969 mlm_start_req->bssId[0] = 0x02;
970
971 /*
972 * Copy randomly generated BSSID
973 * to the session Table
974 */
975 sir_copy_mac_addr(session->bssId,
976 mlm_start_req->bssId);
977 }
978 }
979 /* store the channel num in mlmstart req structure */
980 mlm_start_req->channelNumber = session->currentOperChannel;
981 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
982 mlm_start_req->beaconPeriod =
983 session->beaconParams.beaconInterval;
Arif Hussain671a1902017-03-17 09:08:32 -0700984 mlm_start_req->cac_duration_ms =
985 sme_start_bss_req->cac_duration_ms;
986 mlm_start_req->dfs_regdomain =
987 sme_start_bss_req->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800988 if (LIM_IS_AP_ROLE(session)) {
989 mlm_start_req->dtimPeriod = session->dtimPeriod;
990 mlm_start_req->wps_state = session->wps_state;
991
992 } else {
993 if (wlan_cfg_get_int(mac_ctx,
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700994 WNI_CFG_DTIM_PERIOD, &val) != QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700995 pe_err("could not retrieve DTIM Period");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800996 mlm_start_req->dtimPeriod = (uint8_t) val;
997 }
998
Karthik Kantamneni22dd0f62018-08-07 14:53:50 +0530999 mlm_start_req->cfParamSet.cfpPeriod =
1000 mac_ctx->mlme_cfg->rates.cfp_period;
1001 mlm_start_req->cfParamSet.cfpMaxDuration =
1002 mac_ctx->mlme_cfg->rates.cfp_max_duration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001003
1004 /*
1005 * this may not be needed anymore now,
1006 * as rateSet is now included in the
1007 * session entry and MLM has session context.
1008 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301009 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001010 (void *)&session->rateSet,
1011 sizeof(tSirMacRateSet));
1012
1013 /* Now populate the 11n related parameters */
1014 mlm_start_req->nwType = session->nwType;
1015 mlm_start_req->htCapable = session->htCapability;
1016
1017 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1018 /* Unused */
1019 mlm_start_req->dualCTSProtection =
1020 mac_ctx->lim.gHTDualCTSProtection;
1021 mlm_start_req->txChannelWidthSet =
1022 session->htRecommendedTxWidthSet;
1023
1024 session->limRFBand = lim_get_rf_band(channel_number);
1025
1026 /* Initialize 11h Enable Flag */
1027 session->lim11hEnable = 0;
gaolez76d2a162017-03-21 19:23:58 +08001028 if (mlm_start_req->bssType != eSIR_IBSS_MODE &&
1029 (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001030 BAND_5G == session->limRFBand)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001031 if (wlan_cfg_get_int(mac_ctx,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001032 WNI_CFG_11H_ENABLED, &val) != QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001033 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001034 else
1035 session->lim11hEnable = val;
1036
1037 if (session->lim11hEnable &&
1038 (eSIR_INFRA_AP_MODE ==
1039 mlm_start_req->bssType)) {
1040 cfg_get_wmi_dfs_master_param =
1041 wlan_cfg_get_int(mac_ctx,
1042 WNI_CFG_DFS_MASTER_ENABLED,
1043 &val);
1044 session->lim11hEnable = val;
1045 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001046 if (cfg_get_wmi_dfs_master_param != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001047 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001048 pe_err("Get Fail, CFG DFS ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049 }
1050
1051 if (!session->lim11hEnable) {
1052 if (cfg_set_int(mac_ctx,
1053 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001054 QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055 /*
1056 * Failed to set the CFG param
1057 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1058 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001059 pe_err("Set LOCAL_POWER_CONSTRAINT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001060 }
1061
Jiachao Wu712d4fd2017-08-23 16:52:34 +08001062 mlm_start_req->beacon_tx_rate = session->beacon_tx_rate;
1063
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064 session->limPrevSmeState = session->limSmeState;
1065 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1066 MTRACE(mac_trace
1067 (mac_ctx, TRACE_CODE_SME_STATE,
1068 session->peSessionId,
1069 session->limSmeState));
1070
1071 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1072 (uint32_t *) mlm_start_req);
1073 return;
1074 } else {
1075
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001076 pe_err("Received unexpected START_BSS_REQ, in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001077 mac_ctx->lim.gLimSmeState);
1078 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001079 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001080 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1081
1082free:
1083 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001084 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001085 session->pLimStartBssReq = NULL;
1086 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001087 if (NULL != sme_start_bss_req)
1088 qdf_mem_free(sme_start_bss_req);
1089 if (NULL != mlm_start_req)
1090 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001091 if (NULL != session) {
1092 pe_delete_session(mac_ctx, session);
1093 session = NULL;
1094 }
1095 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1096 session, sme_session_id, sme_transaction_id);
1097}
1098
1099/**
1100 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1101 *
1102 * @pMac: Global MAC context
1103 * @pMsg: Message pointer
1104 *
1105 * Wrapper for the function __lim_handle_sme_start_bss_request
1106 * This message will be defered until softmac come out of
1107 * scan mode or if we have detected radar on the current
1108 * operating channel.
1109 *
1110 * return true - If we consumed the buffer
1111 * false - If have defered the message.
1112 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001113static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1114 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001115{
1116 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1117 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1118 /**
1119 * If message defered, buffer is not consumed yet.
1120 * So return false
1121 */
1122 return false;
1123 }
1124
1125 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1126 return true;
1127}
1128
1129/**
1130 * lim_get_random_bssid()
1131 *
1132 * FUNCTION:This function is called to process generate the random number for bssid
1133 * This function is called to process SME_SCAN_REQ message
1134 * from HDD or upper layer application.
1135 *
1136 * LOGIC:
1137 *
1138 * ASSUMPTIONS:
1139 *
1140 * NOTE:
1141 * 1. geneartes the unique random number for bssid in ibss
1142 *
1143 * @param pMac Pointer to Global MAC structure
1144 * @param *data Pointer to bssid buffer
1145 * @return None
1146 */
1147void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1148{
1149 uint32_t random[2];
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001150
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001151 random[0] = tx_time_get();
1152 random[0] |= (random[0] << 15);
1153 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301154 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001155}
1156
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001157/**
1158 * __lim_process_clear_dfs_channel_list()
1159 *
1160 ***FUNCTION:
Jeff Johnsonc00ae5b2018-05-06 16:06:35 -07001161 ***Clear DFS channel list when country is changed/acquired.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001162 .*This message is sent from SME.
1163 *
1164 ***LOGIC:
1165 *
1166 ***ASSUMPTIONS:
1167 *
1168 ***NOTE:
1169 *
1170 * @param pMac Pointer to Global MAC structure
1171 * @param *pMsgBuf A pointer to the SME message buffer
1172 * @return None
1173 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001174static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1175 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001176{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301177 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001178}
1179
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301180#ifdef WLAN_FEATURE_SAE
1181
1182/**
1183 * lim_update_sae_config()- This API update SAE session info to csr config
1184 * from join request.
1185 * @session: PE session
1186 * @sme_join_req: pointer to join request
1187 *
1188 * Return: None
1189 */
1190static void lim_update_sae_config(tpPESession session,
1191 tpSirSmeJoinReq sme_join_req)
1192{
1193 session->sae_pmk_cached = sme_join_req->sae_pmk_cached;
1194
1195 pe_debug("pmk_cached %d for BSSID=" MAC_ADDRESS_STR,
1196 session->sae_pmk_cached,
1197 MAC_ADDR_ARRAY(sme_join_req->bssDescription.bssId));
1198}
1199#else
1200static inline void lim_update_sae_config(tpPESession session,
1201 tpSirSmeJoinReq sme_join_req)
1202{}
1203#endif
1204
1205
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001206/**
1207 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1208 * @mac_ctx: Pointer to Global MAC structure
1209 * @msg_buf: A pointer to the SME message buffer
1210 *
1211 * This function is called to process SME_JOIN_REQ message
1212 * from HDD or upper layer application.
1213 *
1214 * Return: None
1215 */
1216static void
1217__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1218{
1219 tpSirSmeJoinReq sme_join_req = NULL;
1220 tLimMlmJoinReq *mlm_join_req;
1221 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1222 uint32_t val = 0;
1223 uint16_t n_size;
1224 uint8_t session_id;
1225 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301226 uint8_t sme_session_id = 0;
1227 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001228 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229 uint16_t ie_len;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001230 const uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001231 tSirBssDescription *bss_desc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001232
Arif Hussain995fcaf2016-07-18 11:28:22 -07001233 if (!mac_ctx || !msg_buf) {
1234 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1235 FL("JOIN REQ with invalid data"));
1236 return;
1237 }
1238
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001239/* FEATURE_WLAN_DIAG_SUPPORT */
1240#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1241 /*
1242 * Not sending any session, since it is not created yet.
1243 * The response whould have correct state.
1244 */
1245 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1246#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1247
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001248 /*
1249 * Expect Join request in idle state.
1250 * Reassociate request is expected in link established state.
1251 */
1252
1253 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1254 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1255 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1256 msg_buf);
1257
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301258 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001259 if (NULL == sme_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001260 pe_err("AllocateMemory failed for sme_join_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001261 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301262 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001263 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301264 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001265 n_size);
1266
1267 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1268 /* Received invalid eWNI_SME_JOIN_REQ */
1269 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001270 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001271 sme_join_req->sessionId);
1272 ret_code = eSIR_SME_INVALID_PARAMETERS;
1273 goto end;
1274 }
1275
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001276 /*
1277 * Update the capability here itself as this is used in
1278 * lim_extract_ap_capability() below. If not updated issues
1279 * like not honoring power constraint on 1st association after
1280 * driver loading might occur.
1281 */
1282 lim_update_rrm_capability(mac_ctx, sme_join_req);
1283
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001284 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001285 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001286 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001287 &session_id);
1288
1289 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001290 pe_err("Session(%d) Already exists for BSSID: "
1291 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001292 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001293 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001294 session->limSmeState);
1295
1296 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1297 session->smeSessionId == sme_join_req->sessionId) {
1298 /*
1299 * Received eWNI_SME_JOIN_REQ for same
1300 * BSS as currently associated.
1301 * Log the event and send success
1302 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001303 pe_warn("SessionId: %d", session_id);
1304 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001305 /* Send Join success response to host */
1306 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1307 session = NULL;
1308 goto end;
1309 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001310 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001311 ret_code = eSIR_SME_REFUSED;
1312 session = NULL;
1313 goto end;
1314 }
1315 } else {
1316 /*
1317 * Session Entry does not exist for given BSSId
1318 * Try to Create a new session
1319 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001320 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001321 &session_id, mac_ctx->lim.maxStation,
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +05301322 eSIR_INFRASTRUCTURE_MODE,
1323 sme_join_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001324 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001325 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001326 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1327 goto end;
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301328 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001329 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001330 session_id);
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301331 }
1332
1333 /* Update the beacon/probe filter in mac_ctx */
1334 lim_set_bcn_probe_filter(mac_ctx, session,
1335 &sme_join_req->ssId,
1336 bss_desc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001337 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001338 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339
1340 /*
1341 * Store Session related parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001342 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001343
1344 /* store the smejoin req handle in session table */
1345 session->pLimJoinReq = sme_join_req;
1346
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001347 /* Store SME transaction Id in session Table */
1348 session->transactionId = sme_join_req->transactionId;
1349
1350 /* Store beaconInterval */
1351 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001352 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001353
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301354 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001355 sizeof(session->htConfig));
1356
Sandeep Puligilla98917432016-06-10 13:50:28 -07001357 qdf_mem_copy(&(session->vht_config),
1358 &(sme_join_req->vht_config),
1359 sizeof(session->vht_config));
1360
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001361 /* Copying of bssId is already done, while creating session */
1362 sir_copy_mac_addr(session->selfMacAddr,
1363 sme_join_req->selfMacAddr);
1364 session->bssType = sme_join_req->bsstype;
1365
1366 session->statypeForBss = STA_ENTRY_PEER;
1367 session->limWmeEnabled = sme_join_req->isWMEenabled;
1368 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301369 session->wps_registration = sme_join_req->wps_registration;
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001370 session->he_with_wep_tkip = sme_join_req->he_with_wep_tkip;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001371
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301372 session->enable_bcast_probe_rsp =
1373 sme_join_req->enable_bcast_probe_rsp;
1374
Jeff Johnson179fd8a2018-05-11 14:20:05 -07001375 /* Store vendor specific IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001376 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1378
Naveen Rawat08db88f2017-09-08 15:07:48 -07001379 vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001380 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001381 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001382
1383 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001384 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001385 session->isCiscoVendorAP = true;
1386 } else {
1387 session->isCiscoVendorAP = false;
1388 }
1389
1390 /* Copy the dot 11 mode in to the session table */
1391
1392 session->dot11mode = sme_join_req->dot11mode;
1393#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1394 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1395#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001396 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001397 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1398 session->enableHtSmps = sme_join_req->enableHtSmps;
1399 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001400 session->send_smps_action =
1401 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001402 /*
1403 * By default supported NSS 1x1 is set to true
1404 * and later on updated while determining session
1405 * supported rates which is the intersection of
1406 * self and peer rates
1407 */
1408 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301409 /*Store Persona */
1410 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001411 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 -08001412 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001413 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001414 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301415 session->supported_nss_1x1,
1416 session->pePersona,
1417 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001418
1419 /*Store Persona */
1420 session->pePersona = sme_join_req->staPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +05301421 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301422 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d force_24ghz_in_ht20 %d"),
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001423 session->pePersona, sme_join_req->cbMode,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301424 session->nwType, session->dot11mode,
1425 sme_join_req->force_24ghz_in_ht20);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001426
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001427 /* Copy The channel Id to the session Table */
1428 session->currentOperChannel = bss_desc->channelId;
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301429
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001430 session->vhtCapability =
1431 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001432 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301433 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001434 session->vht_config.su_beam_formee =
1435 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001436 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001437 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001438 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001439 session->enableVhtpAid =
1440 sme_join_req->enableVhtpAid;
1441 session->enableVhtGid =
1442 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001443 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001444 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001445 }
Krunal Soni53993f72016-07-08 18:20:03 -07001446
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001447 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301448 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001449 session->vht_config.su_beam_formee,
1450 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001451 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001452 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001453 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001454 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301455 session->force_24ghz_in_ht20 =
1456 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001457 /* cbMode is already merged value of peer and self -
1458 * done by csr in csr_get_cb_mode_from_ies */
1459 session->htSupportedChannelWidthSet =
1460 (sme_join_req->cbMode) ? 1 : 0;
1461 session->htRecommendedTxWidthSet =
1462 session->htSupportedChannelWidthSet;
1463 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1464
1465 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1466 session->ch_center_freq_seg0 =
1467 session->currentOperChannel - 2;
1468 session->ch_width = CH_WIDTH_40MHZ;
1469 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1470 sme_join_req->cbMode) {
1471 session->ch_center_freq_seg0 =
1472 session->currentOperChannel + 2;
1473 session->ch_width = CH_WIDTH_40MHZ;
1474 } else {
1475 session->ch_center_freq_seg0 = 0;
1476 session->ch_width = CH_WIDTH_20MHZ;
1477 }
1478
Naveen Rawataeca1b92017-10-16 16:55:31 -07001479 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1480 lim_update_session_he_capable(mac_ctx, session);
1481 lim_copy_join_req_he_cap(session, sme_join_req);
1482 }
1483
1484
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001485 /* Record if management frames need to be protected */
1486#ifdef WLAN_FEATURE_11W
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +05301487 if ((eSIR_ED_AES_128_CMAC ==
1488 sme_join_req->MgmtEncryptionType) ||
1489 (eSIR_ED_AES_GMAC_128 == sme_join_req->MgmtEncryptionType) ||
1490 (eSIR_ED_AES_GMAC_256 == sme_join_req->MgmtEncryptionType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001491 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001492 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001493 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001494#endif
1495
1496#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001497 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001498#endif
1499
1500 /* Copy the SSID from smejoinreq to session entry */
1501 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301502 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001503 session->ssId.length);
1504
1505 /*
1506 * Determin 11r or ESE connection based on input from SME
1507 * which inturn is dependent on the profile the user wants
1508 * to connect to, So input is coming from supplicant
1509 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001510 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001511#ifdef FEATURE_WLAN_ESE
1512 session->isESEconnection = sme_join_req->isESEconnection;
1513#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001514 session->isFastTransitionEnabled =
1515 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001516
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001517 session->isFastRoamIniFeatureEnabled =
1518 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001519 session->txLdpcIniFeatureEnabled =
1520 sme_join_req->txLdpcIniFeatureEnabled;
1521
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301522 lim_update_fils_config(session, sme_join_req);
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301523 lim_update_sae_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001524 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1525 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526 } else {
1527 /*
1528 * Throw an error and return and make
1529 * sure to delete the session.
1530 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001531 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001532 session->bssType);
1533 ret_code = eSIR_SME_INVALID_PARAMETERS;
1534 goto end;
1535 }
1536
1537 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301538 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001539 &sme_join_req->addIEScan, sizeof(tSirAddie));
1540
1541 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301542 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001543 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1544
1545 val = sizeof(tLimMlmJoinReq) +
1546 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301547 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001548 if (NULL == mlm_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001549 pe_err("AllocateMemory failed for mlmJoinReq");
Nitesh Shah0102cac2016-07-13 14:38:30 +05301550 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1551 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001552 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001553
1554 /* PE SessionId is stored as a part of JoinReq */
1555 mlm_join_req->sessionId = session->peSessionId;
1556
1557 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1558 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001559 QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001560 pe_err("couldn't retrieve JoinFailureTimer value"
1561 " setting to default value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001562 mlm_join_req->joinFailureTimeout =
1563 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1564 }
1565
1566 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301567 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001568 (void *)&sme_join_req->operationalRateSet,
1569 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301570 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001571 (void *)&sme_join_req->extendedRateSet,
1572 sizeof(tSirMacRateSet));
1573 /*
1574 * this may not be needed anymore now, as rateSet is now
1575 * included in the session entry and MLM has session context.
1576 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301577 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001578 (void *)&session->rateSet,
1579 sizeof(tSirMacRateSet));
1580
1581 session->encryptType = sme_join_req->UCEncryptionType;
1582
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301583 session->supported_nss_1x1 = sme_join_req->supported_nss_1x1;
1584 session->vdev_nss = sme_join_req->vdev_nss;
1585 session->nss = sme_join_req->nss;
1586 session->nss_forced_1x1 = sme_join_req->nss_forced_1x1;
1587
1588 pe_debug("nss %d, vdev_nss %d, supported_nss_1x1 %d",
1589 session->nss,
1590 session->vdev_nss,
1591 session->supported_nss_1x1);
1592
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001593 mlm_join_req->bssDescription.length =
1594 session->pLimJoinReq->bssDescription.length;
1595
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301596 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001597 (uint8_t *)
1598 &session->pLimJoinReq->bssDescription.bssId,
1599 session->pLimJoinReq->bssDescription.length + 2);
1600
1601 session->limCurrentBssCaps =
1602 session->pLimJoinReq->bssDescription.capabilityInfo;
1603
1604 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1605 session->currentOperChannel);
1606 local_power_constraint = reg_max;
1607
1608 lim_extract_ap_capability(mac_ctx,
1609 (uint8_t *)
1610 session->pLimJoinReq->bssDescription.ieFields,
1611 lim_get_ielen_from_bss_description(
1612 &session->pLimJoinReq->bssDescription),
1613 &session->limCurrentBssQosCaps,
1614 &session->limCurrentBssPropCap,
1615 &session->gLimCurrentBssUapsd,
1616 &local_power_constraint, session);
1617
Krunal Soni53993f72016-07-08 18:20:03 -07001618 /*
1619 * Once the AP capabilities are available then set the
1620 * beam forming capabilities accordingly.
1621 */
1622 if (session->nss == 1) {
1623 session->vht_config.su_beam_former = 0;
1624 session->vht_config.tx_stbc = 0;
1625 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301626 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001627 }
1628
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001629 session->maxTxPower = lim_get_max_tx_power(reg_max,
1630 local_power_constraint,
1631 mac_ctx->roam.configParam.nTxPowerCap);
Abhinav Kumard528d192018-03-09 17:31:12 +05301632 session->def_max_tx_pwr = session->maxTxPower;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301633
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001634 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301635 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001636
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301637 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1638 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1639 pe_debug("Update MaxTxPower in join Req to %d",
1640 sme_join_req->powerCap.maxTxPower);
1641 }
1642
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001643 if (session->gLimCurrentBssUapsd) {
1644 session->gUapsdPerAcBitmask =
1645 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001646 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001647 session->gUapsdPerAcBitmask);
1648
1649 /* resetting the dynamic uapsd mask */
1650 session->gUapsdPerAcDeliveryEnableMask = 0;
1651 session->gUapsdPerAcTriggerEnableMask = 0;
1652 }
1653
1654 session->limRFBand =
1655 lim_get_rf_band(session->currentOperChannel);
1656
1657 /* Initialize 11h Enable Flag */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001658 if (BAND_5G == session->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001659 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001660 &val) != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001661 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001662 session->lim11hEnable =
1663 WNI_CFG_11H_ENABLED_STADEF;
1664 } else {
1665 session->lim11hEnable = val;
1666 }
1667 } else {
1668 session->lim11hEnable = 0;
1669 }
1670
1671 /*
1672 * To care of the scenario when STA transitions from
1673 * IBSS to Infrastructure mode.
1674 */
1675 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1676
1677 session->limPrevSmeState = session->limSmeState;
1678 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1679 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1680 session->peSessionId,
1681 session->limSmeState));
1682
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001683 /* Indicate whether spectrum management is enabled */
1684 session->spectrumMgtEnabled =
1685 sme_join_req->spectrumMgtIndicator;
1686
1687 /* Enable the spectrum management if this is a DFS channel */
1688 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001689 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001690 session->currentOperChannel))
1691 session->spectrumMgtEnabled = true;
1692
1693 session->isOSENConnection = sme_join_req->isOSENConnection;
1694
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001695 /* Issue LIM_MLM_JOIN_REQ to MLM */
1696 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1697 (uint32_t *) mlm_join_req);
1698 return;
1699
1700 } else {
1701 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001702 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001703 mac_ctx->lim.gLimSmeState);
1704 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1705 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1706 session = NULL;
1707 goto end;
1708 }
1709
1710end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301711 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1712 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001713
1714 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301715 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001716 sme_join_req = NULL;
1717 if (NULL != session)
1718 session->pLimJoinReq = NULL;
1719 }
1720 if (ret_code != eSIR_SME_SUCCESS) {
1721 if (NULL != session) {
1722 pe_delete_session(mac_ctx, session);
1723 session = NULL;
1724 }
1725 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001726 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001727 sme_session_id, ret_code);
1728 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1729 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1730 sme_transaction_id);
1731}
1732
Amar Singhala297bfa2015-10-15 15:07:29 -07001733uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001734 uint8_t iniTxPower)
1735{
1736 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301737 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001738
Anurag Chouhan6d760662016-02-20 16:05:43 +05301739 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001740 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1741 maxTxPower = txPower;
1742 else if (txPower < MIN_TX_PWR_CAP)
1743 maxTxPower = MIN_TX_PWR_CAP;
1744 else
1745 maxTxPower = MAX_TX_PWR_CAP;
1746
1747 return maxTxPower;
1748}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001749
1750/**
1751 * __lim_process_sme_reassoc_req() - process reassoc req
1752 *
1753 * @mac_ctx: Pointer to Global MAC structure
1754 * @msg_buf: pointer to the SME message buffer
1755 *
1756 * This function is called to process SME_REASSOC_REQ message
1757 * from HDD or upper layer application.
1758 *
1759 * Return: None
1760 */
1761
1762static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
1763 uint32_t *msg_buf)
1764{
1765 uint16_t caps;
1766 uint32_t val;
1767 tpSirSmeJoinReq reassoc_req = NULL;
1768 tLimMlmReassocReq *mlm_reassoc_req;
1769 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1770 tpPESession session_entry = NULL;
1771 uint8_t session_id;
1772 uint8_t sme_session_id;
1773 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001774 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001775 uint32_t tele_bcn_en = 0;
1776 uint16_t size;
1777
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001778 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301779 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001780 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001781 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001782
1783 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1784 goto end;
1785 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301786 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787
1788 if (!lim_is_sme_join_req_valid(mac_ctx,
1789 (tpSirSmeJoinReq)reassoc_req)) {
1790 /*
1791 * Received invalid eWNI_SME_REASSOC_REQ
1792 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001793 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001794
1795 ret_code = eSIR_SME_INVALID_PARAMETERS;
1796 goto end;
1797 }
1798
1799 session_entry = pe_find_session_by_bssid(mac_ctx,
1800 reassoc_req->bssDescription.bssId,
1801 &session_id);
1802 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001803 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001804 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
1805 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001806 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001807 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
1808 &sme_session_id, &transaction_id);
1809 session_entry =
1810 pe_find_session_by_sme_session_id(mac_ctx,
1811 sme_session_id);
1812 if (session_entry != NULL)
1813 lim_handle_sme_join_result(mac_ctx,
1814 eSIR_SME_INVALID_PARAMETERS,
1815 eSIR_MAC_UNSPEC_FAILURE_STATUS,
1816 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817 goto end;
1818 }
1819#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
1820 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001821 session_entry, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001822#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1823 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
1824
1825 /* Store the reassoc handle in the session Table */
1826 session_entry->pLimReAssocReq = reassoc_req;
1827
1828 session_entry->dot11mode = reassoc_req->dot11mode;
1829 session_entry->vhtCapability =
1830 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001831
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301832 if (session_entry->vhtCapability) {
1833 if (session_entry->pePersona == QDF_STA_MODE) {
1834 session_entry->vht_config.su_beam_formee =
1835 reassoc_req->vht_config.su_beam_formee;
1836 } else {
1837 reassoc_req->vht_config.su_beam_formee = 0;
1838 }
1839 session_entry->enableVhtpAid =
1840 reassoc_req->enableVhtpAid;
1841 session_entry->enableVhtGid =
1842 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001843 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301844 }
1845
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301846 session_entry->supported_nss_1x1 = reassoc_req->supported_nss_1x1;
1847 session_entry->vdev_nss = reassoc_req->vdev_nss;
1848 session_entry->nss = reassoc_req->nss;
1849 session_entry->nss_forced_1x1 = reassoc_req->nss_forced_1x1;
1850
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001851 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301852 session_entry->vhtCapability,
1853 session_entry->vht_config.su_beam_formee,
1854 session_entry->vht_config.su_beam_former);
1855
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001856 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
1857 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001858 session_entry->send_smps_action =
1859 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001860 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001861 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001862 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001863 session_entry->send_smps_action,
1864 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001865 /*
1866 * Reassociate request is expected
1867 * in link established state only.
1868 */
1869
1870 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001871 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
1872 /*
1873 * May be from 11r FT pre-auth. So lets check it
1874 * before we bail out
1875 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001876 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001877 session_entry->peSessionId);
1878
1879 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301880 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001881 session_entry->limReAssocbssId,
1882 6)) {
1883 lim_print_mac_addr(mac_ctx,
1884 reassoc_req->bssDescription.
1885 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001886 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001887 ret_code = eSIR_SME_INVALID_PARAMETERS;
1888 goto end;
1889 }
1890
1891 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
1892 session_entry);
1893 return;
1894 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001895 /*
1896 * Should not have received eWNI_SME_REASSOC_REQ
1897 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001898 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001899 session_entry->limSmeState);
1900 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
1901
1902 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1903 goto end;
1904 }
1905
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301906 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001907 session_entry->pLimReAssocReq->bssDescription.bssId,
1908 sizeof(tSirMacAddr));
1909
1910 session_entry->limReassocChannelId =
1911 session_entry->pLimReAssocReq->bssDescription.channelId;
1912
1913 session_entry->reAssocHtSupportedChannelWidthSet =
1914 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
1915 session_entry->reAssocHtRecommendedTxWidthSet =
1916 session_entry->reAssocHtSupportedChannelWidthSet;
1917 session_entry->reAssocHtSecondaryChannelOffset =
1918 session_entry->pLimReAssocReq->cbMode;
1919
1920 session_entry->limReassocBssCaps =
1921 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
1922 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1923 session_entry->currentOperChannel);
1924 local_pwr_constraint = reg_max;
1925
1926 lim_extract_ap_capability(mac_ctx,
1927 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
1928 lim_get_ielen_from_bss_description(
1929 &session_entry->pLimReAssocReq->bssDescription),
1930 &session_entry->limReassocBssQosCaps,
1931 &session_entry->limReassocBssPropCap,
1932 &session_entry->gLimCurrentBssUapsd,
1933 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05301934 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001935 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301936 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001937 /* Copy the SSID from session entry to local variable */
1938 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301939 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001940 reassoc_req->ssId.ssId,
1941 session_entry->limReassocSSID.length);
1942 if (session_entry->gLimCurrentBssUapsd) {
1943 session_entry->gUapsdPerAcBitmask =
1944 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001945 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001946 session_entry->gUapsdPerAcBitmask);
1947 }
1948
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301949 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001950 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001951 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001952
1953 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1954 goto end;
1955 }
1956
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301957 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001958 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
1959
1960 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
1961 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001962 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001963 pe_err("could not retrieve ReassocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001964
1965 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001966 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001967 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301968
1969 lim_update_caps_info_for_bss(mac_ctx, &caps,
1970 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001971 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301972
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001973 mlm_reassoc_req->capabilityInfo = caps;
1974
1975 /* Update PE session_id */
1976 mlm_reassoc_req->sessionId = session_id;
1977
1978 /*
1979 * If telescopic beaconing is enabled, set listen interval to
1980 * WNI_CFG_TELE_BCN_MAX_LI
1981 */
1982 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001983 &tele_bcn_en) != QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001984 pe_err("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001985
1986 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
1987
1988 if (tele_bcn_en) {
1989 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001990 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001991 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001992 } else {
1993 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001994 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001995 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001996 }
1997
1998 mlm_reassoc_req->listenInterval = (uint16_t) val;
1999
2000 /* Indicate whether spectrum management is enabled */
2001 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2002
2003 /* Enable the spectrum management if this is a DFS channel */
2004 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002005 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002006 session_entry->currentOperChannel))
2007 session_entry->spectrumMgtEnabled = true;
2008
2009 session_entry->limPrevSmeState = session_entry->limSmeState;
2010 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2011
2012 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2013 session_entry->peSessionId,
2014 session_entry->limSmeState));
2015
2016 lim_post_mlm_message(mac_ctx,
2017 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2018 return;
2019end:
2020 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302021 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002022 if (session_entry)
2023 session_entry->pLimReAssocReq = NULL;
2024 }
2025
2026 if (session_entry) {
2027 /*
2028 * error occurred after we determined the session so extract
2029 * session and transaction info from there
2030 */
2031 sme_session_id = session_entry->smeSessionId;
2032 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002033 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002034 /*
2035 * error occurred before or during the time we determined
2036 * the session so extract the session and transaction info
2037 * from the message
2038 */
2039 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2040 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002041 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002042 /*
2043 * Send Reassoc failure response to host
2044 * (note session_entry may be NULL, but that's OK)
2045 */
2046 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2047 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2048 session_entry, sme_session_id,
2049 transaction_id);
2050}
2051
2052bool send_disassoc_frame = 1;
2053/**
2054 * __lim_process_sme_disassoc_req()
2055 *
2056 ***FUNCTION:
2057 * This function is called to process SME_DISASSOC_REQ message
2058 * from HDD or upper layer application.
2059 *
2060 ***LOGIC:
2061 *
2062 ***ASSUMPTIONS:
2063 *
2064 ***NOTE:
2065 *
2066 * @param pMac Pointer to Global MAC structure
2067 * @param *pMsgBuf A pointer to the SME message buffer
2068 * @return None
2069 */
2070
2071static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2072{
2073 uint16_t disassocTrigger, reasonCode;
2074 tLimMlmDisassocReq *pMlmDisassocReq;
2075 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2076 tSirSmeDisassocReq smeDisassocReq;
2077 tpPESession psessionEntry = NULL;
2078 uint8_t sessionId;
2079 uint8_t smesessionId;
2080 uint16_t smetransactionId;
2081
2082 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002083 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002084 return;
2085 }
2086
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302087 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002088 smesessionId = smeDisassocReq.sessionId;
2089 smetransactionId = smeDisassocReq.transactionId;
2090 if (!lim_is_sme_disassoc_req_valid(pMac,
2091 &smeDisassocReq,
2092 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002093 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002094 if (pMac->lim.gLimRspReqd) {
2095 pMac->lim.gLimRspReqd = false;
2096
2097 retCode = eSIR_SME_INVALID_PARAMETERS;
2098 disassocTrigger = eLIM_HOST_DISASSOC;
2099 goto sendDisassoc;
2100 }
2101
2102 return;
2103 }
2104
2105 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002106 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002107 &sessionId);
2108 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002109 pe_err("session does not exist for given bssId "
2110 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002111 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002112 retCode = eSIR_SME_INVALID_PARAMETERS;
2113 disassocTrigger = eLIM_HOST_DISASSOC;
2114 goto sendDisassoc;
2115 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002116 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2117 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002118 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2119 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002120 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002121
2122#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2123 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2124 0, smeDisassocReq.reasonCode);
2125#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2126
2127 /* Update SME session Id and SME transaction ID */
2128
2129 psessionEntry->smeSessionId = smesessionId;
2130 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002131 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002132 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002133
2134 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2135 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002136 switch (psessionEntry->limSmeState) {
2137 case eLIM_SME_ASSOCIATED_STATE:
2138 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002139 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002140 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002141 psessionEntry->limPrevSmeState =
2142 psessionEntry->limSmeState;
2143 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002144 /* Delete all TDLS peers connected before leaving BSS */
2145 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002146 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2147 psessionEntry->peSessionId,
2148 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149 break;
2150
2151 case eLIM_SME_WT_DEAUTH_STATE:
2152 /* PE shall still process the DISASSOC_REQ and proceed with
2153 * link tear down even if it had already sent a DEAUTH_IND to
2154 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2155 * its been set when PE entered WT_DEAUTH_STATE.
2156 */
2157 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2158 MTRACE(mac_trace
2159 (pMac, TRACE_CODE_SME_STATE,
2160 psessionEntry->peSessionId,
2161 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002162 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002163 break;
2164
2165 case eLIM_SME_WT_DISASSOC_STATE:
Jeff Johnson47d75242018-05-12 15:58:53 -07002166 /* PE Received a Disassoc frame. Normally it gets DISASSOC_CNF but it
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002167 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2168 * PE can continue processing DISASSOC_REQ and send the response instead
2169 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2170 * for disassoc frame.
2171 *
2172 * It will send a disassoc, which is ok. However, we can use the global flag
2173 * sendDisassoc to not send disassoc frame.
2174 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002175 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002176 break;
2177
2178 case eLIM_SME_JOIN_FAILURE_STATE: {
2179 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002180 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002181 if (pMac->lim.gLimRspReqd) {
2182 retCode = eSIR_SME_SUCCESS;
2183 disassocTrigger = eLIM_HOST_DISASSOC;
2184 goto sendDisassoc;
2185 }
2186 }
2187 break;
2188 default:
2189 /**
2190 * STA is not currently associated.
2191 * Log error and send response to host
2192 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002193 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002194 psessionEntry->limSmeState);
2195 lim_print_sme_state(pMac, LOGE,
2196 psessionEntry->limSmeState);
2197
2198 if (pMac->lim.gLimRspReqd) {
2199 if (psessionEntry->limSmeState !=
2200 eLIM_SME_WT_ASSOC_STATE)
2201 pMac->lim.gLimRspReqd = false;
2202
2203 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2204 disassocTrigger = eLIM_HOST_DISASSOC;
2205 goto sendDisassoc;
2206 }
2207
2208 return;
2209 }
2210
2211 break;
2212
2213 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002214 /* Fall through */
2215 break;
2216
2217 case eLIM_STA_IN_IBSS_ROLE:
2218 default:
2219 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002220 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002221 GET_LIM_SYSTEM_ROLE(psessionEntry));
2222
2223 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2224 disassocTrigger = eLIM_HOST_DISASSOC;
2225 goto sendDisassoc;
2226 } /* end switch (pMac->lim.gLimSystemRole) */
2227
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302228 disassocTrigger = eLIM_HOST_DISASSOC;
2229 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002230
2231 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002232 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002233 send_disassoc_frame = 0;
2234 }
2235 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002236 pe_debug("Sending Disasscoc with disassoc Trigger"
2237 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002238 disassocTrigger, reasonCode);
2239
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302240 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002241 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002242 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002243 return;
2244 }
2245
Anurag Chouhanc5548422016-02-24 18:33:27 +05302246 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002247 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002248
2249 pMlmDisassocReq->reasonCode = reasonCode;
2250 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2251
2252 /* Update PE session ID */
2253 pMlmDisassocReq->sessionId = sessionId;
2254
2255 lim_post_mlm_message(pMac,
2256 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2257 return;
2258
2259sendDisassoc:
2260 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002261 lim_send_sme_disassoc_ntf(pMac,
2262 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002263 retCode,
2264 disassocTrigger,
2265 1, smesessionId, smetransactionId,
2266 psessionEntry);
2267 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002268 lim_send_sme_disassoc_ntf(pMac,
2269 smeDisassocReq.peer_macaddr.bytes,
2270 retCode, disassocTrigger, 1,
2271 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002272
2273} /*** end __lim_process_sme_disassoc_req() ***/
2274
2275/** -----------------------------------------------------------------
2276 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2277
2278 This function is called to process SME_DISASSOC_CNF message
2279 from HDD or upper layer application.
2280
2281 \param pMac - global mac structure
2282 \param pStaDs - station dph hash node
2283 \return none
2284 \sa
2285 ----------------------------------------------------------------- */
2286static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2287{
2288 tSirSmeDisassocCnf smeDisassocCnf;
2289 uint16_t aid;
2290 tpDphHashNode pStaDs;
2291 tpPESession psessionEntry;
2292 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302293 uint32_t *msg = NULL;
2294 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002295
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302296 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002297 sizeof(struct sSirSmeDisassocCnf));
2298
2299 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002300 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002301 &sessionId);
2302 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002303 pe_err("session does not exist for given bssId");
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302304 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302305 smeDisassocCnf.sme_session_id,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302306 eSIR_SME_INVALID_SESSION,
2307 NULL);
2308 if (QDF_IS_STATUS_SUCCESS(status))
2309 lim_send_sme_disassoc_deauth_ntf(pMac,
2310 QDF_STATUS_SUCCESS,
2311 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002312 return;
2313 }
2314
2315 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002316 pe_err("received invalid SME_DISASSOC_CNF message");
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302317 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2318 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302319 eSIR_SME_INVALID_PARAMETERS,
2320 &smeDisassocCnf.bssid.bytes[0]);
2321 if (QDF_IS_STATUS_SUCCESS(status))
2322 lim_send_sme_disassoc_deauth_ntf(pMac,
2323 QDF_STATUS_SUCCESS,
2324 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002325 return;
2326 }
2327#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2328 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2329 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2330 psessionEntry,
2331 (uint16_t) smeDisassocCnf.statusCode, 0);
2332 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2333 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2334 psessionEntry,
2335 (uint16_t) smeDisassocCnf.statusCode, 0);
2336#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2337
2338 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2339 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002340 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2341 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2342 && (psessionEntry->limSmeState !=
2343 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002344 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002345 psessionEntry->limSmeState);
2346 lim_print_sme_state(pMac, LOGE,
2347 psessionEntry->limSmeState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302348 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302349 psessionEntry->smeSessionId,
2350 eSIR_SME_INVALID_STATE,
2351 &smeDisassocCnf.bssid.bytes[0]);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302352 if (QDF_IS_STATUS_SUCCESS(status))
2353 lim_send_sme_disassoc_deauth_ntf(pMac,
2354 QDF_STATUS_SUCCESS,
2355 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002356 return;
2357 }
2358 break;
2359
2360 case eLIM_AP_ROLE:
2361 /* Fall through */
2362 break;
2363
2364 case eLIM_STA_IN_IBSS_ROLE:
2365 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002366 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002367 GET_LIM_SYSTEM_ROLE(psessionEntry));
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302368 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2369 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302370 eSIR_SME_INVALID_STATE,
2371 &smeDisassocCnf.bssid.bytes[0]);
2372 if (QDF_IS_STATUS_SUCCESS(status))
2373 lim_send_sme_disassoc_deauth_ntf(pMac,
2374 QDF_STATUS_SUCCESS,
2375 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002376 return;
2377 }
2378
2379 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2380 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2381 LIM_IS_AP_ROLE(psessionEntry)) {
2382 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002383 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002384 &psessionEntry->dph.dphHashTable);
2385 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002386 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2387 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002388 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302389 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302390 psessionEntry->smeSessionId,
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05302391 eSIR_SME_INVALID_PARAMETERS,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302392 &smeDisassocCnf.bssid.bytes[0]);
2393 if (QDF_IS_STATUS_SUCCESS(status))
2394 lim_send_sme_disassoc_deauth_ntf(pMac,
2395 QDF_STATUS_SUCCESS,
2396 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002397 return;
2398 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302399
2400 if ((pStaDs->mlmStaContext.mlmState ==
2401 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2402 (pStaDs->mlmStaContext.mlmState ==
Arif Hussain5fa13782018-05-10 11:29:52 -07002403 eLIM_MLM_WT_DEL_BSS_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002404 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002405 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302406 pStaDs->mlmStaContext.mlmState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302407 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302408 psessionEntry->smeSessionId,
2409 eSIR_SME_SUCCESS,
2410 NULL);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302411 if (QDF_IS_STATUS_SUCCESS(status))
2412 lim_send_sme_disassoc_deauth_ntf(pMac,
2413 QDF_STATUS_SUCCESS,
2414 (uint32_t *)msg);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302415 return;
2416 }
2417
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002418 /* Delete FT session if there exists one */
2419 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002420 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2421
2422 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002423 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002424 }
2425
2426 return;
2427}
2428
2429/**
2430 * __lim_process_sme_deauth_req() - process sme deauth req
2431 * @mac_ctx: Pointer to Global MAC structure
2432 * @msg_buf: pointer to the SME message buffer
2433 *
2434 * This function is called to process SME_DEAUTH_REQ message
2435 * from HDD or upper layer application.
2436 *
2437 * Return: None
2438 */
2439
2440static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2441 uint32_t *msg_buf)
2442{
2443 uint16_t deauth_trigger, reason_code;
2444 tLimMlmDeauthReq *mlm_deauth_req;
2445 tSirSmeDeauthReq sme_deauth_req;
2446 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2447 tpPESession session_entry;
2448 uint8_t session_id; /* PE sessionId */
2449 uint8_t sme_session_id;
2450 uint16_t sme_transaction_id;
2451
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302452 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002453 sme_session_id = sme_deauth_req.sessionId;
2454 sme_transaction_id = sme_deauth_req.transactionId;
2455
2456 /*
2457 * We need to get a session first but we don't even know
2458 * if the message is correct.
2459 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002460 session_entry = pe_find_session_by_bssid(mac_ctx,
2461 sme_deauth_req.bssid.bytes,
2462 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002463 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002464 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002465 ret_code = eSIR_SME_INVALID_PARAMETERS;
2466 deauth_trigger = eLIM_HOST_DEAUTH;
2467 goto send_deauth;
2468 }
2469
2470 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2471 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002472 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002473 mac_ctx->lim.gLimRspReqd = false;
2474
2475 ret_code = eSIR_SME_INVALID_PARAMETERS;
2476 deauth_trigger = eLIM_HOST_DEAUTH;
2477 goto send_deauth;
2478 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002479 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2480 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002481 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2482 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002483 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002484#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2485 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2486 session_entry, 0, sme_deauth_req.reasonCode);
2487#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2488
2489 /* Update SME session ID and Transaction ID */
2490 session_entry->smeSessionId = sme_session_id;
2491 session_entry->transactionId = sme_transaction_id;
2492
2493 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2494 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002495 switch (session_entry->limSmeState) {
2496 case eLIM_SME_ASSOCIATED_STATE:
2497 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302498 /* Delete all TDLS peers connected before leaving BSS */
2499 lim_delete_tdls_peers(mac_ctx, session_entry);
Abhinav Kumarac12c762018-05-02 13:51:02 +05302500 /* fallthrough */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002501 case eLIM_SME_WT_ASSOC_STATE:
2502 case eLIM_SME_JOIN_FAILURE_STATE:
2503 case eLIM_SME_IDLE_STATE:
2504 session_entry->limPrevSmeState =
2505 session_entry->limSmeState;
2506 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2507 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2508 session_entry->peSessionId,
2509 session_entry->limSmeState));
2510 /* Send Deauthentication request to MLM below */
2511 break;
2512 case eLIM_SME_WT_DEAUTH_STATE:
2513 case eLIM_SME_WT_DISASSOC_STATE:
2514 /*
Jeff Johnson47d75242018-05-12 15:58:53 -07002515 * PE Received a Deauth/Disassoc frame. Normally it get
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002516 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2517 * Which means host is also trying to disconnect.
2518 * PE can continue processing DEAUTH_REQ and send
2519 * the response instead of failing the request.
2520 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2521 * was sent for deauth/disassoc frame.
2522 */
2523 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002524 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002525 break;
2526 default:
2527 /*
2528 * STA is not in a state to deauthenticate with
2529 * peer. Log error and send response to host.
2530 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002531 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002532 session_entry->limSmeState);
2533 lim_print_sme_state(mac_ctx, LOGE,
2534 session_entry->limSmeState);
2535
2536 if (mac_ctx->lim.gLimRspReqd) {
2537 mac_ctx->lim.gLimRspReqd = false;
2538
2539 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2540 deauth_trigger = eLIM_HOST_DEAUTH;
2541
wadesong42968e92017-06-08 14:11:21 +08002542 /*
2543 * here we received deauth request from AP so
2544 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2545 * have ISSUED delSta then mlm state should be
2546 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2547 * delBSS rsp then mlm state should be
2548 * eLIM_MLM_IDLE_STATE so the below condition
2549 * captures the state where delSta not done
2550 * and firmware still in connected state.
2551 */
2552 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002553 eLIM_SME_WT_DEAUTH_STATE &&
2554 session_entry->limMlmState !=
2555 eLIM_MLM_IDLE_STATE &&
2556 session_entry->limMlmState !=
2557 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002558 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002559 goto send_deauth;
2560 }
2561 return;
2562 }
2563 break;
2564
2565 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002566 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002567 if (mac_ctx->lim.gLimRspReqd) {
2568 mac_ctx->lim.gLimRspReqd = false;
2569 ret_code = eSIR_SME_INVALID_PARAMETERS;
2570 deauth_trigger = eLIM_HOST_DEAUTH;
2571 goto send_deauth;
2572 }
2573 return;
2574 case eLIM_AP_ROLE:
2575 break;
2576 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002577 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002578 GET_LIM_SYSTEM_ROLE(session_entry));
2579 if (mac_ctx->lim.gLimRspReqd) {
2580 mac_ctx->lim.gLimRspReqd = false;
2581 ret_code = eSIR_SME_INVALID_PARAMETERS;
2582 deauth_trigger = eLIM_HOST_DEAUTH;
2583 goto send_deauth;
2584 }
2585 return;
2586 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2587
2588 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2589 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002590 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002591 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2592 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2593 } else {
2594 deauth_trigger = eLIM_HOST_DEAUTH;
2595 reason_code = sme_deauth_req.reasonCode;
2596 }
2597
2598 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302599 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002600 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002601 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002602 if (mac_ctx->lim.gLimRspReqd) {
2603 mac_ctx->lim.gLimRspReqd = false;
2604 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2605 deauth_trigger = eLIM_HOST_DEAUTH;
2606 goto send_deauth;
2607 }
2608 return;
2609 }
2610
Anurag Chouhanc5548422016-02-24 18:33:27 +05302611 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002612 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002613
2614 mlm_deauth_req->reasonCode = reason_code;
2615 mlm_deauth_req->deauthTrigger = deauth_trigger;
2616
2617 /* Update PE session Id */
2618 mlm_deauth_req->sessionId = session_id;
2619
2620 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2621 (uint32_t *)mlm_deauth_req);
2622 return;
2623
2624send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002625 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2626 ret_code, deauth_trigger, 1,
2627 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002628}
2629
2630/**
2631 * __lim_process_sme_set_context_req()
2632 *
2633 * @mac_ctx: Pointer to Global MAC structure
2634 * @msg_buf: pointer to the SME message buffer
2635 *
2636 * This function is called to process SME_SETCONTEXT_REQ message
2637 * from HDD or upper layer application.
2638 *
2639 * Return: None
2640 */
2641
2642static void
2643__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2644{
2645 tpSirSmeSetContextReq set_context_req;
2646 tLimMlmSetKeysReq *mlm_set_key_req;
2647 tpPESession session_entry;
2648 uint8_t session_id; /* PE sessionID */
2649 uint8_t sme_session_id;
2650 uint16_t sme_transaction_id;
2651
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002652 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002653 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002654 return;
2655 }
2656
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302657 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002658 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002659 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660 return;
2661 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302662 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002663 sizeof(struct sSirSmeSetContextReq));
2664 sme_session_id = set_context_req->sessionId;
2665 sme_transaction_id = set_context_req->transactionId;
2666
2667 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002668 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002669 goto end;
2670 }
2671
2672 if (set_context_req->keyMaterial.numKeys >
2673 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002674 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002675 set_context_req->keyMaterial.numKeys);
2676 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002677 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002678 eSIR_SME_INVALID_PARAMETERS, NULL,
2679 sme_session_id, sme_transaction_id);
2680 goto end;
2681 }
2682
2683 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002684 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002685 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002686 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002687 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002688 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002689 eSIR_SME_INVALID_PARAMETERS, NULL,
2690 sme_session_id, sme_transaction_id);
2691 goto end;
2692 }
2693#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2694 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2695 session_entry, 0, 0);
2696#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2697
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002698 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002699 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2700 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002701 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002702 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2703 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302704 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002705 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002706 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002707 goto end;
2708 }
2709 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2710 mlm_set_key_req->numKeys =
2711 set_context_req->keyMaterial.numKeys;
2712 if (mlm_set_key_req->numKeys >
2713 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002714 pe_err("no.of keys exceeded max num of default keys limit");
Jingxiang Ge4168a232018-01-03 18:47:15 +08002715 qdf_mem_free(mlm_set_key_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002716 goto end;
2717 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302718 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002719 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002720
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302721 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002722 (uint8_t *) &set_context_req->keyMaterial.key,
2723 sizeof(tSirKeys) *
2724 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2725 numKeys : 1));
2726
2727 mlm_set_key_req->sessionId = session_id;
2728 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002729 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002730 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002731
2732 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2733 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2734 LIM_IS_AP_ROLE(session_entry)) {
2735 if (set_context_req->keyMaterial.key[0].keyLength) {
2736 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002737
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002738 key_id =
2739 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302740 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002741 &session_entry->WEPKeyMaterial[key_id],
2742 (uint8_t *) &set_context_req->keyMaterial,
2743 sizeof(tSirKeyMaterial));
2744 } else {
2745 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002746
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002747 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2748 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302749 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002750 &mlm_set_key_req->key[i],
2751 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2752 sizeof(tSirKeys));
2753 }
2754 }
2755 }
2756 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2757 (uint32_t *) mlm_set_key_req);
2758 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002759 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002760 GET_LIM_SYSTEM_ROLE(session_entry),
2761 session_entry->limSmeState);
2762 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2763
2764 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002765 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002766 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2767 session_entry, sme_session_id,
2768 sme_transaction_id);
2769 }
2770end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302771 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002772 return;
2773}
2774
2775/**
2776 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2777 *
2778 * @mac_ctx: Pointer to Global MAC structure
2779 * @msg_buf: pointer to the SME message buffer
2780 *
2781 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2782 * from HDD or upper layer application.
2783 *
2784 * Return: None
2785 */
2786
Jeff Johnson801f1532016-10-07 07:54:50 -07002787static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2788 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002789{
2790 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2791 tpDphHashNode sta_ds = NULL;
2792 tpPESession session_entry = NULL;
2793 tSap_Event sap_event;
2794 tpWLAN_SAPEventCB sap_event_cb = NULL;
2795 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2796 uint8_t session_id = CSR_SESSION_ID_INVALID;
2797 uint8_t assoc_id = 0;
2798 uint8_t sta_cnt = 0;
2799
2800 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002801 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002802 return;
2803 }
2804
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302805 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002806 sizeof(struct sSirSmeGetAssocSTAsReq));
2807 /*
2808 * Get Associated stations from PE.
2809 * Find PE session Entry
2810 */
2811 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08002812 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002813 &session_id);
2814 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002815 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002816 goto lim_assoc_sta_end;
2817 }
2818
2819 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002820 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002821 session_entry->limSmeState,
2822 GET_LIM_SYSTEM_ROLE(session_entry));
2823 goto lim_assoc_sta_end;
2824 }
2825 /* Retrieve values obtained in the request message */
2826 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
2827 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2828
2829 if (NULL == assoc_sta_tmp)
2830 goto lim_assoc_sta_end;
2831 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
2832 assoc_id++) {
2833 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
2834 &session_entry->dph.dphHashTable);
2835 if (NULL == sta_ds)
2836 continue;
2837 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302838 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002839 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302840 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002841 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
2842 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
2843
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302844 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002845 (uint8_t *)&sta_ds->supportedRates,
2846 sizeof(tSirSupportedRates));
2847 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
2848 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
2849 assoc_sta_tmp->Support40Mhz =
2850 sta_ds->htDsssCckRate40MHzSupport;
2851
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002852 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002853 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002854 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002855 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002856 pe_debug("Association Id: %d Station Index: %d",
2857 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002858 assoc_sta_tmp++;
2859 sta_cnt++;
2860 }
2861 }
2862lim_assoc_sta_end:
2863 /*
2864 * Call hdd callback with sap event to send the list of
2865 * associated stations from PE
2866 */
2867 if (sap_event_cb != NULL) {
2868 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
2869 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302870 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002871 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
2872 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
2873 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2874 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
2875 }
2876}
2877
2878/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002879 * __lim_counter_measures()
2880 *
2881 * FUNCTION:
2882 * This function is called to "implement" MIC counter measure
2883 * and is *temporary* only
2884 *
2885 * LOGIC: on AP, disassoc all STA associated thru TKIP,
2886 * we don't do the proper STA disassoc sequence since the
Jeff Johnsond460e842018-05-11 13:25:53 -07002887 * BSS will be stopped anyway
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002888 *
2889 ***ASSUMPTIONS:
2890 *
2891 ***NOTE:
2892 *
2893 * @param pMac Pointer to Global MAC structure
2894 * @return None
2895 */
2896
2897static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
2898{
2899 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002900
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002901 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002902 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
2903 mac, psessionEntry, false);
2904};
2905
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002906static void
2907__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2908{
2909 tSirSmeStopBssReq stopBssReq;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002910 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002911 tLimSmeStates prevState;
2912 tpPESession psessionEntry;
2913 uint8_t smesessionId;
2914 uint8_t sessionId;
2915 uint16_t smetransactionId;
2916 uint8_t i = 0;
2917 tpDphHashNode pStaDs = NULL;
2918
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302919 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002920 smesessionId = stopBssReq.sessionId;
2921 smetransactionId = stopBssReq.transactionId;
2922
2923 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002924 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002925 /* Send Stop BSS response to host */
2926 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2927 eSIR_SME_INVALID_PARAMETERS, smesessionId,
2928 smetransactionId);
2929 return;
2930 }
2931
2932 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08002933 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002934 &sessionId);
2935 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002936 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002937 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2938 eSIR_SME_INVALID_PARAMETERS, smesessionId,
2939 smetransactionId);
2940 return;
2941 }
2942#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2943 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
2944 0, 0);
2945#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2946
2947 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
2948 LIM_IS_STA_ROLE(psessionEntry)) {
2949 /**
2950 * Should not have received STOP_BSS_REQ in states
2951 * other than 'normal' state or on STA in Infrastructure
2952 * mode. Log error and return response to host.
2953 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002954 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002955 psessionEntry->limSmeState,
2956 GET_LIM_SYSTEM_ROLE(psessionEntry));
2957 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
2958 /* / Send Stop BSS response to host */
2959 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2960 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
2961 smetransactionId);
2962 return;
2963 }
2964
2965 if (LIM_IS_AP_ROLE(psessionEntry))
2966 lim_wpspbc_close(pMac, psessionEntry);
2967
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002968 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002969 stopBssReq.reasonCode);
2970
2971 prevState = psessionEntry->limSmeState;
2972
2973 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
2974 MTRACE(mac_trace
2975 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
2976 psessionEntry->limSmeState));
2977
2978 /* Update SME session Id and Transaction Id */
2979 psessionEntry->smeSessionId = smesessionId;
2980 psessionEntry->transactionId = smetransactionId;
2981
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002982 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
2983 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
2984 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002985 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002986
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002987 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
2988 /* Send disassoc all stations associated thru TKIP */
2989 __lim_counter_measures(pMac, psessionEntry);
2990 else
2991 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002992 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
2993 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002994 }
2995
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002996 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
2997 /* Free the buffer allocated in START_BSS_REQ */
2998 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
2999 psessionEntry->addIeParams.probeRespDataLen = 0;
3000 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003001
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003002 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3003 psessionEntry->addIeParams.assocRespDataLen = 0;
3004 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003005
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003006 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3007 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3008 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003009
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003010 /*
3011 * lim_del_bss is also called as part of coalescing,
3012 * when we send DEL BSS followed by Add Bss msg.
3013 */
3014 pMac->lim.gLimIbssCoalescingHappened = false;
3015 }
Sandeep Puligillaa894ffc2018-06-01 15:33:36 -07003016 for (i = 1; i < psessionEntry->dph.dphHashTable.size; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003017 pStaDs =
3018 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3019 if (NULL == pStaDs)
3020 continue;
3021 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003022 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003023 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3024 pStaDs->assocId, psessionEntry);
3025 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3026 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003027 pe_err("lim_del_sta failed with Status: %d", status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303028 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003029 }
3030 }
3031 /* send a delBss to HAL and wait for a response */
3032 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3033
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003034 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003035 pe_err("delBss failed for bss %d", psessionEntry->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003036 psessionEntry->limSmeState = prevState;
3037
3038 MTRACE(mac_trace
3039 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3040 psessionEntry->limSmeState));
3041
3042 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3043 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3044 smetransactionId);
3045 }
3046}
3047
3048/**
3049 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3050 * @pMac: Global MAC context
3051 * @pMsg: Message from SME
3052 *
3053 * Wrapper for the function __lim_handle_sme_stop_bss_request
3054 * This message will be defered until softmac come out of
3055 * scan mode. Message should be handled even if we have
3056 * detected radar in the current operating channel.
3057 *
3058 * Return: true - If we consumed the buffer
3059 * false - If have defered the message.
3060 */
3061
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003062static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3063 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003064{
3065 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3066 /**
3067 * If message defered, buffer is not consumed yet.
3068 * So return false
3069 */
3070 return false;
3071 }
3072 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3073 return true;
3074} /*** end __lim_process_sme_stop_bss_req() ***/
3075
3076void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3077 uint32_t body, tpPESession psessionEntry)
3078{
3079
3080 (void)body;
3081 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3082 lim_ibss_delete(pMac, psessionEntry);
3083 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3084 lim_delete_pre_auth_list(pMac);
3085 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3086 psessionEntry->smeSessionId,
3087 psessionEntry->transactionId);
3088 return;
3089}
3090
3091/**
3092 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3093 *
3094 * @mac_ctx: pointer to mac context
3095 * @msg_type: message type
3096 * @msg_buf: pointer to the SME message buffer
3097 *
3098 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3099 * in BTAMP AP.
3100 *
3101 * Return: None
3102 */
3103
3104void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3105 uint32_t *msg_buf)
3106{
3107 tSirSmeAssocCnf assoc_cnf;
3108 tpDphHashNode sta_ds = NULL;
3109 tpPESession session_entry = NULL;
3110 uint8_t session_id;
3111 tpSirAssocReq assoc_req;
3112
3113 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003114 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003115 goto end;
3116 }
3117
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303118 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003119 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003120 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003121 goto end;
3122 }
3123
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003124 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003125 &session_id);
3126 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003127 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003128 goto end;
3129 }
3130
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003131 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003132 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3133 (session_entry->limSmeState !=
3134 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003135 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003136 msg_type, session_entry->limSmeState,
3137 GET_LIM_SYSTEM_ROLE(session_entry));
3138 goto end;
3139 }
3140 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3141 &session_entry->dph.dphHashTable);
3142 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003143 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003144 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303145 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003146
3147 /*
3148 * send a DISASSOC_IND message to WSM to make sure
3149 * the state in WSM and LIM is the same
3150 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003151 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003152 eSIR_SME_STA_NOT_ASSOCIATED,
3153 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3154 session_entry->smeSessionId,
3155 session_entry->transactionId,
3156 session_entry);
3157 goto end;
3158 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303159 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003160 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303161 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003162 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003163 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303164 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003165 goto end;
3166 }
3167
3168 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3169 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3170 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3171 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3172 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003173 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3174 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003175 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303176 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003177 goto end;
3178 }
3179 /*
3180 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3181 * has been received
3182 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003183 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003184 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3185 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3186
3187 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3188 /*
3189 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3190 * when it had received Assoc Request frame. Now, PE just needs
3191 * to send association rsp frame to the requesting BTAMP-STA.
3192 */
3193 sta_ds->mlmStaContext.mlmState =
3194 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003195 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003196 sta_ds->assocId);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003197 lim_send_assoc_rsp_mgmt_frame(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003198 sta_ds->assocId, sta_ds->staAddr,
3199 sta_ds->mlmStaContext.subType, sta_ds,
3200 session_entry);
3201 goto end;
3202 } else {
3203 /*
3204 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3205 * to be associated since the HAL sta entry is created for
3206 * denied STA we need to remove this HAL entry.
3207 * So to do that set updateContext to 1
3208 */
3209 if (!sta_ds->mlmStaContext.updateContext)
3210 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003211 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003212 assoc_cnf.statusCode, sta_ds->assocId);
3213 lim_reject_association(mac_ctx, sta_ds->staAddr,
3214 sta_ds->mlmStaContext.subType,
3215 true, sta_ds->mlmStaContext.authType,
3216 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003217 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218 session_entry);
3219 }
3220end:
3221 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3222 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3223 assoc_req = (tpSirAssocReq)
3224 session_entry->parsedAssocReq[sta_ds->assocId];
3225 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303226 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003227 assoc_req->assocReqFrame = NULL;
3228 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303229 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003230 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3231 }
3232}
3233
3234static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3235{
3236 tpDphHashNode pStaDs;
3237 tSirMacAddr peerMac;
3238 tpSirAddtsReq pSirAddts;
3239 uint32_t timeout;
3240 tpPESession psessionEntry;
3241 uint8_t sessionId; /* PE sessionId */
3242 uint8_t smesessionId;
3243 uint16_t smetransactionId;
3244
3245 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003246 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003247 return;
3248 }
3249
3250 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3251 &smetransactionId);
3252
3253 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3254
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003255 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3256 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003257 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003258 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003259 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303260 NULL, pSirAddts->req.tspec,
3261 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003262 return;
3263 }
3264#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3265 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3266 0);
3267#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3268
3269 /* if sta
3270 * - verify assoc state
3271 * - send addts request to ap
3272 * - wait for addts response from ap
3273 * if ap, just ignore with error log
3274 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003275 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3276 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3277 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003278
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003279 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003280 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303281 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003282 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283
3284 pStaDs =
3285 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3286 &psessionEntry->dph.dphHashTable);
3287
3288 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003289 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303290 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003291 }
3292
3293 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3294 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003295 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303296 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003297 }
3298
3299 pSirAddts->req.wsmTspecPresent = 0;
3300 pSirAddts->req.wmeTspecPresent = 0;
3301 pSirAddts->req.lleTspecPresent = 0;
3302
3303 if ((pStaDs->wsmEnabled) &&
3304 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3305 SIR_MAC_ACCESSPOLICY_EDCA))
3306 pSirAddts->req.wsmTspecPresent = 1;
3307 else if (pStaDs->wmeEnabled)
3308 pSirAddts->req.wmeTspecPresent = 1;
3309 else if (pStaDs->lleEnabled)
3310 pSirAddts->req.lleTspecPresent = 1;
3311 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003312 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303313 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003314 }
3315
3316 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3317 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003318 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003319 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303320 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321 }
3322
3323 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003324 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003325 pMac->lim.gLimAddtsReq.req.dialogToken,
3326 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3327 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3328 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303329 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330 }
3331
3332 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3333
3334 /* save the addts request */
3335 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303336 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003337 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3338
3339 /* ship out the message now */
3340 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3341 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303342 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003343 /* start a timer to wait for the response */
3344 if (pSirAddts->timeout)
3345 timeout = pSirAddts->timeout;
3346 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003347 QDF_STATUS_SUCCESS) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303348 pe_debug("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003349 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303350 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003351 }
3352
3353 timeout = SYS_MS_TO_TICKS(timeout);
3354 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3355 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003356 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303357 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003358 }
3359 pMac->lim.gLimAddtsRspTimerCount++;
3360 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3361 pMac->lim.gLimAddtsRspTimerCount) !=
3362 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003363 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303364 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003365 }
3366 MTRACE(mac_trace
3367 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3368 eLIM_ADDTS_RSP_TIMER));
3369
3370 /* add the sessionId to the timer object */
3371 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3372 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3373 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003374 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303375 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003376 }
3377 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303378
3379send_failure_addts_rsp:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003380 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303381 psessionEntry, pSirAddts->req.tspec,
3382 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003383}
3384
3385static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3386{
3387 tSirMacAddr peerMacAddr;
3388 uint8_t ac;
3389 tSirMacTSInfo *pTsinfo;
3390 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3391 tpDphHashNode pStaDs = NULL;
3392 tpPESession psessionEntry;
3393 uint8_t sessionId;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003394 uint32_t status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003395 uint8_t smesessionId;
3396 uint16_t smetransactionId;
3397
3398 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3399 &smetransactionId);
3400
3401 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003402 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003403 &sessionId);
3404 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003405 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003406 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003407 goto end;
3408 }
3409#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3410 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3411 0);
3412#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3413
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003414 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003415 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003416 pe_err("lim_validate_delts_req failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003417 status = QDF_STATUS_E_FAILURE;
3418 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_E_FAILURE, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003419 smesessionId, smetransactionId);
3420 return;
3421 }
3422
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003423 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3424 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003425 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3426
3427 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3428 pDeltsReq->req.wmeTspecPresent,
3429 &pDeltsReq->req.tsinfo,
3430 &pDeltsReq->req.tspec, psessionEntry);
3431
3432 pTsinfo =
3433 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3434 tsinfo : &pDeltsReq->req.tsinfo;
3435
3436 /* We've successfully send DELTS frame to AP. Update the
3437 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3438 * is no longer trigger enabled or delivery enabled
3439 */
3440 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3441 pTsinfo, CLEAR_UAPSD_MASK);
3442
3443 /* We're deleting the TSPEC, so this particular AC is no longer
3444 * admitted. PE needs to downgrade the EDCA
3445 * parameters(for the AC for which TS is being deleted) to the
3446 * next best AC for which ACM is not enabled, and send the
3447 * updated values to HAL.
3448 */
3449 ac = upToAc(pTsinfo->traffic.userPrio);
3450
3451 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3452 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3453 ~(1 << ac);
3454 } else if (pTsinfo->traffic.direction ==
3455 SIR_MAC_DIRECTION_DNLINK) {
3456 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3457 ~(1 << ac);
3458 } else if (pTsinfo->traffic.direction ==
3459 SIR_MAC_DIRECTION_BIDIR) {
3460 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3461 ~(1 << ac);
3462 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3463 ~(1 << ac);
3464 }
3465
3466 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3467 psessionEntry);
3468
3469 pStaDs =
3470 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3471 &psessionEntry->dph.dphHashTable);
3472 if (pStaDs != NULL) {
3473 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003474 pStaDs->bssId, false);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003475 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003476 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003477 pe_err("Self entry missing in Hash Table");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003478 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003479 }
3480#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003481 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003482#endif
3483
3484 /* send an sme response back */
3485end:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003486 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_SUCCESS, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003487 smesessionId, smetransactionId);
3488}
3489
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303490void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003491{
3492 /* fetch the sessionEntry based on the sessionId */
3493 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003494
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003495 psessionEntry = pe_find_session_by_session_id(pMac,
3496 pMac->lim.limTimers.gLimAddtsRspTimer.
3497 sessionId);
3498 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003499 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003500 return;
3501 }
3502
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003503 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003504 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003505 GET_LIM_SYSTEM_ROLE(psessionEntry));
3506 pMac->lim.gLimAddtsSent = false;
3507 return;
3508 }
3509
3510 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003511 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003512 return;
3513 }
3514
3515 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003516 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003517 pMac->lim.gLimAddtsRspTimerCount);
3518 return;
3519 }
3520 /* this a real response timeout */
3521 pMac->lim.gLimAddtsSent = false;
3522 pMac->lim.gLimAddtsRspTimerCount++;
3523
3524 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3525 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3526 psessionEntry->smeSessionId,
3527 psessionEntry->transactionId);
3528}
3529
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003530#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003531/**
3532 * __lim_process_sme_get_statistics_request()
3533 *
3534 ***FUNCTION:
3535 *
3536 *
3537 ***NOTE:
3538 *
3539 * @param pMac Pointer to Global MAC structure
3540 * @param *pMsgBuf A pointer to the SME message buffer
3541 * @return None
3542 */
3543static void
3544__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3545{
3546 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003547 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003548
3549 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3550
3551 msgQ.type = WMA_GET_STATISTICS_REQ;
3552
3553 msgQ.reserved = 0;
3554 msgQ.bodyptr = pMsgBuf;
3555 msgQ.bodyval = 0;
3556 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3557
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003558 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303559 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003560 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003561 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003562 return;
3563 }
3564
3565 return;
3566}
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003567#else
3568static void __lim_process_sme_get_statistics_request(
3569 struct sAniSirGlobal *mac_ctx, uint32_t *pMsgBuf) {}
3570#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003571
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003572#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003573/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003574 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003575 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003576 * @pMac: Pointer to Global MAC structure
3577 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003578 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003579 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003580 */
3581static void
3582__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3583{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003584 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003585
3586 msgQ.type = WMA_TSM_STATS_REQ;
3587 msgQ.reserved = 0;
3588 msgQ.bodyptr = pMsgBuf;
3589 msgQ.bodyval = 0;
3590 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3591
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003592 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303593 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003594 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003595 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003596 return;
3597 }
3598}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003599#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003600
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08003601static void lim_process_sme_set_addba_accept(tpAniSirGlobal mac_ctx,
3602 struct sme_addba_accept *msg)
3603{
3604 if (!msg) {
3605 pe_err("Msg Buffer is NULL");
3606 return;
3607 }
3608 if (!msg->addba_accept)
3609 mac_ctx->reject_addba_req = 1;
3610 else
3611 mac_ctx->reject_addba_req = 0;
3612}
3613
Arif Hussaineb8ba362018-03-07 19:15:13 -08003614static void lim_process_sme_update_edca_params(tpAniSirGlobal mac_ctx,
3615 uint32_t sme_session_id)
3616{
3617 tpPESession pe_session;
3618 tpDphHashNode sta_ds_ptr;
3619
3620 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3621 if (!pe_session) {
3622 pe_err("Session does not exist: sme_id %d", sme_session_id);
3623 return;
3624 }
3625 pe_session->gLimEdcaParamsActive[EDCA_AC_BE].no_ack =
3626 mac_ctx->no_ack_policy_cfg[EDCA_AC_BE];
3627 pe_session->gLimEdcaParamsActive[EDCA_AC_BK].no_ack =
3628 mac_ctx->no_ack_policy_cfg[EDCA_AC_BK];
3629 pe_session->gLimEdcaParamsActive[EDCA_AC_VI].no_ack =
3630 mac_ctx->no_ack_policy_cfg[EDCA_AC_VI];
3631 pe_session->gLimEdcaParamsActive[EDCA_AC_VO].no_ack =
3632 mac_ctx->no_ack_policy_cfg[EDCA_AC_VO];
3633 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3634 &pe_session->dph.dphHashTable);
3635 if (sta_ds_ptr)
3636 lim_send_edca_params(mac_ctx,
3637 pe_session->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003638 sta_ds_ptr->bssId, false);
Arif Hussaineb8ba362018-03-07 19:15:13 -08003639 else
3640 pe_err("Self entry missing in Hash Table");
3641}
3642
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07003643static void lim_process_sme_update_mu_edca_params(tpAniSirGlobal mac_ctx,
3644 uint32_t sme_session_id)
3645{
3646 tpPESession pe_session;
3647 tpDphHashNode sta_ds_ptr;
3648
3649 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3650 if (!pe_session) {
3651 pe_err("Session does not exist: sme_id %d", sme_session_id);
3652 return;
3653 }
3654 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3655 &pe_session->dph.dphHashTable);
3656 if (sta_ds_ptr)
3657 lim_send_edca_params(mac_ctx, mac_ctx->usr_mu_edca_params,
3658 sta_ds_ptr->bssId, true);
3659 else
3660 pe_err("Self entry missing in Hash Table");
3661}
3662
Naveen Rawat8029a402017-06-01 10:54:19 -07003663static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3664 struct update_config *msg)
3665{
3666 tpPESession pe_session;
3667
3668 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3669 if (msg == NULL) {
3670 pe_err("Buffer is Pointing to NULL");
3671 return;
3672 }
3673
3674 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3675 msg->sme_session_id);
3676 if (pe_session == NULL) {
3677 pe_warn("Session does not exist for given BSSID");
3678 return;
3679 }
3680
3681 switch (msg->capab) {
3682 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3683 pe_session->htConfig.ht_rx_ldpc = msg->value;
3684 break;
3685 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3686 pe_session->htConfig.ht_tx_stbc = msg->value;
3687 break;
3688 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3689 pe_session->htConfig.ht_rx_stbc = msg->value;
3690 break;
3691 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3692 pe_session->htConfig.ht_sgi20 = msg->value;
3693 break;
3694 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3695 pe_session->htConfig.ht_sgi40 = msg->value;
3696 break;
3697 }
3698
3699 if (LIM_IS_AP_ROLE(pe_session)) {
3700 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3701 lim_send_beacon_ind(mac_ctx, pe_session);
3702 }
3703}
3704
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003705void
3706lim_send_vdev_restart(tpAniSirGlobal pMac,
3707 tpPESession psessionEntry, uint8_t sessionId)
3708{
3709 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003710 struct scheduler_msg msgQ = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003711 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003712
3713 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003714 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003715 return;
3716 }
3717
3718 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303719 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003720 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003721 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003722 return;
3723 }
3724
3725 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3726 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003727 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003728
3729 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3730 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3731 msgQ.bodyval = 0;
3732
3733 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003734 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003735 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303736 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003737 }
3738}
3739
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303740/**
3741 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3742 * @mac_ctx: Pointer to Global MAC structure
3743 * @msg_buf: Pointer to SME message buffer
3744 *
3745 * Return: None
3746 */
3747static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3748 uint32_t *msg_buf)
3749{
3750 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003751 struct scheduler_msg wma_msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003752 QDF_STATUS status;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303753 tSirRoamOffloadScanReq *req_buffer;
3754 uint16_t local_ie_len;
3755 uint8_t *local_ie_buf;
3756
3757 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3758 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3759 req_buffer->sessionId);
3760
3761 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3762 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003763 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303764 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303765 return;
3766 }
3767
3768 local_ie_len = req_buffer->assoc_ie.length;
3769 /* Update ext cap IE if present */
3770 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003771 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3772 local_ie_buf, &local_ie_len)) {
3773 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003774 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3775 req_buffer->assoc_ie.length = local_ie_len;
3776 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3777 local_ie_buf, local_ie_len);
3778 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303779 }
3780 qdf_mem_free(local_ie_buf);
3781
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303782 if (pe_session)
3783 lim_update_fils_rik(pe_session, req_buffer);
3784
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303785 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3786 wma_msg.bodyptr = req_buffer;
3787
3788 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003789 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003790 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303791 qdf_mem_free(req_buffer);
3792 }
3793}
3794
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303795/*
3796 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3797 * @mac_ctx: Pointer to global mac context
3798 * @session: Pointer to PE session
3799 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3800 * 1 - Disable broadcast SSID
3801 *
3802 * Return: None
3803 */
3804static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3805 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003806{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003807 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003808 session->ssidHidden, ssid_hidden);
3809
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003810 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303811 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003812 } else {
3813 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05303814 return;
3815 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003816
3817 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303818 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003819
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003820 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303821}
3822
3823/**
3824 * __lim_process_sme_session_update - process SME session update msg
3825 *
3826 * @mac_ctx: Pointer to global mac context
3827 * @msg_buf: Pointer to the received message buffer
3828 *
3829 * Return: None
3830 */
3831static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
3832 uint32_t *msg_buf)
3833{
3834 struct sir_update_session_param *msg;
3835 tpPESession session;
3836
3837 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003838 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303839 return;
3840 }
3841
3842 msg = (struct sir_update_session_param *) msg_buf;
3843
3844 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
3845 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003846 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303847 msg->session_id);
3848 return;
3849 }
3850
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003851 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303852 msg->param_type, msg->param_val);
3853 switch (msg->param_type) {
3854 case SIR_PARAM_SSID_HIDDEN:
3855 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
3856 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303857 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
3858 session->ignore_assoc_disallowed = msg->param_val;
3859 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303860 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003861 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303862 break;
3863 }
3864}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003865
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003866/*
3867 Update the beacon Interval dynamically if beaconInterval is different in MCC
3868 */
3869static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3870{
3871 tpSirChangeBIParams pChangeBIParams;
3872 tpPESession psessionEntry;
3873 uint8_t sessionId = 0;
3874 tUpdateBeaconParams beaconParams;
3875
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003876 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003877
3878 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003879 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003880 return;
3881 }
3882
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303883 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003884 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
3885
3886 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08003887 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003888 &sessionId);
3889 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003890 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003891 return;
3892 }
3893
3894 /*Update sessionEntry Beacon Interval */
3895 if (psessionEntry->beaconParams.beaconInterval !=
3896 pChangeBIParams->beaconInterval) {
3897 psessionEntry->beaconParams.beaconInterval =
3898 pChangeBIParams->beaconInterval;
3899 }
3900
3901 /*Update sch beaconInterval */
3902 if (pMac->sch.schObject.gSchBeaconInterval !=
3903 pChangeBIParams->beaconInterval) {
3904 pMac->sch.schObject.gSchBeaconInterval =
3905 pChangeBIParams->beaconInterval;
3906
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003907 pe_debug("LIM send update BeaconInterval Indication: %d",
3908 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003909
3910 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
3911 /* Update beacon */
3912 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3913
3914 beaconParams.bssIdx = psessionEntry->bssIdx;
3915 /* Set change in beacon Interval */
3916 beaconParams.beaconInterval =
3917 pChangeBIParams->beaconInterval;
3918 beaconParams.paramChangeBitmap =
3919 PARAM_BCN_INTERVAL_CHANGED;
3920 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
3921 }
3922 }
3923
3924 return;
3925} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
3926
3927#ifdef QCA_HT_2040_COEX
3928static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
3929 uint32_t *pMsgBuf)
3930{
3931 tpSirSetHT2040Mode pSetHT2040Mode;
3932 tpPESession psessionEntry;
3933 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003934 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003935 tUpdateVHTOpMode *pHtOpMode = NULL;
3936 uint16_t staId = 0;
3937 tpDphHashNode pStaDs = NULL;
3938
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003939 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003940 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003941 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003942 return;
3943 }
3944
3945 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
3946
3947 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08003948 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003949 &sessionId);
3950 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003951 pe_debug("Session does not exist for given BSSID");
3952 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003953 return;
3954 }
3955
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003956 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003957 pSetHT2040Mode->cbMode);
3958 /*Update sessionEntry HT related fields */
3959 switch (pSetHT2040Mode->cbMode) {
3960 case PHY_SINGLE_CHANNEL_CENTERED:
3961 psessionEntry->htSecondaryChannelOffset =
3962 PHY_SINGLE_CHANNEL_CENTERED;
3963 psessionEntry->htRecommendedTxWidthSet = 0;
3964 if (pSetHT2040Mode->obssEnabled)
3965 psessionEntry->htSupportedChannelWidthSet
3966 = eHT_CHANNEL_WIDTH_40MHZ;
3967 else
3968 psessionEntry->htSupportedChannelWidthSet
3969 = eHT_CHANNEL_WIDTH_20MHZ;
3970 break;
3971 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
3972 psessionEntry->htSecondaryChannelOffset =
3973 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3974 psessionEntry->htRecommendedTxWidthSet = 1;
3975 break;
3976 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
3977 psessionEntry->htSecondaryChannelOffset =
3978 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3979 psessionEntry->htRecommendedTxWidthSet = 1;
3980 break;
3981 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003982 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003983 return;
3984 }
3985
3986 /* Update beacon */
3987 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3988 lim_send_beacon_ind(pMac, psessionEntry);
3989
3990 /* update OP Mode for each associated peer */
3991 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
3992 pStaDs = dph_get_hash_entry(pMac, staId,
3993 &psessionEntry->dph.dphHashTable);
3994 if (NULL == pStaDs)
3995 continue;
3996
3997 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303998 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003999 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004000 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004001 return;
4002 }
4003 pHtOpMode->opMode =
4004 (psessionEntry->htSecondaryChannelOffset ==
4005 PHY_SINGLE_CHANNEL_CENTERED) ?
4006 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4007 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304008 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004009 sizeof(tSirMacAddr));
4010 pHtOpMode->smesessionId = sessionId;
4011
4012 msg.type = WMA_UPDATE_OP_MODE;
4013 msg.reserved = 0;
4014 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004015 if (!QDF_IS_STATUS_SUCCESS
4016 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
4017 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304018 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004019 return;
4020 }
Jeff Johnson47d75242018-05-12 15:58:53 -07004021 pe_debug("Notified FW about OP mode: %d for staId=%d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004022 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004023
4024 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004025 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004026 }
4027
4028 return;
4029}
4030#endif
4031
4032/* -------------------------------------------------------------------- */
4033/**
4034 * __lim_process_report_message
4035 *
4036 * FUNCTION: Processes the next received Radio Resource Management message
4037 *
4038 * LOGIC:
4039 *
4040 * ASSUMPTIONS:
4041 *
4042 * NOTE:
4043 *
4044 * @param None
4045 * @return None
4046 */
4047
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004048static void __lim_process_report_message(tpAniSirGlobal pMac,
4049 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004050{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051 switch (pMsg->type) {
4052 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4053 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4054 break;
4055 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004056 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004057 break;
4058 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004059 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004060 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004061}
4062
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004063/* -------------------------------------------------------------------- */
4064/**
4065 * lim_send_set_max_tx_power_req
4066 *
4067 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4068 *
4069 * LOGIC:
4070 *
4071 * ASSUMPTIONS:
4072 *
4073 * NOTE:
4074 *
4075 * @param txPower txPower to be set.
4076 * @param pSessionEntry session entry.
4077 * @return None
4078 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004079QDF_STATUS
Amar Singhala297bfa2015-10-15 15:07:29 -07004080lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004081 tpPESession pSessionEntry)
4082{
4083 tpMaxTxPowerParams pMaxTxParams = NULL;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004084 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004085 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004086
4087 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004088 pe_err("Invalid parameters");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004089 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004090 }
4091
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304092 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004093 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004094 pe_err("Unable to allocate memory for pMaxTxParams");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004095 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004096
4097 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004098 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304099 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304100 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304101 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004102 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304103 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004104
4105 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4106 msgQ.bodyptr = pMaxTxParams;
4107 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004108 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004109 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4110 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004111 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004112 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304113 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004114 }
4115 return retCode;
4116}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004117
4118/**
4119 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4120 *
4121 * @mac_ctx: Pointer to Global MAC structure
4122 * @msg_buf: pointer to the SME message buffer
4123 *
4124 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4125 * from SME. It Register this information within PE.
4126 *
4127 * Return: None
4128 */
4129static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4130 uint32_t *msg_buf)
4131{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304132 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004133 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4134 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4135 struct mgmt_frm_reg_info *next = NULL;
4136 bool match = false;
4137
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004138 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004139 sme_req->registerFrame, sme_req->frameType,
4140 sme_req->matchLen);
4141 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304142 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304143 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4144 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304145 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004146
4147 while (lim_mgmt_regn != NULL) {
4148 if (lim_mgmt_regn->frameType != sme_req->frameType)
4149 goto skip_match;
4150 if (sme_req->matchLen) {
4151 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304152 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004153 sme_req->matchData,
4154 lim_mgmt_regn->matchLen))) {
4155 /* found match! */
4156 match = true;
4157 break;
4158 }
4159 } else {
4160 /* found match! */
4161 match = true;
4162 break;
4163 }
4164skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304165 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304166 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004167 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304168 (qdf_list_node_t *)lim_mgmt_regn,
4169 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304170 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004171 lim_mgmt_regn = next;
4172 next = NULL;
4173 }
4174 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304175 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004176 if (QDF_STATUS_SUCCESS ==
4177 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004178 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004179 (qdf_list_node_t *)lim_mgmt_regn))
4180 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304181 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004182 }
4183
4184 if (sme_req->registerFrame) {
4185 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304186 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004187 sme_req->matchLen);
4188 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004189 lim_mgmt_regn->frameType = sme_req->frameType;
4190 lim_mgmt_regn->matchLen = sme_req->matchLen;
4191 lim_mgmt_regn->sessionId = sme_req->sessionId;
4192 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304193 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004194 sme_req->matchData,
4195 sme_req->matchLen);
4196 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304197 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004198 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304199 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004200 gLimMgmtFrameRegistratinQueue,
4201 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304202 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004203 &mac_ctx->lim.lim_frame_register_lock);
4204 }
4205 }
4206 return;
4207}
4208
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004209static void
4210__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4211{
4212 tpSirResetAPCapsChange pResetCapsChange;
4213 tpPESession psessionEntry;
4214 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004215
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004216 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004217 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004218 return;
4219 }
4220
4221 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4222 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004223 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4224 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004225 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004226 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004227 return;
4228 }
4229
4230 psessionEntry->limSentCapsChangeNtf = false;
4231 return;
4232}
4233
4234/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304235 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4236 * indication callback in PE.
4237 * @mac_ptr: Mac pointer
4238 * @msg_buf: Msg pointer containing the callback
4239 *
4240 * This function is used save the Management frame
4241 * indication callback in PE.
4242 *
4243 * Return: None
4244 */
4245static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4246 uint32_t *msg_buf)
4247{
4248 struct sir_sme_mgmt_frame_cb_req *sme_req =
4249 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4250
4251 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004252 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304253 return;
4254 }
4255 if (sme_req->callback)
4256 mac_ctx->mgmt_frame_ind_cb =
4257 (sir_mgmt_frame_ind_callback)sme_req->callback;
4258 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004259 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304260}
4261
4262/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304263 *__lim_process_send_disassoc_frame: function processes disassoc frame
4264 * @mac_ctx: pointer to mac context
4265 * @msg_buf: message buffer
4266 *
4267 * function processes disassoc request received from SME
4268 *
4269 * return: none
4270 */
4271static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4272 uint32_t *msg_buf)
4273{
4274 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004275 QDF_STATUS status;
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304276 tpPESession session_entry = NULL;
4277 uint8_t sme_session_id;
4278 uint16_t sme_trans_id;
4279
4280 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004281 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304282 return;
4283 }
4284
4285 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4286 &sme_trans_id);
4287
4288 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4289 &sme_send_disassoc_frame_req,
4290 (uint8_t *)msg_buf);
4291
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004292 if ((QDF_STATUS_E_FAILURE == status) ||
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304293 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4294 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004295 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304296 return;
4297 }
4298
4299 session_entry = pe_find_session_by_sme_session_id(
4300 mac_ctx, sme_session_id);
4301 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004302 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304303 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4304 return;
4305 }
4306
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004307 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 +05304308 sme_send_disassoc_frame_req.msg_type,
4309 sme_send_disassoc_frame_req.length,
4310 sme_send_disassoc_frame_req.session_id,
4311 sme_send_disassoc_frame_req.trans_id,
4312 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4313 sme_send_disassoc_frame_req.reason,
4314 sme_send_disassoc_frame_req.wait_for_ack);
4315
4316 lim_send_disassoc_mgmt_frame(mac_ctx,
4317 sme_send_disassoc_frame_req.reason,
4318 sme_send_disassoc_frame_req.peer_mac,
4319 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4320}
4321
4322/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004323 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4324 * @mac_ctx: Pointer to Global MAC structure
4325 * @pdev_id: pdev id to set the IE.
4326 * @nss: Nss values to prepare the HT IE.
4327 *
4328 * Prepares the HT IE with self capabilities for different
4329 * Nss values and sends the set HT IE req to FW.
4330 *
4331 * Return: None
4332 */
4333static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4334 uint8_t nss)
4335{
4336 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004337 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004338 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004339 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004340 tHtCaps *p_ht_cap;
4341 int i;
4342
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004343 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004344 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4345 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004346 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004347 return;
4348 }
4349 ie_params->nss = i;
4350 ie_params->pdev_id = pdev_id;
4351 ie_params->ie_type = DOT11_HT_IE;
4352 /* 2 for IE len and EID */
4353 ie_params->ie_len = 2 + sizeof(tHtCaps);
4354 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4355 if (NULL == ie_params->ie_ptr) {
4356 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004357 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004358 return;
4359 }
4360 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4361 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4362 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4363 ie_params->ie_len);
4364
4365 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004366 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4367 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004368 if (NULL == p_ie) {
4369 qdf_mem_free(ie_params->ie_ptr);
4370 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004371 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004372 return;
4373 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004374 p_ht_cap = (tHtCaps *)&p_ie[2];
4375 p_ht_cap->supportedMCSSet[1] = 0;
4376 p_ht_cap->txSTBC = 0;
4377 }
4378
4379 msg.type = WMA_SET_PDEV_IE_REQ;
4380 msg.bodyptr = ie_params;
4381 msg.bodyval = 0;
4382
4383 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004384 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004385 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004386 qdf_mem_free(ie_params->ie_ptr);
4387 qdf_mem_free(ie_params);
4388 return;
4389 }
4390 }
4391}
4392
4393/**
4394 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4395 * @mac_ctx: Pointer to Global MAC structure
4396 * @pdev_id: pdev id to set the IE.
4397 * @nss: Nss values to prepare the VHT IE.
4398 *
4399 * Prepares the VHT IE with self capabilities for different
4400 * Nss values and sends the set VHT IE req to FW.
4401 *
4402 * Return: None
4403 */
4404static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4405 uint8_t nss)
4406{
4407 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004408 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004409 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004410 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004411 tSirMacVHTCapabilityInfo *vht_cap;
4412 int i;
4413 tSirVhtMcsInfo *vht_mcs;
4414
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004415 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004416 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4417 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004418 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004419 return;
4420 }
4421 ie_params->nss = i;
4422 ie_params->pdev_id = pdev_id;
4423 ie_params->ie_type = DOT11_VHT_IE;
4424 /* 2 for IE len and EID */
4425 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4426 sizeof(tSirVhtMcsInfo);
4427 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4428 if (NULL == ie_params->ie_ptr) {
4429 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004430 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004431 return;
4432 }
4433 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4434 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4435 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4436 ie_params->ie_len);
4437
4438 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004439 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4440 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004441 if (NULL == p_ie) {
4442 qdf_mem_free(ie_params->ie_ptr);
4443 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004444 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004445 return;
4446 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004447 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4448 vht_cap->txSTBC = 0;
4449 vht_mcs =
4450 (tSirVhtMcsInfo *)&p_ie[2 +
4451 sizeof(tSirMacVHTCapabilityInfo)];
4452 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4453 vht_mcs->rxHighest =
4454 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4455 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4456 vht_mcs->txHighest =
4457 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4458 }
4459 msg.type = WMA_SET_PDEV_IE_REQ;
4460 msg.bodyptr = ie_params;
4461 msg.bodyval = 0;
4462
4463 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004464 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004465 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004466 qdf_mem_free(ie_params->ie_ptr);
4467 qdf_mem_free(ie_params);
4468 return;
4469 }
4470 }
4471}
4472
4473/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004474 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4475 * @mac_ctx: Pointer to Global MAC structure
4476 * @msg_buf: Pointer to the SME message buffer
4477 *
4478 * This function is called by limProcessMessageQueue(). This function sets the
4479 * VDEV IEs to the FW.
4480 *
4481 * Return: None
4482 */
4483static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4484 uint32_t *msg_buf)
4485{
4486 struct sir_set_vdev_ies_per_band *p_msg =
4487 (struct sir_set_vdev_ies_per_band *)msg_buf;
4488
4489 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004490 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004491 return;
4492 }
4493
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004494 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004495 p_msg->vdev_id);
4496 /* intentionally using NULL here so that self capabilty are sent */
4497 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4498 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004499 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004500}
4501
4502/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004503 * lim_process_set_pdev_IEs() - process the set pdev IE req
4504 * @mac_ctx: Pointer to Global MAC structure
4505 * @msg_buf: Pointer to the SME message buffer
4506 *
4507 * This function is called by limProcessMessageQueue(). This
4508 * function sets the PDEV IEs to the FW.
4509 *
4510 * Return: None
4511 */
4512static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4513{
4514 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4515
4516 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4517
4518 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004519 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004520 return;
4521 }
4522
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004523 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004524 ht_vht_cfg->nss);
4525 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4526
4527 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4528 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4529 ht_vht_cfg->nss);
4530}
4531
4532/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304533 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4534 *
4535 * access policy
4536 * @mac_ctx: pointer to mac context
4537 * @msg: message buffer
4538 *
4539 * function processes vendor IE and access policy from SME and updates PE
4540 *
4541 * session entry
4542 *
4543 * return: none
4544*/
4545static void lim_process_sme_update_access_policy_vendor_ie(
4546 tpAniSirGlobal mac_ctx,
4547 uint32_t *msg)
4548{
4549 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4550 struct sPESession *pe_session_entry;
Pragaspathi Thilagaraj9b7a1162018-05-07 16:28:13 +05304551 uint16_t num_bytes;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304552
4553 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004554 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304555 return;
4556 }
4557 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4558 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4559 update_vendor_ie->sme_session_id);
4560
4561 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004562 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304563 update_vendor_ie->sme_session_id);
4564 return;
4565 }
4566 if (pe_session_entry->access_policy_vendor_ie)
4567 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4568
4569 num_bytes = update_vendor_ie->ie[1] + 2;
4570 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4571
4572 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004573 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304574 return;
4575 }
4576 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4577 &update_vendor_ie->ie[0], num_bytes);
4578
4579 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4580}
4581
4582/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004583 * lim_process_sme_req_messages()
4584 *
4585 ***FUNCTION:
4586 * This function is called by limProcessMessageQueue(). This
4587 * function processes SME request messages from HDD or upper layer
4588 * application.
4589 *
4590 ***LOGIC:
4591 *
4592 ***ASSUMPTIONS:
4593 *
4594 ***NOTE:
4595 *
4596 * @param pMac Pointer to Global MAC structure
4597 * @param msgType Indicates the SME message type
4598 * @param *pMsgBuf A pointer to the SME message buffer
4599 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4600 * false - if pMsgBuf is not to be freed.
4601 */
4602
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004603bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4604 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004605{
Jeff Johnson33142e62018-05-06 17:58:36 -07004606 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 -08004607 uint32_t *pMsgBuf = pMsg->bodyptr;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004608
4609 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004610 lim_msg_str(pMsg->type), pMsg->type,
4611 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4612 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004613
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004614 /* If no insert NOA required then execute the code below */
4615
4616 switch (pMsg->type) {
4617 case eWNI_SME_SYS_READY_IND:
4618 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4619 break;
4620
4621 case eWNI_SME_START_BSS_REQ:
4622 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4623 break;
4624
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004625 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4626 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4627 break;
4628 case eWNI_SME_JOIN_REQ:
4629 __lim_process_sme_join_req(pMac, pMsgBuf);
4630 break;
4631
4632 case eWNI_SME_REASSOC_REQ:
4633 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4634 break;
4635
4636 case eWNI_SME_DISASSOC_REQ:
4637 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4638 break;
4639
4640 case eWNI_SME_DISASSOC_CNF:
4641 case eWNI_SME_DEAUTH_CNF:
4642 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4643 break;
4644
4645 case eWNI_SME_DEAUTH_REQ:
4646 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4647 break;
4648
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304649 case eWNI_SME_SEND_DISASSOC_FRAME:
4650 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4651 break;
4652
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004653 case eWNI_SME_SETCONTEXT_REQ:
4654 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4655 break;
4656
4657 case eWNI_SME_STOP_BSS_REQ:
4658 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4659 break;
4660
4661 case eWNI_SME_ASSOC_CNF:
4662 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004663 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004664 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4665 pMsgBuf);
4666 break;
4667
4668 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004669 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004670 __lim_process_sme_addts_req(pMac, pMsgBuf);
4671 break;
4672
4673 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004674 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004675 __lim_process_sme_delts_req(pMac, pMsgBuf);
4676 break;
4677
4678 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004679 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004680 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4681 break;
4682
4683 case eWNI_SME_GET_STATISTICS_REQ:
4684 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4685 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4686 bufConsumed = false;
4687 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004688#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004689 case eWNI_SME_GET_TSM_STATS_REQ:
4690 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4691 bufConsumed = false;
4692 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004693#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004694 case eWNI_SME_GET_ASSOC_STAS_REQ:
4695 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4696 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304697 case eWNI_SME_SESSION_UPDATE_PARAM:
4698 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004699 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304700 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4701 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4702 bufConsumed = false;
4703 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004704 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4705 /* Update the beaconInterval */
4706 __lim_process_sme_change_bi(pMac, pMsgBuf);
4707 break;
4708
4709#ifdef QCA_HT_2040_COEX
4710 case eWNI_SME_SET_HT_2040_MODE:
4711 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4712 break;
4713#endif
4714
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004715 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4716 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4717 __lim_process_report_message(pMac, pMsg);
4718 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004719
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004720 case eWNI_SME_FT_PRE_AUTH_REQ:
4721 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4722 break;
4723 case eWNI_SME_FT_UPDATE_KEY:
4724 lim_process_ft_update_key(pMac, pMsgBuf);
4725 break;
4726
4727 case eWNI_SME_FT_AGGR_QOS_REQ:
4728 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4729 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004730
4731 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4732 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4733 break;
4734#ifdef FEATURE_WLAN_TDLS
4735 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4736 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4737 break;
4738 case eWNI_SME_TDLS_ADD_STA_REQ:
4739 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4740 break;
4741 case eWNI_SME_TDLS_DEL_STA_REQ:
4742 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4743 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004744#endif
4745 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4746 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4747 break;
4748
4749 case eWNI_SME_CHANNEL_CHANGE_REQ:
4750 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4751 break;
4752
4753 case eWNI_SME_START_BEACON_REQ:
4754 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4755 break;
4756
4757 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4758 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4759 break;
4760
4761 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4762 lim_process_update_add_ies(pMac, pMsgBuf);
4763 break;
4764
4765 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4766 lim_process_modify_add_ies(pMac, pMsgBuf);
4767 break;
4768 case eWNI_SME_SET_HW_MODE_REQ:
4769 lim_process_set_hw_mode(pMac, pMsgBuf);
4770 break;
4771 case eWNI_SME_NSS_UPDATE_REQ:
4772 lim_process_nss_update_request(pMac, pMsgBuf);
4773 break;
4774 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4775 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4776 break;
4777 case eWNI_SME_SET_IE_REQ:
4778 lim_process_set_ie_req(pMac, pMsgBuf);
4779 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304780 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4781 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
4782 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304783 case eWNI_SME_EXT_CHANGE_CHANNEL:
4784 lim_process_ext_change_channel(pMac, pMsgBuf);
4785 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08004786 case eWNI_SME_SET_ANTENNA_MODE_REQ:
4787 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
4788 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004789 case eWNI_SME_PDEV_SET_HT_VHT_IE:
4790 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07004791 break;
4792 case eWNI_SME_SET_VDEV_IES_PER_BAND:
4793 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
4794 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304795 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
4796 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
4797 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07004798 case eWNI_SME_UPDATE_CONFIG:
4799 lim_process_sme_update_config(pMac,
4800 (struct update_config *)pMsgBuf);
4801 break;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004802 case eWNI_SME_SET_ADDBA_ACCEPT:
4803 lim_process_sme_set_addba_accept(pMac,
4804 (struct sme_addba_accept *)pMsgBuf);
4805 break;
Arif Hussaineb8ba362018-03-07 19:15:13 -08004806 case eWNI_SME_UPDATE_EDCA_PROFILE:
4807 lim_process_sme_update_edca_params(pMac, pMsg->bodyval);
4808 break;
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07004809 case WNI_SME_UPDATE_MU_EDCA_PARAMS:
4810 lim_process_sme_update_mu_edca_params(pMac, pMsg->bodyval);
4811 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004812 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304813 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004814 pMsg->bodyptr = NULL;
4815 break;
4816 } /* switch (msgType) */
4817
4818 return bufConsumed;
4819} /*** end lim_process_sme_req_messages() ***/
4820
4821/**
4822 * lim_process_sme_start_beacon_req()
4823 *
4824 ***FUNCTION:
4825 * This function is called by limProcessMessageQueue(). This
4826 * function processes SME request messages from HDD or upper layer
4827 * application.
4828 *
4829 ***LOGIC:
4830 *
4831 ***ASSUMPTIONS:
4832 *
4833 ***NOTE:
4834 *
4835 * @param pMac Pointer to Global MAC structure
4836 * @param msgType Indicates the SME message type
4837 * @param *pMsgBuf A pointer to the SME message buffer
4838 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4839 * false - if pMsgBuf is not to be freed.
4840 */
4841static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
4842{
4843 tpSirStartBeaconIndication pBeaconStartInd;
4844 tpPESession psessionEntry;
4845 uint8_t sessionId; /* PE sessionID */
4846
4847 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004848 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004849 return;
4850 }
4851
4852 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
4853 psessionEntry = pe_find_session_by_bssid(pMac,
4854 pBeaconStartInd->bssid,
4855 &sessionId);
4856 if (psessionEntry == NULL) {
4857 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004858 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004859 return;
4860 }
4861
4862 if (pBeaconStartInd->beaconStartStatus == true) {
4863 /*
4864 * Currently this Indication comes from SAP
4865 * to start Beacon Tx on a DFS channel
4866 * since beaconing has to be done on DFS
4867 * channel only after CAC WAIT is completed.
4868 * On a DFS Channel LIM does not start beacon
4869 * Tx right after the WMA_ADD_BSS_RSP.
4870 */
4871 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05304872 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004873 FL("Start Beacon with ssid %s Ch %d"),
4874 psessionEntry->ssId.ssId,
4875 psessionEntry->currentOperChannel);
4876 lim_send_beacon_ind(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08004877 lim_enable_obss_detection_config(pMac, psessionEntry);
Arif Hussain05fb4872018-01-03 16:02:55 -08004878 lim_send_obss_color_collision_cfg(pMac, psessionEntry,
4879 OBSS_COLOR_COLLISION_DETECTION);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004880 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004881 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004882 return;
4883 }
4884}
4885
4886/**
4887 * lim_process_sme_channel_change_request() - process sme ch change req
4888 *
4889 * @mac_ctx: Pointer to Global MAC structure
4890 * @msg_buf: pointer to the SME message buffer
4891 *
4892 * This function is called to process SME_CHANNEL_CHANGE_REQ message
4893 *
4894 * Return: None
4895 */
4896static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
4897 uint32_t *msg_buf)
4898{
4899 tpSirChanChangeRequest ch_change_req;
4900 tpPESession session_entry;
4901 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07004902 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004903 uint32_t val = 0;
4904
4905 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004906 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004907 return;
4908 }
4909 ch_change_req = (tpSirChanChangeRequest)msg_buf;
4910
4911 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
4912 ch_change_req->targetChannel);
4913
4914 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
4915 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004916 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004917 return;
4918 }
4919
4920 session_entry = pe_find_session_by_bssid(mac_ctx,
4921 ch_change_req->bssid, &session_id);
4922 if (session_entry == NULL) {
4923 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004924 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004925 return;
4926 }
4927
Manjunathappa Prakash34fda792018-02-07 18:23:42 -08004928 if ((session_entry->currentOperChannel ==
4929 ch_change_req->targetChannel) &&
4930 (session_entry->ch_width == ch_change_req->ch_width)) {
4931 pe_err("Target channel and mode is same as current channel and mode channel %d and mode %d",
4932 session_entry->currentOperChannel, session_entry->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004933 return;
4934 }
4935
4936 if (LIM_IS_AP_ROLE(session_entry))
4937 session_entry->channelChangeReasonCode =
4938 LIM_SWITCH_CHANNEL_SAP_DFS;
4939 else
4940 session_entry->channelChangeReasonCode =
4941 LIM_SWITCH_CHANNEL_OPERATION;
4942
Bala Venkateshb39ed152017-12-26 19:35:27 +05304943 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d, nw_type %d, dot11mode %d",
4944 session_entry->currentOperChannel,
4945 ch_change_req->targetChannel,
4946 ch_change_req->ch_width,
4947 ch_change_req->nw_type,
4948 ch_change_req->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004949
4950 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004951 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004952 session_entry->ch_center_freq_seg0 =
4953 ch_change_req->center_freq_seg_0;
4954 session_entry->ch_center_freq_seg1 =
4955 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004956 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004957 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004958 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004959 session_entry->htRecommendedTxWidthSet =
4960 session_entry->htSupportedChannelWidthSet;
4961 session_entry->currentOperChannel =
4962 ch_change_req->targetChannel;
4963 session_entry->limRFBand =
4964 lim_get_rf_band(session_entry->currentOperChannel);
Vignesh Viswanathan153ae932018-04-11 14:24:13 +05304965
4966 /* Update the global beacon filter */
4967 lim_update_bcn_probe_filter(mac_ctx, session_entry);
4968
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004969 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08004970 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004971 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004972 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004973 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004974 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004975 }
4976
4977 session_entry->lim11hEnable = val;
4978 session_entry->dot11mode = ch_change_req->dot11mode;
Bala Venkateshb39ed152017-12-26 19:35:27 +05304979 session_entry->nwType = ch_change_req->nw_type;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304980 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004981 &ch_change_req->operational_rateset,
4982 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304983 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004984 &ch_change_req->extended_rateset,
4985 sizeof(session_entry->extRateSet));
4986 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
4987 session_entry->ch_center_freq_seg0,
4988 session_entry->ch_center_freq_seg1,
4989 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07004990 max_tx_pwr, session_entry->peSessionId,
4991 ch_change_req->cac_duration_ms,
4992 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004993}
4994
4995/******************************************************************************
4996* lim_start_bss_update_add_ie_buffer()
4997*
4998***FUNCTION:
4999* This function checks the src buffer and its length and then malloc for
5000* dst buffer update the same
5001*
5002***LOGIC:
5003*
5004***ASSUMPTIONS:
5005*
5006***NOTE:
5007*
5008* @param pMac Pointer to Global MAC structure
5009* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5010* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5011* @param *pSrcData_buff A pointer of uint8_t src buffer
5012* @param srcDataLen src buffer length
5013******************************************************************************/
5014
5015static void
5016lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5017 uint8_t **pDstData_buff,
5018 uint16_t *pDstDataLen,
5019 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5020{
5021
5022 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5023 *pDstDataLen = srcDataLen;
5024
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305025 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005026
5027 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005028 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005029 return;
5030 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305031 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005032 } else {
5033 *pDstData_buff = NULL;
5034 *pDstDataLen = 0;
5035 }
5036}
5037
5038/******************************************************************************
5039* lim_update_add_ie_buffer()
5040*
5041***FUNCTION:
5042* This function checks the src buffer and length if src buffer length more
5043* than dst buffer length then free the dst buffer and malloc for the new src
5044* length, and update the dst buffer and length. But if dst buffer is bigger
5045* than src buffer length then it just update the dst buffer and length
5046*
5047***LOGIC:
5048*
5049***ASSUMPTIONS:
5050*
5051***NOTE:
5052*
5053* @param pMac Pointer to Global MAC structure
5054* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5055* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5056* @param *pSrcData_buff A pointer of uint8_t src buffer
5057* @param srcDataLen src buffer length
5058******************************************************************************/
5059
5060static void
5061lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5062 uint8_t **pDstData_buff,
5063 uint16_t *pDstDataLen,
5064 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5065{
5066
5067 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005068 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005069 return;
5070 }
5071
5072 if (srcDataLen > *pDstDataLen) {
5073 *pDstDataLen = srcDataLen;
5074 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305075 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005076 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305077 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005078
5079 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005080 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005081 *pDstDataLen = 0;
5082 return;
5083 }
5084 }
5085
5086 /* copy the content of buffer into dst buffer
5087 */
5088 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305089 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005090
5091}
5092
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005093/**
5094 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5095 * @pMac : Pointer to Global MAC structure
5096 * @pDstData_buff : A pointer to pointer of dst buffer
5097 * @pDstDataLen : A pointer to pointer of dst buffer length
5098 * @pModifyIE : A pointer to tSirModifyIE
5099 *
5100 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5101 *
5102 * Return:
5103 * True or false depending upon whether IE is updated or not
5104 */
5105static bool
5106lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5107 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5108{
Hong Shi1553d692016-09-28 12:16:19 +08005109 int32_t oui_length;
5110 uint8_t *ibss_ie = NULL;
5111 uint8_t *vendor_ie;
5112#define MAC_VENDOR_OUI "\x00\x16\x32"
5113#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005114
5115 ibss_ie = pModifyIE->pIEBuffer;
5116 oui_length = pModifyIE->oui_length;
5117
5118 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005119 pe_err("Invalid set IBSS vendor IE command length %d",
5120 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005121 return false;
5122 }
5123
Hong Shi1553d692016-09-28 12:16:19 +08005124 /*
5125 * Why replace only beacon OUI data here:
5126 * 1. other ie (such as wpa) shall not be overwritten here.
5127 * 2. per spec, beacon oui ie might be set twice and original one
5128 * shall be updated.
5129 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005130 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005131 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5132 if (vendor_ie) {
5133 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5134 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5135 pModifyIE->ieBufferlength);
5136 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005137 uint16_t new_length;
5138 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005139
Naveen Rawat668dee32017-09-29 14:39:40 -07005140 /*
5141 * check for uint16 overflow before using sum of two numbers as
5142 * length of size to malloc
5143 */
5144 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5145 pe_err("U16 overflow due to %d + %d",
5146 pModifyIE->ieBufferlength, *pDstDataLen);
5147 return false;
5148 }
5149
5150 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5151 new_ptr = qdf_mem_malloc(new_length);
Hong Shi1553d692016-09-28 12:16:19 +08005152 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005153 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005154 return false;
5155 }
5156 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5157 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5158 pModifyIE->ieBufferlength);
5159 qdf_mem_free(*pDstData_buff);
5160 *pDstDataLen = new_length;
5161 *pDstData_buff = new_ptr;
5162 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005163 return true;
5164}
5165
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005166/*
5167* lim_process_modify_add_ies() - process modify additional IE req.
5168*
5169* @mac_ctx: Pointer to Global MAC structure
5170* @msg_buf: pointer to the SME message buffer
5171*
5172* This function update the PE buffers for additional IEs.
5173*
5174* Return: None
5175*/
5176static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5177 uint32_t *msg_buf)
5178{
5179 tpSirModifyIEsInd modify_add_ies;
5180 tpPESession session_entry;
5181 uint8_t session_id;
5182 bool ret = false;
5183 tSirAddIeParams *add_ie_params;
5184
5185 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005186 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005187 return;
5188 }
5189
5190 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5191 /* Incoming message has smeSession, use BSSID to find PE session */
5192 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005193 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005194
5195 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005196 pe_err("Session not found for given bssid"
5197 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005198 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005199 goto end;
5200 }
5201 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5202 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5203 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005204 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005205 modify_add_ies->modifyIE.pIEBuffer,
5206 modify_add_ies->modifyIE.ieBufferlength,
5207 modify_add_ies->modifyIE.ieID,
5208 modify_add_ies->modifyIE.ieIDLen,
5209 modify_add_ies->updateType);
5210 goto end;
5211 }
5212 add_ie_params = &session_entry->addIeParams;
5213 switch (modify_add_ies->updateType) {
5214 case eUPDATE_IE_PROBE_RESP:
5215 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005216 if (LIM_IS_IBSS_ROLE(session_entry)) {
5217 lim_update_ibss_prop_add_ies(mac_ctx,
5218 &add_ie_params->probeRespData_buff,
5219 &add_ie_params->probeRespDataLen,
5220 &modify_add_ies->modifyIE);
5221 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005222 break;
5223 case eUPDATE_IE_ASSOC_RESP:
5224 /* assoc resp IE */
5225 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305226 QDF_TRACE(QDF_MODULE_ID_PE,
5227 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005228 "assoc resp add ie not present %d"),
5229 add_ie_params->assocRespDataLen);
5230 }
5231 /* search through the buffer and modify the IE */
5232 break;
5233 case eUPDATE_IE_PROBE_BCN:
5234 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005235 if (LIM_IS_IBSS_ROLE(session_entry)) {
5236 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5237 &add_ie_params->probeRespBCNData_buff,
5238 &add_ie_params->probeRespBCNDataLen,
5239 &modify_add_ies->modifyIE);
5240 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005241 if (ret == true && modify_add_ies->modifyIE.notify) {
5242 lim_handle_param_update(mac_ctx,
5243 modify_add_ies->updateType);
5244 }
5245 break;
5246 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005247 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005248 modify_add_ies->updateType);
5249 break;
5250 }
5251end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305252 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005253 modify_add_ies->modifyIE.pIEBuffer = NULL;
5254}
5255
5256/*
5257* lim_process_update_add_ies() - process additional IE update req
5258*
5259* @mac_ctx: Pointer to Global MAC structure
5260* @msg_buf: pointer to the SME message buffer
5261*
5262* This function update the PE buffers for additional IEs.
5263*
5264* Return: None
5265*/
5266static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5267 uint32_t *msg_buf)
5268{
5269 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5270 uint8_t session_id;
5271 tpPESession session_entry;
5272 tSirAddIeParams *addn_ie;
5273 uint16_t new_length = 0;
5274 uint8_t *new_ptr = NULL;
5275 tSirUpdateIE *update_ie;
5276
5277 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005278 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005279 return;
5280 }
5281 update_ie = &update_add_ies->updateIE;
5282 /* incoming message has smeSession, use BSSID to find PE session */
5283 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005284 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005285
5286 if (NULL == session_entry) {
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05305287 pe_debug("Session not found for given bssid"
5288 MAC_ADDRESS_STR,
5289 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005290 goto end;
5291 }
5292 addn_ie = &session_entry->addIeParams;
5293 /* if len is 0, upper layer requested freeing of buffer */
5294 if (0 == update_ie->ieBufferlength) {
5295 switch (update_add_ies->updateType) {
5296 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305297 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005298 addn_ie->probeRespData_buff = NULL;
5299 addn_ie->probeRespDataLen = 0;
5300 break;
5301 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305302 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005303 addn_ie->assocRespData_buff = NULL;
5304 addn_ie->assocRespDataLen = 0;
5305 break;
5306 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305307 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005308 addn_ie->probeRespBCNData_buff = NULL;
5309 addn_ie->probeRespBCNDataLen = 0;
5310
5311 if (update_ie->notify)
5312 lim_handle_param_update(mac_ctx,
5313 update_add_ies->updateType);
5314 break;
5315 default:
5316 break;
5317 }
5318 return;
5319 }
5320 switch (update_add_ies->updateType) {
5321 case eUPDATE_IE_PROBE_RESP:
5322 if (update_ie->append) {
5323 /*
5324 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005325 * with combined length.
5326 * Multiple back to back append commands
5327 * can lead to a huge length.So, check
5328 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005329 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005330 if (addn_ie->probeRespDataLen >
5331 (USHRT_MAX - update_ie->ieBufferlength)) {
5332 pe_err("IE Length overflow, curr:%d, new:%d",
5333 addn_ie->probeRespDataLen,
5334 update_ie->ieBufferlength);
5335 goto end;
5336 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005337 new_length = update_ie->ieBufferlength +
5338 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305339 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005340 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005341 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005342 goto end;
5343 }
5344 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305345 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005346 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305347 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005348 update_ie->pAdditionIEBuffer,
5349 update_ie->ieBufferlength);
5350 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305351 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005352 /* adjust length accordingly */
5353 addn_ie->probeRespDataLen = new_length;
5354 /* save refernece of local buffer in PE session */
5355 addn_ie->probeRespData_buff = new_ptr;
5356 goto end;
5357 }
5358 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5359 &addn_ie->probeRespDataLen,
5360 update_ie->pAdditionIEBuffer,
5361 update_ie->ieBufferlength);
5362 break;
5363 case eUPDATE_IE_ASSOC_RESP:
5364 /* assoc resp IE */
5365 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5366 &addn_ie->assocRespDataLen,
5367 update_ie->pAdditionIEBuffer,
5368 update_ie->ieBufferlength);
5369 break;
5370 case eUPDATE_IE_PROBE_BCN:
5371 /* probe resp Bcn IE */
5372 lim_update_add_ie_buffer(mac_ctx,
5373 &addn_ie->probeRespBCNData_buff,
5374 &addn_ie->probeRespBCNDataLen,
5375 update_ie->pAdditionIEBuffer,
5376 update_ie->ieBufferlength);
5377 if (update_ie->notify)
5378 lim_handle_param_update(mac_ctx,
5379 update_add_ies->updateType);
5380 break;
5381 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005382 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005383 break;
5384 }
5385end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305386 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005387 update_ie->pAdditionIEBuffer = NULL;
5388}
5389
5390/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305391 * send_extended_chan_switch_action_frame()- function to send ECSA
5392 * action frame for each sta connected to SAP/GO and AP in case of
5393 * STA .
5394 * @mac_ctx: pointer to global mac structure
5395 * @new_channel: new channel to switch to.
5396 * @ch_bandwidth: BW of channel to calculate op_class
5397 * @session_entry: pe session
5398 *
5399 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5400 *
5401 * Return: void
5402 */
5403
5404static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5405 uint16_t new_channel, uint8_t ch_bandwidth,
5406 tpPESession session_entry)
5407{
5408 uint16_t op_class;
5409 uint8_t switch_mode = 0, i;
5410 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005411 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305412
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005413 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305414 mac_ctx->scan.countryCodeCurrent,
5415 new_channel,
5416 ch_bandwidth);
5417
5418 if (LIM_IS_AP_ROLE(session_entry) &&
5419 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005420 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305421
gaoleze2920bd2017-03-21 17:38:42 +08005422 switch_count = session_entry->gLimChannelSwitch.switchCount;
5423
Abhishek Singh518323d2015-10-19 17:42:01 +05305424 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005425 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305426 psta =
5427 session_entry->dph.dphHashTable.pDphNodeArray + i;
5428 if (psta && psta->added)
5429 lim_send_extended_chan_switch_action_frame(
5430 mac_ctx,
5431 psta->staAddr,
5432 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005433 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305434 }
5435 } else if (LIM_IS_STA_ROLE(session_entry)) {
5436 lim_send_extended_chan_switch_action_frame(mac_ctx,
5437 session_entry->bssId,
5438 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005439 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305440 }
5441
5442}
5443
gaolez76d2a162017-03-21 19:23:58 +08005444void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5445 uint16_t new_channel,
5446 uint8_t ch_bandwidth,
5447 tpPESession session_entry)
5448{
5449 uint16_t op_class;
5450 uint8_t switch_mode = 0, i;
5451 uint8_t switch_count;
5452 tpDphHashNode psta;
5453 tpDphHashNode dph_node_array_ptr;
5454
5455 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5456
5457 op_class = wlan_reg_dmn_get_opclass_from_channel(
5458 mac_ctx->scan.countryCodeCurrent,
5459 new_channel, ch_bandwidth);
5460
5461 if (LIM_IS_AP_ROLE(session_entry) &&
5462 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5463 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5464
5465 switch_count = session_entry->gLimChannelSwitch.switchCount;
5466
5467 if (LIM_IS_AP_ROLE(session_entry)) {
5468 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5469 psta = dph_node_array_ptr + i;
5470 if (!(psta && psta->added))
5471 continue;
5472 if (session_entry->lim_non_ecsa_cap_num == 0)
5473 lim_send_extended_chan_switch_action_frame
5474 (mac_ctx, psta->staAddr, switch_mode,
5475 op_class, new_channel, switch_count,
5476 session_entry);
5477 else
5478 lim_send_channel_switch_mgmt_frame
5479 (mac_ctx, psta->staAddr, switch_mode,
5480 new_channel, switch_count,
5481 session_entry);
5482 }
5483 } else if (LIM_IS_STA_ROLE(session_entry)) {
5484 lim_send_extended_chan_switch_action_frame
5485 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5486 new_channel, switch_count, session_entry);
5487 }
5488}
5489
5490/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005491 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5492 *
5493 * @mac_ctx: Pointer to Global MAC structure
5494 * @msg_buf: pointer to the SME message buffer
5495 *
5496 * This function processes SME request messages from HDD or upper layer
5497 * application.
5498 *
5499 * Return: None
5500 */
5501static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5502 uint32_t *msg_buf)
5503{
5504 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5505 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005506 uint8_t session_id;
5507 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005508 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005509
5510 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005511 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005512 return;
5513 }
5514
5515 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5516 session_entry = pe_find_session_by_bssid(mac_ctx,
5517 dfs_csa_ie_req->bssid, &session_id);
5518 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005519 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005520 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5521 return;
5522 }
5523
5524 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005525 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005526 GET_LIM_SYSTEM_ROLE(session_entry));
5527 return;
5528 }
5529
5530 /* target channel */
5531 session_entry->gLimChannelSwitch.primaryChannel =
5532 dfs_csa_ie_req->targetChannel;
5533
5534 /* Channel switch announcement needs to be included in beacon */
5535 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005536 session_entry->gLimChannelSwitch.switchCount =
5537 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005538 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005539 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305540 session_entry->gLimChannelSwitch.sec_ch_offset =
5541 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005542 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005543 session_entry->gLimChannelSwitch.switchMode =
5544 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005545
5546 /*
5547 * Validate if SAP is operating HT or VHT mode and set the Channel
5548 * Switch Wrapper element with the Wide Band Switch subelement.
5549 */
5550 if (true != session_entry->vhtCapability)
5551 goto skip_vht;
5552
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005553 /* Now encode the Wider Ch BW element depending on the ch width */
5554 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005555 switch (dfs_csa_ie_req->ch_params.ch_width) {
5556 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005557 /*
5558 * Wide channel BW sublement in channel wrapper element is not
5559 * required in case of 20 Mhz operation. Currently It is set
5560 * only set in case of 40/80 Mhz Operation.
5561 */
5562 session_entry->dfsIncludeChanWrapperIe = false;
5563 wider_bw_ch_switch->newChanWidth =
5564 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5565 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005566 case CH_WIDTH_40MHZ:
5567 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005568 wider_bw_ch_switch->newChanWidth =
5569 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5570 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005571 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005572 session_entry->dfsIncludeChanWrapperIe = true;
5573 wider_bw_ch_switch->newChanWidth =
5574 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5575 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005576 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005577 session_entry->dfsIncludeChanWrapperIe = true;
5578 wider_bw_ch_switch->newChanWidth =
5579 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5580 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005581 case CH_WIDTH_80P80MHZ:
5582 session_entry->dfsIncludeChanWrapperIe = true;
5583 wider_bw_ch_switch->newChanWidth =
5584 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005585 /*
5586 * This is not applicable for 20/40/80 Mhz.
5587 * Only used when we support 80+80 Mhz operation.
5588 * In case of 80+80 Mhz, this parameter indicates
5589 * center channel frequency index of 80 Mhz channel of
5590 * frequency segment 1.
5591 */
5592 wider_bw_ch_switch->newCenterChanFreq1 =
5593 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005594 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005595 default:
5596 session_entry->dfsIncludeChanWrapperIe = false;
5597 /*
5598 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5599 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5600 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005601 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005602 break;
5603 }
5604 /* Fetch the center channel based on the channel width */
5605 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005606 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005607skip_vht:
5608 /* Send CSA IE request from here */
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05305609 lim_send_dfs_chan_sw_ie_update(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305610
5611 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5612 ch_offset = BW80;
5613 else
5614 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5615
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005616 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305617 session_entry->gLimChannelSwitch.switchCount,
5618 session_entry->gLimChannelSwitch.primaryChannel,
5619 session_entry->gLimChannelSwitch.ch_width,
5620 session_entry->dfsIncludeChanWrapperIe,
5621 ch_offset);
5622
gaolez76d2a162017-03-21 19:23:58 +08005623 /* Send ECSA/CSA Action frame after updating the beacon */
5624 if (CHAN_HOP_ALL_BANDS_ENABLE)
5625 lim_send_chan_switch_action_frame(mac_ctx,
5626 session_entry->gLimChannelSwitch.primaryChannel,
5627 ch_offset, session_entry);
5628 else
5629 send_extended_chan_switch_action_frame(mac_ctx,
5630 session_entry->gLimChannelSwitch.primaryChannel,
5631 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005632}
5633
5634/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305635 * lim_process_ext_change_channel()- function to send ECSA
5636 * action frame for STA/CLI .
5637 * @mac_ctx: pointer to global mac structure
5638 * @msg: params from sme for new channel.
5639 *
5640 * This function is called to send ECSA frame for STA/CLI.
5641 *
5642 * Return: void
5643 */
5644
5645static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5646 uint32_t *msg)
5647{
5648 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5649 (struct sir_sme_ext_cng_chan_req *) msg;
5650 tpPESession session_entry = NULL;
5651
5652 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005653 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305654 return;
5655 }
5656 session_entry =
5657 pe_find_session_by_sme_session_id(mac_ctx,
5658 ext_chng_channel->session_id);
5659 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005660 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305661 ext_chng_channel->session_id);
5662 return;
5663 }
5664 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005665 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305666 return;
5667 }
5668 send_extended_chan_switch_action_frame(mac_ctx,
5669 ext_chng_channel->new_channel,
5670 0, session_entry);
5671}
5672
5673/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005674 * lim_process_nss_update_request() - process sme nss update req
5675 *
5676 * @mac_ctx: Pointer to Global MAC structure
5677 * @msg_buf: pointer to the SME message buffer
5678 *
5679 * This function processes SME request messages from HDD or upper layer
5680 * application.
5681 *
5682 * Return: None
5683 */
5684static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5685 uint32_t *msg_buf)
5686{
5687 struct sir_nss_update_request *nss_update_req_ptr;
5688 tpPESession session_entry = NULL;
5689
5690 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005691 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005692 return;
5693 }
5694
5695 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305696 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005697 nss_update_req_ptr->vdev_id);
5698 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005699 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005700 nss_update_req_ptr->vdev_id);
5701 return;
5702 }
5703
5704 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005705 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005706 GET_LIM_SYSTEM_ROLE(session_entry));
5707 return;
5708 }
5709
5710 /* populate nss field in the beacon */
5711 session_entry->gLimOperatingMode.present = 1;
5712 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05305713 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
5714
5715 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
5716 (session_entry->ch_width > CH_WIDTH_80MHZ))
5717 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
5718
5719 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
5720
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005721 /* Send nss update request from here */
5722 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005723 QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005724 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005725 return;
5726 }
5727
5728 lim_send_beacon_ind(mac_ctx, session_entry);
5729}
5730
5731/**
5732 * lim_process_set_ie_req() - process sme set IE request
5733 *
5734 * @mac_ctx: Pointer to Global MAC structure
5735 * @msg_buf: pointer to the SME message buffer
5736 *
5737 * This function processes SME request messages from HDD or upper layer
5738 * application.
5739 *
5740 * Return: None
5741 */
5742static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5743{
5744 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305745 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005746
5747 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005748 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005749 return;
5750 }
5751
5752 msg = (struct send_extcap_ie *)msg_buf;
5753 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305754 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005755 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005756
5757}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005758
5759#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Arif Hussain05fb4872018-01-03 16:02:55 -08005760
5761/**
5762 * obss_color_collision_process_color_disable() - Disable bss color
5763 * @mac_ctx: Pointer to Global MAC structure
5764 * @session: pointer to session
5765 *
5766 * This function will disbale bss color.
5767 *
5768 * Return: None
5769 */
5770static void obss_color_collision_process_color_disable(tpAniSirGlobal mac_ctx,
5771 tpPESession session)
5772{
5773 tUpdateBeaconParams beacon_params;
5774
5775 if (!session) {
5776 pe_err("Invalid session");
5777 return;
5778 }
5779
5780 if (session->valid && !LIM_IS_AP_ROLE(session)) {
5781 pe_err("Invalid SystemRole %d",
5782 GET_LIM_SYSTEM_ROLE(session));
5783 return;
5784 }
5785
5786 if (session->bss_color_changing == 1) {
5787 pe_warn("%d: color change in progress", session->smeSessionId);
5788 /* Continue color collision detection */
5789 lim_send_obss_color_collision_cfg(mac_ctx, session,
5790 OBSS_COLOR_COLLISION_DETECTION);
5791 return;
5792 }
5793
5794 if (session->he_op.bss_col_disabled == 1) {
5795 pe_warn("%d: bss color already disabled",
5796 session->smeSessionId);
5797 /* Continue free color detection */
5798 lim_send_obss_color_collision_cfg(mac_ctx, session,
5799 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5800 return;
5801 }
5802
5803 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5804 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5805 session->he_op.bss_col_disabled = 1;
Arif Hussain05fb4872018-01-03 16:02:55 -08005806 beacon_params.bss_color_disabled = 1;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005807 beacon_params.bss_color = session->he_op.bss_color;
Arif Hussain05fb4872018-01-03 16:02:55 -08005808
5809 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005810 QDF_STATUS_SUCCESS) {
Arif Hussain05fb4872018-01-03 16:02:55 -08005811 pe_err("Unable to set op mode IE in beacon");
5812 return;
5813 }
5814
5815 lim_send_beacon_params(mac_ctx, &beacon_params, session);
5816 lim_send_obss_color_collision_cfg(mac_ctx, session,
5817 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5818}
5819
5820/**
5821 * obss_color_collision_process_color_change() - Process bss color change
5822 * @mac_ctx: Pointer to Global MAC structure
5823 * @session: pointer to session
5824 * @obss_color_info: obss color collision/free slot indication info
5825 *
5826 * This function selects new color ib case of bss color collision.
5827 *
5828 * Return: None
5829 */
5830static void obss_color_collision_process_color_change(tpAniSirGlobal mac_ctx,
5831 tpPESession session,
5832 struct wmi_obss_color_collision_info *obss_color_info)
5833{
5834 int i, num_bss_color = 0;
5835 uint32_t bss_color_bitmap;
5836 uint8_t bss_color_index_array[MAX_BSS_COLOR_VALUE];
5837 uint32_t rand_byte = 0;
5838 struct sir_set_he_bss_color he_bss_color;
5839 bool is_color_collision = false;
5840
5841
5842 if (session->bss_color_changing == 1) {
5843 pe_err("%d: color change in progress", session->smeSessionId);
5844 return;
5845 }
5846
5847 if (!session->he_op.bss_col_disabled) {
5848 if (session->he_op.bss_color < 32)
5849 is_color_collision = (obss_color_info->
5850 obss_color_bitmap_bit0to31 >>
5851 session->he_op.bss_color) & 0x01;
5852 else
5853 is_color_collision = (obss_color_info->
5854 obss_color_bitmap_bit32to63 >>
5855 (session->he_op.bss_color -
Arif Hussain9e8c5612018-04-12 16:35:48 -07005856 32)) & 0x01;
Arif Hussain05fb4872018-01-03 16:02:55 -08005857 if (!is_color_collision) {
5858 pe_err("%d: color collision not found, curr_color: %d",
5859 session->smeSessionId,
5860 session->he_op.bss_color);
5861 return;
5862 }
5863 }
5864
5865 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit0to31;
5866
5867 /* Skip color zero */
5868 bss_color_bitmap = bss_color_bitmap >> 1;
5869 for (i = 0; (i < 31) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5870 if (!(bss_color_bitmap & 0x01)) {
5871 bss_color_index_array[num_bss_color] = i + 1;
5872 num_bss_color++;
5873 }
5874 bss_color_bitmap = bss_color_bitmap >> 1;
5875 }
5876
5877 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit32to63;
5878 for (i = 0; (i < 32) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5879 if (!(bss_color_bitmap & 0x01)) {
5880 bss_color_index_array[num_bss_color] = i + 32;
5881 num_bss_color++;
5882 }
5883 bss_color_bitmap = bss_color_bitmap >> 1;
5884 }
5885
5886 if (num_bss_color) {
5887 qdf_get_random_bytes((void *) &rand_byte, 1);
5888 i = (rand_byte + qdf_mc_timer_get_system_ticks()) %
5889 num_bss_color;
5890 pe_debug("New bss color = %d", bss_color_index_array[i]);
5891 he_bss_color.session_id = obss_color_info->vdev_id;
5892 he_bss_color.bss_color = bss_color_index_array[i];
5893 lim_process_set_he_bss_color(mac_ctx,
5894 (uint32_t *)&he_bss_color);
5895 } else {
5896 pe_err("Unable to find bss color from bitmasp");
5897 if (obss_color_info->evt_type ==
5898 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY &&
5899 session->obss_color_collision_dec_evt ==
5900 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
5901 /* In dot11BSSColorCollisionAPPeriod and
5902 * timer expired, time to disable bss color.
5903 */
5904 obss_color_collision_process_color_disable(mac_ctx,
5905 session);
5906 else
5907 /*
5908 * Enter dot11BSSColorCollisionAPPeriod period.
5909 */
5910 lim_send_obss_color_collision_cfg(mac_ctx, session,
5911 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY);
5912 }
5913}
5914
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005915void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5916{
5917 struct sir_set_he_bss_color *bss_color;
5918 tpPESession session_entry = NULL;
5919 tUpdateBeaconParams beacon_params;
5920
5921 if (!msg_buf) {
5922 pe_err("Buffer is Pointing to NULL");
5923 return;
5924 }
5925
5926 bss_color = (struct sir_set_he_bss_color *)msg_buf;
5927 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5928 bss_color->session_id);
5929 if (!session_entry) {
5930 pe_err("Session not found for given session_id %d",
5931 bss_color->session_id);
5932 return;
5933 }
5934
5935 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5936 pe_err("Invalid SystemRole %d",
5937 GET_LIM_SYSTEM_ROLE(session_entry));
5938 return;
5939 }
5940
5941 if (bss_color->bss_color == session_entry->he_op.bss_color) {
5942 pe_err("No change in BSS color, current BSS color %d",
5943 bss_color->bss_color);
5944 return;
5945 }
5946 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5947 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5948 session_entry->he_op.bss_col_disabled = 1;
5949 session_entry->he_bss_color_change.countdown =
5950 BSS_COLOR_SWITCH_COUNTDOWN;
5951 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005952 beacon_params.bss_color_disabled = 1;
5953 beacon_params.bss_color = session_entry->he_op.bss_color;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005954 session_entry->bss_color_changing = 1;
5955
5956 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005957 QDF_STATUS_SUCCESS) {
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005958 pe_err("Unable to set op mode IE in beacon");
5959 return;
5960 }
5961
5962 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
Arif Hussain05fb4872018-01-03 16:02:55 -08005963 lim_send_obss_color_collision_cfg(mac_ctx, session_entry,
5964 OBSS_COLOR_COLLISION_DETECTION_DISABLE);
5965}
5966
5967void lim_send_obss_color_collision_cfg(tpAniSirGlobal mac_ctx,
5968 tpPESession session,
5969 enum wmi_obss_color_collision_evt_type
5970 event_type)
5971{
5972 struct wmi_obss_color_collision_cfg_param *cfg_param;
5973 struct scheduler_msg msg = {0};
5974
5975 if (!session) {
5976 pe_err("Invalid session");
5977 return;
5978 }
5979
5980 if (!session->he_capable ||
5981 !session->is_session_obss_color_collision_det_enabled) {
5982 pe_debug("%d: obss color det not enabled, he_cap:%d, sup:%d:%d",
5983 session->smeSessionId, session->he_capable,
5984 session->is_session_obss_color_collision_det_enabled,
5985 mac_ctx->lim.global_obss_color_collision_det_offload);
5986 return;
5987 }
5988
5989 cfg_param = qdf_mem_malloc(sizeof(*cfg_param));
5990 if (!cfg_param) {
5991 pe_err("Failed to allocate memory");
5992 return;
5993 }
5994
5995 pe_debug("%d: sending event:%d", session->smeSessionId, event_type);
5996 qdf_mem_zero(cfg_param, sizeof(*cfg_param));
5997 cfg_param->vdev_id = session->smeSessionId;
5998 cfg_param->evt_type = event_type;
5999 if (LIM_IS_AP_ROLE(session))
6000 cfg_param->detection_period_ms =
6001 OBSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS;
6002 else
6003 cfg_param->detection_period_ms =
6004 OBSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS;
6005
6006 cfg_param->scan_period_ms = OBSS_COLOR_COLLISION_SCAN_PERIOD_MS;
6007 if (event_type == OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6008 cfg_param->free_slot_expiry_time_ms =
6009 OBSS_COLOR_COLLISION_FREE_SLOT_EXPIRY_MS;
6010
6011 msg.type = WMA_OBSS_COLOR_COLLISION_REQ;
6012 msg.bodyptr = cfg_param;
6013 msg.reserved = 0;
6014
6015 if (QDF_IS_STATUS_ERROR(scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
6016 pe_err("Failed to post WMA_OBSS_COLOR_COLLISION_REQ to WMA");
6017 qdf_mem_free(cfg_param);
6018 } else {
6019 session->obss_color_collision_dec_evt = event_type;
6020 }
6021}
6022
6023void lim_process_obss_color_collision_info(tpAniSirGlobal mac_ctx,
6024 uint32_t *msg_buf)
6025{
6026 struct wmi_obss_color_collision_info *obss_color_info;
6027 tpPESession session;
6028
6029 if (!msg_buf) {
6030 pe_err("Buffer is Pointing to NULL");
6031 return;
6032 }
6033
6034 obss_color_info = (struct wmi_obss_color_collision_info *)msg_buf;
6035 session = pe_find_session_by_sme_session_id(mac_ctx,
6036 obss_color_info->vdev_id);
6037 if (!session) {
6038 pe_err("Session not found for given session_id %d",
6039 obss_color_info->vdev_id);
6040 return;
6041 }
6042
6043 pe_debug("vdev_id:%d, evt:%d:%d, 0to31:0x%x, 32to63:0x%x, cap:%d:%d:%d",
6044 obss_color_info->vdev_id,
6045 obss_color_info->evt_type,
6046 session->obss_color_collision_dec_evt,
6047 obss_color_info->obss_color_bitmap_bit0to31,
6048 obss_color_info->obss_color_bitmap_bit32to63,
6049 session->he_capable,
6050 session->is_session_obss_color_collision_det_enabled,
6051 mac_ctx->lim.global_obss_color_collision_det_offload);
6052
6053 if (!session->he_capable ||
6054 !session->is_session_obss_color_collision_det_enabled) {
6055 return;
6056 }
6057
6058 switch (obss_color_info->evt_type) {
6059 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
6060 pe_err("%d: FW disabled obss color det. he_cap:%d, sup:%d:%d",
6061 session->smeSessionId, session->he_capable,
6062 session->is_session_obss_color_collision_det_enabled,
6063 mac_ctx->lim.global_obss_color_collision_det_offload);
6064 session->is_session_obss_color_collision_det_enabled = false;
6065 return;
6066 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
6067 case OBSS_COLOR_COLLISION_DETECTION:
6068 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
6069 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6070 pe_debug("Invalid System Role %d",
6071 GET_LIM_SYSTEM_ROLE(session));
6072 return;
6073 }
6074
6075 if (session->obss_color_collision_dec_evt !=
6076 obss_color_info->evt_type) {
6077 pe_debug("%d: Wrong event: %d, skiping",
6078 obss_color_info->vdev_id,
6079 obss_color_info->evt_type);
6080 return;
6081 }
6082 obss_color_collision_process_color_change(mac_ctx, session,
6083 obss_color_info);
6084 break;
6085 default:
6086 pe_err("%d: Invalid event type %d",
6087 obss_color_info->vdev_id, obss_color_info->evt_type);
6088 return;
6089 }
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006090}
6091#endif