blob: ff05a010b573dca670606411c6d84f780509d106 [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;
Arif Hussain6686c0b2018-08-21 18:21:05 -07001339 session->enable_session_twt_support =
1340 sme_join_req->enable_session_twt_support;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341 /*
1342 * Store Session related parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001343 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001344
1345 /* store the smejoin req handle in session table */
1346 session->pLimJoinReq = sme_join_req;
1347
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001348 /* Store SME transaction Id in session Table */
1349 session->transactionId = sme_join_req->transactionId;
1350
1351 /* Store beaconInterval */
1352 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001353 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001354
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301355 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001356 sizeof(session->htConfig));
1357
Sandeep Puligilla98917432016-06-10 13:50:28 -07001358 qdf_mem_copy(&(session->vht_config),
1359 &(sme_join_req->vht_config),
1360 sizeof(session->vht_config));
1361
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001362 /* Copying of bssId is already done, while creating session */
1363 sir_copy_mac_addr(session->selfMacAddr,
1364 sme_join_req->selfMacAddr);
1365 session->bssType = sme_join_req->bsstype;
1366
1367 session->statypeForBss = STA_ENTRY_PEER;
1368 session->limWmeEnabled = sme_join_req->isWMEenabled;
1369 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301370 session->wps_registration = sme_join_req->wps_registration;
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001371 session->he_with_wep_tkip = sme_join_req->he_with_wep_tkip;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001372
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301373 session->enable_bcast_probe_rsp =
1374 sme_join_req->enable_bcast_probe_rsp;
1375
Jeff Johnson179fd8a2018-05-11 14:20:05 -07001376 /* Store vendor specific IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001377 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001378 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1379
Naveen Rawat08db88f2017-09-08 15:07:48 -07001380 vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001382 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001383
1384 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001385 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001386 session->isCiscoVendorAP = true;
1387 } else {
1388 session->isCiscoVendorAP = false;
1389 }
1390
1391 /* Copy the dot 11 mode in to the session table */
1392
1393 session->dot11mode = sme_join_req->dot11mode;
1394#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1395 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1396#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001397 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001398 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1399 session->enableHtSmps = sme_join_req->enableHtSmps;
1400 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001401 session->send_smps_action =
1402 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001403 /*
1404 * By default supported NSS 1x1 is set to true
1405 * and later on updated while determining session
1406 * supported rates which is the intersection of
1407 * self and peer rates
1408 */
1409 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301410 /*Store Persona */
1411 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001412 pe_debug("enable Smps: %d mode: %d send action: %d supported nss 1x1: %d pePersona %d cbMode %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001413 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001414 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001415 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301416 session->supported_nss_1x1,
1417 session->pePersona,
1418 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001419
1420 /*Store Persona */
1421 session->pePersona = sme_join_req->staPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +05301422 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301423 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d force_24ghz_in_ht20 %d"),
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001424 session->pePersona, sme_join_req->cbMode,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301425 session->nwType, session->dot11mode,
1426 sme_join_req->force_24ghz_in_ht20);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001427
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001428 /* Copy The channel Id to the session Table */
1429 session->currentOperChannel = bss_desc->channelId;
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301430
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001431 session->vhtCapability =
1432 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001433 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301434 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001435 session->vht_config.su_beam_formee =
1436 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001437 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001438 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001439 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440 session->enableVhtpAid =
1441 sme_join_req->enableVhtpAid;
1442 session->enableVhtGid =
1443 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001444 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001445 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001446 }
Krunal Soni53993f72016-07-08 18:20:03 -07001447
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001448 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301449 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001450 session->vht_config.su_beam_formee,
1451 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001452 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001453 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001454 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001455 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301456 session->force_24ghz_in_ht20 =
1457 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001458 /* cbMode is already merged value of peer and self -
1459 * done by csr in csr_get_cb_mode_from_ies */
1460 session->htSupportedChannelWidthSet =
1461 (sme_join_req->cbMode) ? 1 : 0;
1462 session->htRecommendedTxWidthSet =
1463 session->htSupportedChannelWidthSet;
1464 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1465
1466 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1467 session->ch_center_freq_seg0 =
1468 session->currentOperChannel - 2;
1469 session->ch_width = CH_WIDTH_40MHZ;
1470 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1471 sme_join_req->cbMode) {
1472 session->ch_center_freq_seg0 =
1473 session->currentOperChannel + 2;
1474 session->ch_width = CH_WIDTH_40MHZ;
1475 } else {
1476 session->ch_center_freq_seg0 = 0;
1477 session->ch_width = CH_WIDTH_20MHZ;
1478 }
1479
Naveen Rawataeca1b92017-10-16 16:55:31 -07001480 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1481 lim_update_session_he_capable(mac_ctx, session);
1482 lim_copy_join_req_he_cap(session, sme_join_req);
1483 }
1484
1485
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001486 /* Record if management frames need to be protected */
1487#ifdef WLAN_FEATURE_11W
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +05301488 if ((eSIR_ED_AES_128_CMAC ==
1489 sme_join_req->MgmtEncryptionType) ||
1490 (eSIR_ED_AES_GMAC_128 == sme_join_req->MgmtEncryptionType) ||
1491 (eSIR_ED_AES_GMAC_256 == sme_join_req->MgmtEncryptionType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001492 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001493 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001494 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001495#endif
1496
1497#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001498 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001499#endif
1500
1501 /* Copy the SSID from smejoinreq to session entry */
1502 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301503 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001504 session->ssId.length);
1505
1506 /*
1507 * Determin 11r or ESE connection based on input from SME
1508 * which inturn is dependent on the profile the user wants
1509 * to connect to, So input is coming from supplicant
1510 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001511 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001512#ifdef FEATURE_WLAN_ESE
1513 session->isESEconnection = sme_join_req->isESEconnection;
1514#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001515 session->isFastTransitionEnabled =
1516 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001517
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001518 session->isFastRoamIniFeatureEnabled =
1519 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001520 session->txLdpcIniFeatureEnabled =
1521 sme_join_req->txLdpcIniFeatureEnabled;
1522
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301523 lim_update_fils_config(session, sme_join_req);
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301524 lim_update_sae_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001525 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1526 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001527 } else {
1528 /*
1529 * Throw an error and return and make
1530 * sure to delete the session.
1531 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001532 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001533 session->bssType);
1534 ret_code = eSIR_SME_INVALID_PARAMETERS;
1535 goto end;
1536 }
1537
1538 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301539 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001540 &sme_join_req->addIEScan, sizeof(tSirAddie));
1541
1542 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301543 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001544 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1545
1546 val = sizeof(tLimMlmJoinReq) +
1547 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301548 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001549 if (NULL == mlm_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001550 pe_err("AllocateMemory failed for mlmJoinReq");
Nitesh Shah0102cac2016-07-13 14:38:30 +05301551 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1552 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001553 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001554
1555 /* PE SessionId is stored as a part of JoinReq */
1556 mlm_join_req->sessionId = session->peSessionId;
1557
1558 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1559 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001560 QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001561 pe_err("couldn't retrieve JoinFailureTimer value"
1562 " setting to default value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001563 mlm_join_req->joinFailureTimeout =
1564 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1565 }
1566
1567 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301568 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001569 (void *)&sme_join_req->operationalRateSet,
1570 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301571 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001572 (void *)&sme_join_req->extendedRateSet,
1573 sizeof(tSirMacRateSet));
1574 /*
1575 * this may not be needed anymore now, as rateSet is now
1576 * included in the session entry and MLM has session context.
1577 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301578 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001579 (void *)&session->rateSet,
1580 sizeof(tSirMacRateSet));
1581
1582 session->encryptType = sme_join_req->UCEncryptionType;
1583
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301584 session->supported_nss_1x1 = sme_join_req->supported_nss_1x1;
1585 session->vdev_nss = sme_join_req->vdev_nss;
1586 session->nss = sme_join_req->nss;
1587 session->nss_forced_1x1 = sme_join_req->nss_forced_1x1;
1588
1589 pe_debug("nss %d, vdev_nss %d, supported_nss_1x1 %d",
1590 session->nss,
1591 session->vdev_nss,
1592 session->supported_nss_1x1);
1593
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001594 mlm_join_req->bssDescription.length =
1595 session->pLimJoinReq->bssDescription.length;
1596
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301597 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001598 (uint8_t *)
1599 &session->pLimJoinReq->bssDescription.bssId,
1600 session->pLimJoinReq->bssDescription.length + 2);
1601
1602 session->limCurrentBssCaps =
1603 session->pLimJoinReq->bssDescription.capabilityInfo;
1604
1605 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1606 session->currentOperChannel);
1607 local_power_constraint = reg_max;
1608
1609 lim_extract_ap_capability(mac_ctx,
1610 (uint8_t *)
1611 session->pLimJoinReq->bssDescription.ieFields,
1612 lim_get_ielen_from_bss_description(
1613 &session->pLimJoinReq->bssDescription),
1614 &session->limCurrentBssQosCaps,
1615 &session->limCurrentBssPropCap,
1616 &session->gLimCurrentBssUapsd,
1617 &local_power_constraint, session);
1618
Krunal Soni53993f72016-07-08 18:20:03 -07001619 /*
1620 * Once the AP capabilities are available then set the
1621 * beam forming capabilities accordingly.
1622 */
1623 if (session->nss == 1) {
1624 session->vht_config.su_beam_former = 0;
1625 session->vht_config.tx_stbc = 0;
1626 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301627 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001628 }
1629
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001630 session->maxTxPower = lim_get_max_tx_power(reg_max,
1631 local_power_constraint,
1632 mac_ctx->roam.configParam.nTxPowerCap);
Abhinav Kumard528d192018-03-09 17:31:12 +05301633 session->def_max_tx_pwr = session->maxTxPower;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301634
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001635 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301636 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301638 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1639 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1640 pe_debug("Update MaxTxPower in join Req to %d",
1641 sme_join_req->powerCap.maxTxPower);
1642 }
1643
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001644 if (session->gLimCurrentBssUapsd) {
1645 session->gUapsdPerAcBitmask =
1646 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001647 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001648 session->gUapsdPerAcBitmask);
1649
1650 /* resetting the dynamic uapsd mask */
1651 session->gUapsdPerAcDeliveryEnableMask = 0;
1652 session->gUapsdPerAcTriggerEnableMask = 0;
1653 }
1654
1655 session->limRFBand =
1656 lim_get_rf_band(session->currentOperChannel);
1657
1658 /* Initialize 11h Enable Flag */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001659 if (BAND_5G == session->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001660 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001661 &val) != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001662 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001663 session->lim11hEnable =
1664 WNI_CFG_11H_ENABLED_STADEF;
1665 } else {
1666 session->lim11hEnable = val;
1667 }
1668 } else {
1669 session->lim11hEnable = 0;
1670 }
1671
1672 /*
1673 * To care of the scenario when STA transitions from
1674 * IBSS to Infrastructure mode.
1675 */
1676 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1677
1678 session->limPrevSmeState = session->limSmeState;
1679 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1680 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1681 session->peSessionId,
1682 session->limSmeState));
1683
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001684 /* Indicate whether spectrum management is enabled */
1685 session->spectrumMgtEnabled =
1686 sme_join_req->spectrumMgtIndicator;
1687
1688 /* Enable the spectrum management if this is a DFS channel */
1689 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001690 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001691 session->currentOperChannel))
1692 session->spectrumMgtEnabled = true;
1693
1694 session->isOSENConnection = sme_join_req->isOSENConnection;
1695
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001696 /* Issue LIM_MLM_JOIN_REQ to MLM */
1697 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1698 (uint32_t *) mlm_join_req);
1699 return;
1700
1701 } else {
1702 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001703 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001704 mac_ctx->lim.gLimSmeState);
1705 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1706 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1707 session = NULL;
1708 goto end;
1709 }
1710
1711end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301712 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1713 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001714
1715 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301716 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717 sme_join_req = NULL;
1718 if (NULL != session)
1719 session->pLimJoinReq = NULL;
1720 }
1721 if (ret_code != eSIR_SME_SUCCESS) {
1722 if (NULL != session) {
1723 pe_delete_session(mac_ctx, session);
1724 session = NULL;
1725 }
1726 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001727 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001728 sme_session_id, ret_code);
1729 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1730 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1731 sme_transaction_id);
1732}
1733
Amar Singhala297bfa2015-10-15 15:07:29 -07001734uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001735 uint8_t iniTxPower)
1736{
1737 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301738 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001739
Anurag Chouhan6d760662016-02-20 16:05:43 +05301740 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001741 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1742 maxTxPower = txPower;
1743 else if (txPower < MIN_TX_PWR_CAP)
1744 maxTxPower = MIN_TX_PWR_CAP;
1745 else
1746 maxTxPower = MAX_TX_PWR_CAP;
1747
1748 return maxTxPower;
1749}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001750
1751/**
1752 * __lim_process_sme_reassoc_req() - process reassoc req
1753 *
1754 * @mac_ctx: Pointer to Global MAC structure
1755 * @msg_buf: pointer to the SME message buffer
1756 *
1757 * This function is called to process SME_REASSOC_REQ message
1758 * from HDD or upper layer application.
1759 *
1760 * Return: None
1761 */
1762
1763static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
1764 uint32_t *msg_buf)
1765{
1766 uint16_t caps;
1767 uint32_t val;
1768 tpSirSmeJoinReq reassoc_req = NULL;
1769 tLimMlmReassocReq *mlm_reassoc_req;
1770 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1771 tpPESession session_entry = NULL;
1772 uint8_t session_id;
1773 uint8_t sme_session_id;
1774 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001775 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001776 uint32_t tele_bcn_en = 0;
1777 uint16_t size;
1778
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001779 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301780 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001781 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001782 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001783
1784 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1785 goto end;
1786 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301787 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001788
1789 if (!lim_is_sme_join_req_valid(mac_ctx,
1790 (tpSirSmeJoinReq)reassoc_req)) {
1791 /*
1792 * Received invalid eWNI_SME_REASSOC_REQ
1793 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001794 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001795
1796 ret_code = eSIR_SME_INVALID_PARAMETERS;
1797 goto end;
1798 }
1799
1800 session_entry = pe_find_session_by_bssid(mac_ctx,
1801 reassoc_req->bssDescription.bssId,
1802 &session_id);
1803 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001804 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001805 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
1806 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001808 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
1809 &sme_session_id, &transaction_id);
1810 session_entry =
1811 pe_find_session_by_sme_session_id(mac_ctx,
1812 sme_session_id);
1813 if (session_entry != NULL)
1814 lim_handle_sme_join_result(mac_ctx,
1815 eSIR_SME_INVALID_PARAMETERS,
1816 eSIR_MAC_UNSPEC_FAILURE_STATUS,
1817 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001818 goto end;
1819 }
1820#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
1821 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001822 session_entry, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001823#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1824 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
1825
1826 /* Store the reassoc handle in the session Table */
1827 session_entry->pLimReAssocReq = reassoc_req;
1828
1829 session_entry->dot11mode = reassoc_req->dot11mode;
1830 session_entry->vhtCapability =
1831 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001832
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301833 if (session_entry->vhtCapability) {
1834 if (session_entry->pePersona == QDF_STA_MODE) {
1835 session_entry->vht_config.su_beam_formee =
1836 reassoc_req->vht_config.su_beam_formee;
1837 } else {
1838 reassoc_req->vht_config.su_beam_formee = 0;
1839 }
1840 session_entry->enableVhtpAid =
1841 reassoc_req->enableVhtpAid;
1842 session_entry->enableVhtGid =
1843 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001844 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301845 }
1846
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301847 session_entry->supported_nss_1x1 = reassoc_req->supported_nss_1x1;
1848 session_entry->vdev_nss = reassoc_req->vdev_nss;
1849 session_entry->nss = reassoc_req->nss;
1850 session_entry->nss_forced_1x1 = reassoc_req->nss_forced_1x1;
1851
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001852 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301853 session_entry->vhtCapability,
1854 session_entry->vht_config.su_beam_formee,
1855 session_entry->vht_config.su_beam_former);
1856
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001857 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
1858 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001859 session_entry->send_smps_action =
1860 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001861 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001862 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001863 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001864 session_entry->send_smps_action,
1865 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001866 /*
1867 * Reassociate request is expected
1868 * in link established state only.
1869 */
1870
1871 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001872 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
1873 /*
1874 * May be from 11r FT pre-auth. So lets check it
1875 * before we bail out
1876 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001877 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001878 session_entry->peSessionId);
1879
1880 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301881 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001882 session_entry->limReAssocbssId,
1883 6)) {
1884 lim_print_mac_addr(mac_ctx,
1885 reassoc_req->bssDescription.
1886 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001887 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888 ret_code = eSIR_SME_INVALID_PARAMETERS;
1889 goto end;
1890 }
1891
1892 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
1893 session_entry);
1894 return;
1895 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001896 /*
1897 * Should not have received eWNI_SME_REASSOC_REQ
1898 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001899 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001900 session_entry->limSmeState);
1901 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
1902
1903 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1904 goto end;
1905 }
1906
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301907 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001908 session_entry->pLimReAssocReq->bssDescription.bssId,
1909 sizeof(tSirMacAddr));
1910
1911 session_entry->limReassocChannelId =
1912 session_entry->pLimReAssocReq->bssDescription.channelId;
1913
1914 session_entry->reAssocHtSupportedChannelWidthSet =
1915 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
1916 session_entry->reAssocHtRecommendedTxWidthSet =
1917 session_entry->reAssocHtSupportedChannelWidthSet;
1918 session_entry->reAssocHtSecondaryChannelOffset =
1919 session_entry->pLimReAssocReq->cbMode;
1920
1921 session_entry->limReassocBssCaps =
1922 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
1923 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1924 session_entry->currentOperChannel);
1925 local_pwr_constraint = reg_max;
1926
1927 lim_extract_ap_capability(mac_ctx,
1928 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
1929 lim_get_ielen_from_bss_description(
1930 &session_entry->pLimReAssocReq->bssDescription),
1931 &session_entry->limReassocBssQosCaps,
1932 &session_entry->limReassocBssPropCap,
1933 &session_entry->gLimCurrentBssUapsd,
1934 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05301935 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001936 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301937 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001938 /* Copy the SSID from session entry to local variable */
1939 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301940 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001941 reassoc_req->ssId.ssId,
1942 session_entry->limReassocSSID.length);
1943 if (session_entry->gLimCurrentBssUapsd) {
1944 session_entry->gUapsdPerAcBitmask =
1945 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001946 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001947 session_entry->gUapsdPerAcBitmask);
1948 }
1949
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301950 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001951 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001952 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001953
1954 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1955 goto end;
1956 }
1957
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301958 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001959 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
1960
1961 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
1962 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001963 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001964 pe_err("could not retrieve ReassocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001965
1966 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001967 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001968 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301969
1970 lim_update_caps_info_for_bss(mac_ctx, &caps,
1971 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001972 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301973
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001974 mlm_reassoc_req->capabilityInfo = caps;
1975
1976 /* Update PE session_id */
1977 mlm_reassoc_req->sessionId = session_id;
1978
1979 /*
1980 * If telescopic beaconing is enabled, set listen interval to
1981 * WNI_CFG_TELE_BCN_MAX_LI
1982 */
1983 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001984 &tele_bcn_en) != QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001985 pe_err("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001986
1987 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
1988
1989 if (tele_bcn_en) {
1990 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001991 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001992 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001993 } else {
1994 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001995 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001996 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001997 }
1998
1999 mlm_reassoc_req->listenInterval = (uint16_t) val;
2000
2001 /* Indicate whether spectrum management is enabled */
2002 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2003
2004 /* Enable the spectrum management if this is a DFS channel */
2005 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002006 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002007 session_entry->currentOperChannel))
2008 session_entry->spectrumMgtEnabled = true;
2009
2010 session_entry->limPrevSmeState = session_entry->limSmeState;
2011 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2012
2013 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2014 session_entry->peSessionId,
2015 session_entry->limSmeState));
2016
2017 lim_post_mlm_message(mac_ctx,
2018 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2019 return;
2020end:
2021 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302022 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002023 if (session_entry)
2024 session_entry->pLimReAssocReq = NULL;
2025 }
2026
2027 if (session_entry) {
2028 /*
2029 * error occurred after we determined the session so extract
2030 * session and transaction info from there
2031 */
2032 sme_session_id = session_entry->smeSessionId;
2033 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002034 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002035 /*
2036 * error occurred before or during the time we determined
2037 * the session so extract the session and transaction info
2038 * from the message
2039 */
2040 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2041 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002042 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002043 /*
2044 * Send Reassoc failure response to host
2045 * (note session_entry may be NULL, but that's OK)
2046 */
2047 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2048 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2049 session_entry, sme_session_id,
2050 transaction_id);
2051}
2052
2053bool send_disassoc_frame = 1;
2054/**
2055 * __lim_process_sme_disassoc_req()
2056 *
2057 ***FUNCTION:
2058 * This function is called to process SME_DISASSOC_REQ message
2059 * from HDD or upper layer application.
2060 *
2061 ***LOGIC:
2062 *
2063 ***ASSUMPTIONS:
2064 *
2065 ***NOTE:
2066 *
2067 * @param pMac Pointer to Global MAC structure
2068 * @param *pMsgBuf A pointer to the SME message buffer
2069 * @return None
2070 */
2071
2072static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2073{
2074 uint16_t disassocTrigger, reasonCode;
2075 tLimMlmDisassocReq *pMlmDisassocReq;
2076 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2077 tSirSmeDisassocReq smeDisassocReq;
2078 tpPESession psessionEntry = NULL;
2079 uint8_t sessionId;
2080 uint8_t smesessionId;
2081 uint16_t smetransactionId;
2082
2083 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002084 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002085 return;
2086 }
2087
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302088 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002089 smesessionId = smeDisassocReq.sessionId;
2090 smetransactionId = smeDisassocReq.transactionId;
2091 if (!lim_is_sme_disassoc_req_valid(pMac,
2092 &smeDisassocReq,
2093 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002094 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002095 if (pMac->lim.gLimRspReqd) {
2096 pMac->lim.gLimRspReqd = false;
2097
2098 retCode = eSIR_SME_INVALID_PARAMETERS;
2099 disassocTrigger = eLIM_HOST_DISASSOC;
2100 goto sendDisassoc;
2101 }
2102
2103 return;
2104 }
2105
2106 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002107 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002108 &sessionId);
2109 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002110 pe_err("session does not exist for given bssId "
2111 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002112 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002113 retCode = eSIR_SME_INVALID_PARAMETERS;
2114 disassocTrigger = eLIM_HOST_DISASSOC;
2115 goto sendDisassoc;
2116 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002117 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2118 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002119 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2120 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002121 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002122
2123#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2124 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2125 0, smeDisassocReq.reasonCode);
2126#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2127
2128 /* Update SME session Id and SME transaction ID */
2129
2130 psessionEntry->smeSessionId = smesessionId;
2131 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002132 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002133 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002134
2135 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2136 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002137 switch (psessionEntry->limSmeState) {
2138 case eLIM_SME_ASSOCIATED_STATE:
2139 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002140 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002141 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002142 psessionEntry->limPrevSmeState =
2143 psessionEntry->limSmeState;
2144 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002145 /* Delete all TDLS peers connected before leaving BSS */
2146 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002147 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2148 psessionEntry->peSessionId,
2149 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002150 break;
2151
2152 case eLIM_SME_WT_DEAUTH_STATE:
2153 /* PE shall still process the DISASSOC_REQ and proceed with
2154 * link tear down even if it had already sent a DEAUTH_IND to
2155 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2156 * its been set when PE entered WT_DEAUTH_STATE.
2157 */
2158 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2159 MTRACE(mac_trace
2160 (pMac, TRACE_CODE_SME_STATE,
2161 psessionEntry->peSessionId,
2162 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002163 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002164 break;
2165
2166 case eLIM_SME_WT_DISASSOC_STATE:
Jeff Johnson47d75242018-05-12 15:58:53 -07002167 /* PE Received a Disassoc frame. Normally it gets DISASSOC_CNF but it
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002168 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2169 * PE can continue processing DISASSOC_REQ and send the response instead
2170 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2171 * for disassoc frame.
2172 *
2173 * It will send a disassoc, which is ok. However, we can use the global flag
2174 * sendDisassoc to not send disassoc frame.
2175 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002176 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002177 break;
2178
2179 case eLIM_SME_JOIN_FAILURE_STATE: {
2180 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002181 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002182 if (pMac->lim.gLimRspReqd) {
2183 retCode = eSIR_SME_SUCCESS;
2184 disassocTrigger = eLIM_HOST_DISASSOC;
2185 goto sendDisassoc;
2186 }
2187 }
2188 break;
2189 default:
2190 /**
2191 * STA is not currently associated.
2192 * Log error and send response to host
2193 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002194 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002195 psessionEntry->limSmeState);
2196 lim_print_sme_state(pMac, LOGE,
2197 psessionEntry->limSmeState);
2198
2199 if (pMac->lim.gLimRspReqd) {
2200 if (psessionEntry->limSmeState !=
2201 eLIM_SME_WT_ASSOC_STATE)
2202 pMac->lim.gLimRspReqd = false;
2203
2204 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2205 disassocTrigger = eLIM_HOST_DISASSOC;
2206 goto sendDisassoc;
2207 }
2208
2209 return;
2210 }
2211
2212 break;
2213
2214 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002215 /* Fall through */
2216 break;
2217
2218 case eLIM_STA_IN_IBSS_ROLE:
2219 default:
2220 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002221 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002222 GET_LIM_SYSTEM_ROLE(psessionEntry));
2223
2224 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2225 disassocTrigger = eLIM_HOST_DISASSOC;
2226 goto sendDisassoc;
2227 } /* end switch (pMac->lim.gLimSystemRole) */
2228
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302229 disassocTrigger = eLIM_HOST_DISASSOC;
2230 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002231
2232 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002233 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002234 send_disassoc_frame = 0;
2235 }
2236 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002237 pe_debug("Sending Disasscoc with disassoc Trigger"
2238 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002239 disassocTrigger, reasonCode);
2240
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302241 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002242 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002243 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002244 return;
2245 }
2246
Anurag Chouhanc5548422016-02-24 18:33:27 +05302247 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002248 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002249
2250 pMlmDisassocReq->reasonCode = reasonCode;
2251 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2252
2253 /* Update PE session ID */
2254 pMlmDisassocReq->sessionId = sessionId;
2255
2256 lim_post_mlm_message(pMac,
2257 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2258 return;
2259
2260sendDisassoc:
2261 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002262 lim_send_sme_disassoc_ntf(pMac,
2263 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002264 retCode,
2265 disassocTrigger,
2266 1, smesessionId, smetransactionId,
2267 psessionEntry);
2268 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002269 lim_send_sme_disassoc_ntf(pMac,
2270 smeDisassocReq.peer_macaddr.bytes,
2271 retCode, disassocTrigger, 1,
2272 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002273
2274} /*** end __lim_process_sme_disassoc_req() ***/
2275
2276/** -----------------------------------------------------------------
2277 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2278
2279 This function is called to process SME_DISASSOC_CNF message
2280 from HDD or upper layer application.
2281
2282 \param pMac - global mac structure
2283 \param pStaDs - station dph hash node
2284 \return none
2285 \sa
2286 ----------------------------------------------------------------- */
2287static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2288{
2289 tSirSmeDisassocCnf smeDisassocCnf;
2290 uint16_t aid;
2291 tpDphHashNode pStaDs;
2292 tpPESession psessionEntry;
2293 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302294 uint32_t *msg = NULL;
2295 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002296
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302297 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002298 sizeof(struct sSirSmeDisassocCnf));
2299
2300 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002301 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002302 &sessionId);
2303 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002304 pe_err("session does not exist for given bssId");
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302305 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302306 smeDisassocCnf.sme_session_id,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302307 eSIR_SME_INVALID_SESSION,
2308 NULL);
2309 if (QDF_IS_STATUS_SUCCESS(status))
2310 lim_send_sme_disassoc_deauth_ntf(pMac,
2311 QDF_STATUS_SUCCESS,
2312 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002313 return;
2314 }
2315
2316 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002317 pe_err("received invalid SME_DISASSOC_CNF message");
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302318 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2319 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302320 eSIR_SME_INVALID_PARAMETERS,
2321 &smeDisassocCnf.bssid.bytes[0]);
2322 if (QDF_IS_STATUS_SUCCESS(status))
2323 lim_send_sme_disassoc_deauth_ntf(pMac,
2324 QDF_STATUS_SUCCESS,
2325 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002326 return;
2327 }
2328#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2329 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2330 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2331 psessionEntry,
2332 (uint16_t) smeDisassocCnf.statusCode, 0);
2333 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2334 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2335 psessionEntry,
2336 (uint16_t) smeDisassocCnf.statusCode, 0);
2337#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2338
2339 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2340 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002341 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2342 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2343 && (psessionEntry->limSmeState !=
2344 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002345 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002346 psessionEntry->limSmeState);
2347 lim_print_sme_state(pMac, LOGE,
2348 psessionEntry->limSmeState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302349 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302350 psessionEntry->smeSessionId,
2351 eSIR_SME_INVALID_STATE,
2352 &smeDisassocCnf.bssid.bytes[0]);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302353 if (QDF_IS_STATUS_SUCCESS(status))
2354 lim_send_sme_disassoc_deauth_ntf(pMac,
2355 QDF_STATUS_SUCCESS,
2356 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002357 return;
2358 }
2359 break;
2360
2361 case eLIM_AP_ROLE:
2362 /* Fall through */
2363 break;
2364
2365 case eLIM_STA_IN_IBSS_ROLE:
2366 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002367 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002368 GET_LIM_SYSTEM_ROLE(psessionEntry));
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302369 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2370 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302371 eSIR_SME_INVALID_STATE,
2372 &smeDisassocCnf.bssid.bytes[0]);
2373 if (QDF_IS_STATUS_SUCCESS(status))
2374 lim_send_sme_disassoc_deauth_ntf(pMac,
2375 QDF_STATUS_SUCCESS,
2376 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002377 return;
2378 }
2379
2380 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2381 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2382 LIM_IS_AP_ROLE(psessionEntry)) {
2383 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002384 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002385 &psessionEntry->dph.dphHashTable);
2386 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002387 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2388 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002389 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302390 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302391 psessionEntry->smeSessionId,
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05302392 eSIR_SME_INVALID_PARAMETERS,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302393 &smeDisassocCnf.bssid.bytes[0]);
2394 if (QDF_IS_STATUS_SUCCESS(status))
2395 lim_send_sme_disassoc_deauth_ntf(pMac,
2396 QDF_STATUS_SUCCESS,
2397 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002398 return;
2399 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302400
2401 if ((pStaDs->mlmStaContext.mlmState ==
2402 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2403 (pStaDs->mlmStaContext.mlmState ==
Arif Hussain5fa13782018-05-10 11:29:52 -07002404 eLIM_MLM_WT_DEL_BSS_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002405 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002406 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302407 pStaDs->mlmStaContext.mlmState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302408 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302409 psessionEntry->smeSessionId,
2410 eSIR_SME_SUCCESS,
2411 NULL);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302412 if (QDF_IS_STATUS_SUCCESS(status))
2413 lim_send_sme_disassoc_deauth_ntf(pMac,
2414 QDF_STATUS_SUCCESS,
2415 (uint32_t *)msg);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302416 return;
2417 }
2418
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002419 /* Delete FT session if there exists one */
2420 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002421 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2422
2423 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002424 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002425 }
2426
2427 return;
2428}
2429
2430/**
2431 * __lim_process_sme_deauth_req() - process sme deauth req
2432 * @mac_ctx: Pointer to Global MAC structure
2433 * @msg_buf: pointer to the SME message buffer
2434 *
2435 * This function is called to process SME_DEAUTH_REQ message
2436 * from HDD or upper layer application.
2437 *
2438 * Return: None
2439 */
2440
2441static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2442 uint32_t *msg_buf)
2443{
2444 uint16_t deauth_trigger, reason_code;
2445 tLimMlmDeauthReq *mlm_deauth_req;
2446 tSirSmeDeauthReq sme_deauth_req;
2447 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2448 tpPESession session_entry;
2449 uint8_t session_id; /* PE sessionId */
2450 uint8_t sme_session_id;
2451 uint16_t sme_transaction_id;
2452
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302453 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002454 sme_session_id = sme_deauth_req.sessionId;
2455 sme_transaction_id = sme_deauth_req.transactionId;
2456
2457 /*
2458 * We need to get a session first but we don't even know
2459 * if the message is correct.
2460 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002461 session_entry = pe_find_session_by_bssid(mac_ctx,
2462 sme_deauth_req.bssid.bytes,
2463 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002464 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002465 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002466 ret_code = eSIR_SME_INVALID_PARAMETERS;
2467 deauth_trigger = eLIM_HOST_DEAUTH;
2468 goto send_deauth;
2469 }
2470
2471 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2472 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002473 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002474 mac_ctx->lim.gLimRspReqd = false;
2475
2476 ret_code = eSIR_SME_INVALID_PARAMETERS;
2477 deauth_trigger = eLIM_HOST_DEAUTH;
2478 goto send_deauth;
2479 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002480 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2481 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002482 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2483 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002484 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002485#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2486 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2487 session_entry, 0, sme_deauth_req.reasonCode);
2488#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2489
2490 /* Update SME session ID and Transaction ID */
2491 session_entry->smeSessionId = sme_session_id;
2492 session_entry->transactionId = sme_transaction_id;
2493
2494 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2495 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002496 switch (session_entry->limSmeState) {
2497 case eLIM_SME_ASSOCIATED_STATE:
2498 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302499 /* Delete all TDLS peers connected before leaving BSS */
2500 lim_delete_tdls_peers(mac_ctx, session_entry);
Abhinav Kumarac12c762018-05-02 13:51:02 +05302501 /* fallthrough */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002502 case eLIM_SME_WT_ASSOC_STATE:
2503 case eLIM_SME_JOIN_FAILURE_STATE:
2504 case eLIM_SME_IDLE_STATE:
2505 session_entry->limPrevSmeState =
2506 session_entry->limSmeState;
2507 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2508 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2509 session_entry->peSessionId,
2510 session_entry->limSmeState));
2511 /* Send Deauthentication request to MLM below */
2512 break;
2513 case eLIM_SME_WT_DEAUTH_STATE:
2514 case eLIM_SME_WT_DISASSOC_STATE:
2515 /*
Jeff Johnson47d75242018-05-12 15:58:53 -07002516 * PE Received a Deauth/Disassoc frame. Normally it get
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002517 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2518 * Which means host is also trying to disconnect.
2519 * PE can continue processing DEAUTH_REQ and send
2520 * the response instead of failing the request.
2521 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2522 * was sent for deauth/disassoc frame.
2523 */
2524 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002525 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002526 break;
2527 default:
2528 /*
2529 * STA is not in a state to deauthenticate with
2530 * peer. Log error and send response to host.
2531 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002532 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002533 session_entry->limSmeState);
2534 lim_print_sme_state(mac_ctx, LOGE,
2535 session_entry->limSmeState);
2536
2537 if (mac_ctx->lim.gLimRspReqd) {
2538 mac_ctx->lim.gLimRspReqd = false;
2539
2540 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2541 deauth_trigger = eLIM_HOST_DEAUTH;
2542
wadesong42968e92017-06-08 14:11:21 +08002543 /*
2544 * here we received deauth request from AP so
2545 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2546 * have ISSUED delSta then mlm state should be
2547 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2548 * delBSS rsp then mlm state should be
2549 * eLIM_MLM_IDLE_STATE so the below condition
2550 * captures the state where delSta not done
2551 * and firmware still in connected state.
2552 */
2553 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002554 eLIM_SME_WT_DEAUTH_STATE &&
2555 session_entry->limMlmState !=
2556 eLIM_MLM_IDLE_STATE &&
2557 session_entry->limMlmState !=
2558 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002559 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002560 goto send_deauth;
2561 }
2562 return;
2563 }
2564 break;
2565
2566 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002567 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002568 if (mac_ctx->lim.gLimRspReqd) {
2569 mac_ctx->lim.gLimRspReqd = false;
2570 ret_code = eSIR_SME_INVALID_PARAMETERS;
2571 deauth_trigger = eLIM_HOST_DEAUTH;
2572 goto send_deauth;
2573 }
2574 return;
2575 case eLIM_AP_ROLE:
2576 break;
2577 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002578 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002579 GET_LIM_SYSTEM_ROLE(session_entry));
2580 if (mac_ctx->lim.gLimRspReqd) {
2581 mac_ctx->lim.gLimRspReqd = false;
2582 ret_code = eSIR_SME_INVALID_PARAMETERS;
2583 deauth_trigger = eLIM_HOST_DEAUTH;
2584 goto send_deauth;
2585 }
2586 return;
2587 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2588
2589 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2590 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002591 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002592 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2593 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2594 } else {
2595 deauth_trigger = eLIM_HOST_DEAUTH;
2596 reason_code = sme_deauth_req.reasonCode;
2597 }
2598
2599 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302600 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002601 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002602 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002603 if (mac_ctx->lim.gLimRspReqd) {
2604 mac_ctx->lim.gLimRspReqd = false;
2605 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2606 deauth_trigger = eLIM_HOST_DEAUTH;
2607 goto send_deauth;
2608 }
2609 return;
2610 }
2611
Anurag Chouhanc5548422016-02-24 18:33:27 +05302612 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002613 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002614
2615 mlm_deauth_req->reasonCode = reason_code;
2616 mlm_deauth_req->deauthTrigger = deauth_trigger;
2617
2618 /* Update PE session Id */
2619 mlm_deauth_req->sessionId = session_id;
2620
2621 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2622 (uint32_t *)mlm_deauth_req);
2623 return;
2624
2625send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002626 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2627 ret_code, deauth_trigger, 1,
2628 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002629}
2630
2631/**
2632 * __lim_process_sme_set_context_req()
2633 *
2634 * @mac_ctx: Pointer to Global MAC structure
2635 * @msg_buf: pointer to the SME message buffer
2636 *
2637 * This function is called to process SME_SETCONTEXT_REQ message
2638 * from HDD or upper layer application.
2639 *
2640 * Return: None
2641 */
2642
2643static void
2644__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2645{
2646 tpSirSmeSetContextReq set_context_req;
2647 tLimMlmSetKeysReq *mlm_set_key_req;
2648 tpPESession session_entry;
2649 uint8_t session_id; /* PE sessionID */
2650 uint8_t sme_session_id;
2651 uint16_t sme_transaction_id;
2652
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002653 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002654 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002655 return;
2656 }
2657
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302658 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002659 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002660 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002661 return;
2662 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302663 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002664 sizeof(struct sSirSmeSetContextReq));
2665 sme_session_id = set_context_req->sessionId;
2666 sme_transaction_id = set_context_req->transactionId;
2667
2668 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002669 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002670 goto end;
2671 }
2672
2673 if (set_context_req->keyMaterial.numKeys >
2674 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002675 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002676 set_context_req->keyMaterial.numKeys);
2677 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002678 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002679 eSIR_SME_INVALID_PARAMETERS, NULL,
2680 sme_session_id, sme_transaction_id);
2681 goto end;
2682 }
2683
2684 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002685 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002686 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002687 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002688 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002689 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002690 eSIR_SME_INVALID_PARAMETERS, NULL,
2691 sme_session_id, sme_transaction_id);
2692 goto end;
2693 }
2694#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2695 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2696 session_entry, 0, 0);
2697#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2698
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002699 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002700 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2701 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002702 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002703 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2704 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302705 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002706 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002707 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002708 goto end;
2709 }
2710 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2711 mlm_set_key_req->numKeys =
2712 set_context_req->keyMaterial.numKeys;
2713 if (mlm_set_key_req->numKeys >
2714 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002715 pe_err("no.of keys exceeded max num of default keys limit");
Jingxiang Ge4168a232018-01-03 18:47:15 +08002716 qdf_mem_free(mlm_set_key_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002717 goto end;
2718 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302719 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002720 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002721
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302722 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002723 (uint8_t *) &set_context_req->keyMaterial.key,
2724 sizeof(tSirKeys) *
2725 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2726 numKeys : 1));
2727
2728 mlm_set_key_req->sessionId = session_id;
2729 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002730 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002731 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002732
2733 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2734 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2735 LIM_IS_AP_ROLE(session_entry)) {
2736 if (set_context_req->keyMaterial.key[0].keyLength) {
2737 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002738
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002739 key_id =
2740 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302741 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002742 &session_entry->WEPKeyMaterial[key_id],
2743 (uint8_t *) &set_context_req->keyMaterial,
2744 sizeof(tSirKeyMaterial));
2745 } else {
2746 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002747
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002748 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2749 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302750 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002751 &mlm_set_key_req->key[i],
2752 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2753 sizeof(tSirKeys));
2754 }
2755 }
2756 }
2757 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2758 (uint32_t *) mlm_set_key_req);
2759 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002760 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002761 GET_LIM_SYSTEM_ROLE(session_entry),
2762 session_entry->limSmeState);
2763 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2764
2765 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002766 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002767 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2768 session_entry, sme_session_id,
2769 sme_transaction_id);
2770 }
2771end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302772 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002773 return;
2774}
2775
2776/**
2777 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2778 *
2779 * @mac_ctx: Pointer to Global MAC structure
2780 * @msg_buf: pointer to the SME message buffer
2781 *
2782 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2783 * from HDD or upper layer application.
2784 *
2785 * Return: None
2786 */
2787
Jeff Johnson801f1532016-10-07 07:54:50 -07002788static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2789 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002790{
2791 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2792 tpDphHashNode sta_ds = NULL;
2793 tpPESession session_entry = NULL;
2794 tSap_Event sap_event;
2795 tpWLAN_SAPEventCB sap_event_cb = NULL;
2796 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2797 uint8_t session_id = CSR_SESSION_ID_INVALID;
2798 uint8_t assoc_id = 0;
2799 uint8_t sta_cnt = 0;
2800
2801 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002802 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002803 return;
2804 }
2805
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302806 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002807 sizeof(struct sSirSmeGetAssocSTAsReq));
2808 /*
2809 * Get Associated stations from PE.
2810 * Find PE session Entry
2811 */
2812 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08002813 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002814 &session_id);
2815 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002816 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002817 goto lim_assoc_sta_end;
2818 }
2819
2820 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002821 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002822 session_entry->limSmeState,
2823 GET_LIM_SYSTEM_ROLE(session_entry));
2824 goto lim_assoc_sta_end;
2825 }
2826 /* Retrieve values obtained in the request message */
2827 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
2828 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2829
2830 if (NULL == assoc_sta_tmp)
2831 goto lim_assoc_sta_end;
2832 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
2833 assoc_id++) {
2834 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
2835 &session_entry->dph.dphHashTable);
2836 if (NULL == sta_ds)
2837 continue;
2838 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302839 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002840 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302841 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002842 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
2843 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
2844
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302845 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002846 (uint8_t *)&sta_ds->supportedRates,
2847 sizeof(tSirSupportedRates));
2848 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
2849 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
2850 assoc_sta_tmp->Support40Mhz =
2851 sta_ds->htDsssCckRate40MHzSupport;
2852
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002853 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002854 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002855 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002856 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002857 pe_debug("Association Id: %d Station Index: %d",
2858 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002859 assoc_sta_tmp++;
2860 sta_cnt++;
2861 }
2862 }
2863lim_assoc_sta_end:
2864 /*
2865 * Call hdd callback with sap event to send the list of
2866 * associated stations from PE
2867 */
2868 if (sap_event_cb != NULL) {
2869 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
2870 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302871 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002872 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
2873 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
2874 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2875 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
2876 }
2877}
2878
2879/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002880 * __lim_counter_measures()
2881 *
2882 * FUNCTION:
2883 * This function is called to "implement" MIC counter measure
2884 * and is *temporary* only
2885 *
2886 * LOGIC: on AP, disassoc all STA associated thru TKIP,
2887 * we don't do the proper STA disassoc sequence since the
Jeff Johnsond460e842018-05-11 13:25:53 -07002888 * BSS will be stopped anyway
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002889 *
2890 ***ASSUMPTIONS:
2891 *
2892 ***NOTE:
2893 *
2894 * @param pMac Pointer to Global MAC structure
2895 * @return None
2896 */
2897
2898static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
2899{
2900 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002901
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002902 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002903 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
2904 mac, psessionEntry, false);
2905};
2906
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002907static void
2908__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2909{
2910 tSirSmeStopBssReq stopBssReq;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002911 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002912 tLimSmeStates prevState;
2913 tpPESession psessionEntry;
2914 uint8_t smesessionId;
2915 uint8_t sessionId;
2916 uint16_t smetransactionId;
2917 uint8_t i = 0;
2918 tpDphHashNode pStaDs = NULL;
2919
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302920 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002921 smesessionId = stopBssReq.sessionId;
2922 smetransactionId = stopBssReq.transactionId;
2923
2924 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002925 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002926 /* Send Stop BSS response to host */
2927 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2928 eSIR_SME_INVALID_PARAMETERS, smesessionId,
2929 smetransactionId);
2930 return;
2931 }
2932
2933 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08002934 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002935 &sessionId);
2936 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002937 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002938 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2939 eSIR_SME_INVALID_PARAMETERS, smesessionId,
2940 smetransactionId);
2941 return;
2942 }
2943#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2944 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
2945 0, 0);
2946#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2947
2948 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
2949 LIM_IS_STA_ROLE(psessionEntry)) {
2950 /**
2951 * Should not have received STOP_BSS_REQ in states
2952 * other than 'normal' state or on STA in Infrastructure
2953 * mode. Log error and return response to host.
2954 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002955 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002956 psessionEntry->limSmeState,
2957 GET_LIM_SYSTEM_ROLE(psessionEntry));
2958 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
2959 /* / Send Stop BSS response to host */
2960 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2961 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
2962 smetransactionId);
2963 return;
2964 }
2965
2966 if (LIM_IS_AP_ROLE(psessionEntry))
2967 lim_wpspbc_close(pMac, psessionEntry);
2968
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002969 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002970 stopBssReq.reasonCode);
2971
2972 prevState = psessionEntry->limSmeState;
2973
2974 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
2975 MTRACE(mac_trace
2976 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
2977 psessionEntry->limSmeState));
2978
2979 /* Update SME session Id and Transaction Id */
2980 psessionEntry->smeSessionId = smesessionId;
2981 psessionEntry->transactionId = smetransactionId;
2982
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002983 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
2984 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
2985 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002986 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002987
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002988 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
2989 /* Send disassoc all stations associated thru TKIP */
2990 __lim_counter_measures(pMac, psessionEntry);
2991 else
2992 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002993 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
2994 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002995 }
2996
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002997 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
2998 /* Free the buffer allocated in START_BSS_REQ */
2999 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3000 psessionEntry->addIeParams.probeRespDataLen = 0;
3001 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003002
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003003 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3004 psessionEntry->addIeParams.assocRespDataLen = 0;
3005 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003006
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003007 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3008 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3009 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003010
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003011 /*
3012 * lim_del_bss is also called as part of coalescing,
3013 * when we send DEL BSS followed by Add Bss msg.
3014 */
3015 pMac->lim.gLimIbssCoalescingHappened = false;
3016 }
Sandeep Puligillaa894ffc2018-06-01 15:33:36 -07003017 for (i = 1; i < psessionEntry->dph.dphHashTable.size; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003018 pStaDs =
3019 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3020 if (NULL == pStaDs)
3021 continue;
3022 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003023 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003024 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3025 pStaDs->assocId, psessionEntry);
3026 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3027 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003028 pe_err("lim_del_sta failed with Status: %d", status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303029 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003030 }
3031 }
3032 /* send a delBss to HAL and wait for a response */
3033 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3034
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003035 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003036 pe_err("delBss failed for bss %d", psessionEntry->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003037 psessionEntry->limSmeState = prevState;
3038
3039 MTRACE(mac_trace
3040 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3041 psessionEntry->limSmeState));
3042
3043 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3044 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3045 smetransactionId);
3046 }
3047}
3048
3049/**
3050 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3051 * @pMac: Global MAC context
3052 * @pMsg: Message from SME
3053 *
3054 * Wrapper for the function __lim_handle_sme_stop_bss_request
3055 * This message will be defered until softmac come out of
3056 * scan mode. Message should be handled even if we have
3057 * detected radar in the current operating channel.
3058 *
3059 * Return: true - If we consumed the buffer
3060 * false - If have defered the message.
3061 */
3062
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003063static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3064 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003065{
3066 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3067 /**
3068 * If message defered, buffer is not consumed yet.
3069 * So return false
3070 */
3071 return false;
3072 }
3073 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3074 return true;
3075} /*** end __lim_process_sme_stop_bss_req() ***/
3076
3077void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3078 uint32_t body, tpPESession psessionEntry)
3079{
3080
3081 (void)body;
3082 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3083 lim_ibss_delete(pMac, psessionEntry);
3084 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3085 lim_delete_pre_auth_list(pMac);
3086 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3087 psessionEntry->smeSessionId,
3088 psessionEntry->transactionId);
3089 return;
3090}
3091
3092/**
3093 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3094 *
3095 * @mac_ctx: pointer to mac context
3096 * @msg_type: message type
3097 * @msg_buf: pointer to the SME message buffer
3098 *
3099 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3100 * in BTAMP AP.
3101 *
3102 * Return: None
3103 */
3104
3105void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3106 uint32_t *msg_buf)
3107{
3108 tSirSmeAssocCnf assoc_cnf;
3109 tpDphHashNode sta_ds = NULL;
3110 tpPESession session_entry = NULL;
3111 uint8_t session_id;
3112 tpSirAssocReq assoc_req;
3113
3114 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003115 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003116 goto end;
3117 }
3118
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303119 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003120 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003121 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003122 goto end;
3123 }
3124
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003125 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003126 &session_id);
3127 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003128 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003129 goto end;
3130 }
3131
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003132 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003133 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3134 (session_entry->limSmeState !=
3135 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003136 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003137 msg_type, session_entry->limSmeState,
3138 GET_LIM_SYSTEM_ROLE(session_entry));
3139 goto end;
3140 }
3141 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3142 &session_entry->dph.dphHashTable);
3143 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003144 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003145 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303146 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147
3148 /*
3149 * send a DISASSOC_IND message to WSM to make sure
3150 * the state in WSM and LIM is the same
3151 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003152 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003153 eSIR_SME_STA_NOT_ASSOCIATED,
3154 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3155 session_entry->smeSessionId,
3156 session_entry->transactionId,
3157 session_entry);
3158 goto end;
3159 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303160 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003161 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303162 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003163 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003164 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303165 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003166 goto end;
3167 }
3168
3169 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3170 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3171 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3172 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3173 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003174 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3175 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003176 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303177 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003178 goto end;
3179 }
3180 /*
3181 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3182 * has been received
3183 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003184 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003185 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3186 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3187
3188 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3189 /*
3190 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3191 * when it had received Assoc Request frame. Now, PE just needs
3192 * to send association rsp frame to the requesting BTAMP-STA.
3193 */
3194 sta_ds->mlmStaContext.mlmState =
3195 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003196 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003197 sta_ds->assocId);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003198 lim_send_assoc_rsp_mgmt_frame(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003199 sta_ds->assocId, sta_ds->staAddr,
3200 sta_ds->mlmStaContext.subType, sta_ds,
3201 session_entry);
3202 goto end;
3203 } else {
3204 /*
3205 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3206 * to be associated since the HAL sta entry is created for
3207 * denied STA we need to remove this HAL entry.
3208 * So to do that set updateContext to 1
3209 */
3210 if (!sta_ds->mlmStaContext.updateContext)
3211 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003212 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003213 assoc_cnf.statusCode, sta_ds->assocId);
3214 lim_reject_association(mac_ctx, sta_ds->staAddr,
3215 sta_ds->mlmStaContext.subType,
3216 true, sta_ds->mlmStaContext.authType,
3217 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003218 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003219 session_entry);
3220 }
3221end:
3222 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3223 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3224 assoc_req = (tpSirAssocReq)
3225 session_entry->parsedAssocReq[sta_ds->assocId];
3226 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303227 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003228 assoc_req->assocReqFrame = NULL;
3229 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303230 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003231 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3232 }
3233}
3234
3235static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3236{
3237 tpDphHashNode pStaDs;
3238 tSirMacAddr peerMac;
3239 tpSirAddtsReq pSirAddts;
3240 uint32_t timeout;
3241 tpPESession psessionEntry;
3242 uint8_t sessionId; /* PE sessionId */
3243 uint8_t smesessionId;
3244 uint16_t smetransactionId;
3245
3246 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003247 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003248 return;
3249 }
3250
3251 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3252 &smetransactionId);
3253
3254 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3255
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003256 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3257 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003258 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003259 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003260 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303261 NULL, pSirAddts->req.tspec,
3262 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003263 return;
3264 }
3265#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3266 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3267 0);
3268#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3269
3270 /* if sta
3271 * - verify assoc state
3272 * - send addts request to ap
3273 * - wait for addts response from ap
3274 * if ap, just ignore with error log
3275 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003276 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3277 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3278 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003280 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003281 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303282 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003284
3285 pStaDs =
3286 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3287 &psessionEntry->dph.dphHashTable);
3288
3289 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003290 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303291 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003292 }
3293
3294 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3295 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003296 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303297 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003298 }
3299
3300 pSirAddts->req.wsmTspecPresent = 0;
3301 pSirAddts->req.wmeTspecPresent = 0;
3302 pSirAddts->req.lleTspecPresent = 0;
3303
3304 if ((pStaDs->wsmEnabled) &&
3305 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3306 SIR_MAC_ACCESSPOLICY_EDCA))
3307 pSirAddts->req.wsmTspecPresent = 1;
3308 else if (pStaDs->wmeEnabled)
3309 pSirAddts->req.wmeTspecPresent = 1;
3310 else if (pStaDs->lleEnabled)
3311 pSirAddts->req.lleTspecPresent = 1;
3312 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003313 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303314 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003315 }
3316
3317 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3318 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003319 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003320 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303321 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003322 }
3323
3324 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003325 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003326 pMac->lim.gLimAddtsReq.req.dialogToken,
3327 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3328 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3329 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303330 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003331 }
3332
3333 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3334
3335 /* save the addts request */
3336 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303337 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003338 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3339
3340 /* ship out the message now */
3341 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3342 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303343 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344 /* start a timer to wait for the response */
3345 if (pSirAddts->timeout)
3346 timeout = pSirAddts->timeout;
3347 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003348 QDF_STATUS_SUCCESS) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303349 pe_debug("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003350 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303351 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003352 }
3353
3354 timeout = SYS_MS_TO_TICKS(timeout);
3355 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3356 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003357 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303358 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003359 }
3360 pMac->lim.gLimAddtsRspTimerCount++;
3361 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3362 pMac->lim.gLimAddtsRspTimerCount) !=
3363 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003364 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303365 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003366 }
3367 MTRACE(mac_trace
3368 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3369 eLIM_ADDTS_RSP_TIMER));
3370
3371 /* add the sessionId to the timer object */
3372 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3373 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3374 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003375 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303376 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003377 }
3378 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303379
3380send_failure_addts_rsp:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003381 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303382 psessionEntry, pSirAddts->req.tspec,
3383 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003384}
3385
3386static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3387{
3388 tSirMacAddr peerMacAddr;
3389 uint8_t ac;
3390 tSirMacTSInfo *pTsinfo;
3391 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3392 tpDphHashNode pStaDs = NULL;
3393 tpPESession psessionEntry;
3394 uint8_t sessionId;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003395 uint32_t status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003396 uint8_t smesessionId;
3397 uint16_t smetransactionId;
3398
3399 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3400 &smetransactionId);
3401
3402 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003403 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003404 &sessionId);
3405 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003406 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003407 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003408 goto end;
3409 }
3410#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3411 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3412 0);
3413#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3414
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003415 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003416 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003417 pe_err("lim_validate_delts_req failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003418 status = QDF_STATUS_E_FAILURE;
3419 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_E_FAILURE, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003420 smesessionId, smetransactionId);
3421 return;
3422 }
3423
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003424 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3425 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003426 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3427
3428 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3429 pDeltsReq->req.wmeTspecPresent,
3430 &pDeltsReq->req.tsinfo,
3431 &pDeltsReq->req.tspec, psessionEntry);
3432
3433 pTsinfo =
3434 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3435 tsinfo : &pDeltsReq->req.tsinfo;
3436
3437 /* We've successfully send DELTS frame to AP. Update the
3438 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3439 * is no longer trigger enabled or delivery enabled
3440 */
3441 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3442 pTsinfo, CLEAR_UAPSD_MASK);
3443
3444 /* We're deleting the TSPEC, so this particular AC is no longer
3445 * admitted. PE needs to downgrade the EDCA
3446 * parameters(for the AC for which TS is being deleted) to the
3447 * next best AC for which ACM is not enabled, and send the
3448 * updated values to HAL.
3449 */
3450 ac = upToAc(pTsinfo->traffic.userPrio);
3451
3452 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3453 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3454 ~(1 << ac);
3455 } else if (pTsinfo->traffic.direction ==
3456 SIR_MAC_DIRECTION_DNLINK) {
3457 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3458 ~(1 << ac);
3459 } else if (pTsinfo->traffic.direction ==
3460 SIR_MAC_DIRECTION_BIDIR) {
3461 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3462 ~(1 << ac);
3463 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3464 ~(1 << ac);
3465 }
3466
3467 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3468 psessionEntry);
3469
3470 pStaDs =
3471 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3472 &psessionEntry->dph.dphHashTable);
3473 if (pStaDs != NULL) {
3474 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003475 pStaDs->bssId, false);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003476 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003477 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003478 pe_err("Self entry missing in Hash Table");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003479 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003480 }
3481#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003482 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003483#endif
3484
3485 /* send an sme response back */
3486end:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003487 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_SUCCESS, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003488 smesessionId, smetransactionId);
3489}
3490
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303491void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003492{
3493 /* fetch the sessionEntry based on the sessionId */
3494 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003495
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496 psessionEntry = pe_find_session_by_session_id(pMac,
3497 pMac->lim.limTimers.gLimAddtsRspTimer.
3498 sessionId);
3499 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003500 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003501 return;
3502 }
3503
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003504 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003505 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003506 GET_LIM_SYSTEM_ROLE(psessionEntry));
3507 pMac->lim.gLimAddtsSent = false;
3508 return;
3509 }
3510
3511 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003512 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003513 return;
3514 }
3515
3516 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003517 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003518 pMac->lim.gLimAddtsRspTimerCount);
3519 return;
3520 }
3521 /* this a real response timeout */
3522 pMac->lim.gLimAddtsSent = false;
3523 pMac->lim.gLimAddtsRspTimerCount++;
3524
3525 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3526 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3527 psessionEntry->smeSessionId,
3528 psessionEntry->transactionId);
3529}
3530
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003531#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003532/**
3533 * __lim_process_sme_get_statistics_request()
3534 *
3535 ***FUNCTION:
3536 *
3537 *
3538 ***NOTE:
3539 *
3540 * @param pMac Pointer to Global MAC structure
3541 * @param *pMsgBuf A pointer to the SME message buffer
3542 * @return None
3543 */
3544static void
3545__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3546{
3547 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003548 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003549
3550 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3551
3552 msgQ.type = WMA_GET_STATISTICS_REQ;
3553
3554 msgQ.reserved = 0;
3555 msgQ.bodyptr = pMsgBuf;
3556 msgQ.bodyval = 0;
3557 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3558
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003559 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303560 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003561 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003562 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003563 return;
3564 }
3565
3566 return;
3567}
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003568#else
3569static void __lim_process_sme_get_statistics_request(
3570 struct sAniSirGlobal *mac_ctx, uint32_t *pMsgBuf) {}
3571#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003572
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003573#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003574/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003575 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003576 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003577 * @pMac: Pointer to Global MAC structure
3578 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003579 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003580 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003581 */
3582static void
3583__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3584{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003585 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586
3587 msgQ.type = WMA_TSM_STATS_REQ;
3588 msgQ.reserved = 0;
3589 msgQ.bodyptr = pMsgBuf;
3590 msgQ.bodyval = 0;
3591 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3592
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003593 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303594 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003595 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003596 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003597 return;
3598 }
3599}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003600#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003601
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08003602static void lim_process_sme_set_addba_accept(tpAniSirGlobal mac_ctx,
3603 struct sme_addba_accept *msg)
3604{
3605 if (!msg) {
3606 pe_err("Msg Buffer is NULL");
3607 return;
3608 }
3609 if (!msg->addba_accept)
3610 mac_ctx->reject_addba_req = 1;
3611 else
3612 mac_ctx->reject_addba_req = 0;
3613}
3614
Arif Hussaineb8ba362018-03-07 19:15:13 -08003615static void lim_process_sme_update_edca_params(tpAniSirGlobal mac_ctx,
3616 uint32_t sme_session_id)
3617{
3618 tpPESession pe_session;
3619 tpDphHashNode sta_ds_ptr;
3620
3621 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3622 if (!pe_session) {
3623 pe_err("Session does not exist: sme_id %d", sme_session_id);
3624 return;
3625 }
3626 pe_session->gLimEdcaParamsActive[EDCA_AC_BE].no_ack =
3627 mac_ctx->no_ack_policy_cfg[EDCA_AC_BE];
3628 pe_session->gLimEdcaParamsActive[EDCA_AC_BK].no_ack =
3629 mac_ctx->no_ack_policy_cfg[EDCA_AC_BK];
3630 pe_session->gLimEdcaParamsActive[EDCA_AC_VI].no_ack =
3631 mac_ctx->no_ack_policy_cfg[EDCA_AC_VI];
3632 pe_session->gLimEdcaParamsActive[EDCA_AC_VO].no_ack =
3633 mac_ctx->no_ack_policy_cfg[EDCA_AC_VO];
3634 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3635 &pe_session->dph.dphHashTable);
3636 if (sta_ds_ptr)
3637 lim_send_edca_params(mac_ctx,
3638 pe_session->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003639 sta_ds_ptr->bssId, false);
Arif Hussaineb8ba362018-03-07 19:15:13 -08003640 else
3641 pe_err("Self entry missing in Hash Table");
3642}
3643
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07003644static void lim_process_sme_update_mu_edca_params(tpAniSirGlobal mac_ctx,
3645 uint32_t sme_session_id)
3646{
3647 tpPESession pe_session;
3648 tpDphHashNode sta_ds_ptr;
3649
3650 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3651 if (!pe_session) {
3652 pe_err("Session does not exist: sme_id %d", sme_session_id);
3653 return;
3654 }
3655 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3656 &pe_session->dph.dphHashTable);
3657 if (sta_ds_ptr)
3658 lim_send_edca_params(mac_ctx, mac_ctx->usr_mu_edca_params,
3659 sta_ds_ptr->bssId, true);
3660 else
3661 pe_err("Self entry missing in Hash Table");
3662}
3663
Naveen Rawat8029a402017-06-01 10:54:19 -07003664static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3665 struct update_config *msg)
3666{
3667 tpPESession pe_session;
3668
3669 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3670 if (msg == NULL) {
3671 pe_err("Buffer is Pointing to NULL");
3672 return;
3673 }
3674
3675 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3676 msg->sme_session_id);
3677 if (pe_session == NULL) {
3678 pe_warn("Session does not exist for given BSSID");
3679 return;
3680 }
3681
3682 switch (msg->capab) {
3683 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3684 pe_session->htConfig.ht_rx_ldpc = msg->value;
3685 break;
3686 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3687 pe_session->htConfig.ht_tx_stbc = msg->value;
3688 break;
3689 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3690 pe_session->htConfig.ht_rx_stbc = msg->value;
3691 break;
3692 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3693 pe_session->htConfig.ht_sgi20 = msg->value;
3694 break;
3695 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3696 pe_session->htConfig.ht_sgi40 = msg->value;
3697 break;
3698 }
3699
3700 if (LIM_IS_AP_ROLE(pe_session)) {
3701 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3702 lim_send_beacon_ind(mac_ctx, pe_session);
3703 }
3704}
3705
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003706void
3707lim_send_vdev_restart(tpAniSirGlobal pMac,
3708 tpPESession psessionEntry, uint8_t sessionId)
3709{
3710 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003711 struct scheduler_msg msgQ = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003712 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003713
3714 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003715 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003716 return;
3717 }
3718
3719 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303720 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003721 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003722 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003723 return;
3724 }
3725
3726 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3727 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003728 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003729
3730 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3731 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3732 msgQ.bodyval = 0;
3733
3734 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003735 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003736 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303737 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003738 }
3739}
3740
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303741/**
3742 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3743 * @mac_ctx: Pointer to Global MAC structure
3744 * @msg_buf: Pointer to SME message buffer
3745 *
3746 * Return: None
3747 */
3748static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3749 uint32_t *msg_buf)
3750{
3751 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003752 struct scheduler_msg wma_msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003753 QDF_STATUS status;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303754 tSirRoamOffloadScanReq *req_buffer;
3755 uint16_t local_ie_len;
3756 uint8_t *local_ie_buf;
3757
3758 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3759 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3760 req_buffer->sessionId);
3761
3762 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3763 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003764 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303765 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303766 return;
3767 }
3768
3769 local_ie_len = req_buffer->assoc_ie.length;
3770 /* Update ext cap IE if present */
3771 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003772 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3773 local_ie_buf, &local_ie_len)) {
3774 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003775 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3776 req_buffer->assoc_ie.length = local_ie_len;
3777 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3778 local_ie_buf, local_ie_len);
3779 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303780 }
3781 qdf_mem_free(local_ie_buf);
3782
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303783 if (pe_session)
3784 lim_update_fils_rik(pe_session, req_buffer);
3785
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303786 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3787 wma_msg.bodyptr = req_buffer;
3788
3789 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003790 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003791 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303792 qdf_mem_free(req_buffer);
3793 }
3794}
3795
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303796/*
3797 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3798 * @mac_ctx: Pointer to global mac context
3799 * @session: Pointer to PE session
3800 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3801 * 1 - Disable broadcast SSID
3802 *
3803 * Return: None
3804 */
3805static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3806 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003807{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003808 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003809 session->ssidHidden, ssid_hidden);
3810
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003811 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303812 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003813 } else {
3814 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05303815 return;
3816 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003817
3818 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303819 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003820
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003821 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303822}
3823
3824/**
3825 * __lim_process_sme_session_update - process SME session update msg
3826 *
3827 * @mac_ctx: Pointer to global mac context
3828 * @msg_buf: Pointer to the received message buffer
3829 *
3830 * Return: None
3831 */
3832static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
3833 uint32_t *msg_buf)
3834{
3835 struct sir_update_session_param *msg;
3836 tpPESession session;
3837
3838 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003839 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303840 return;
3841 }
3842
3843 msg = (struct sir_update_session_param *) msg_buf;
3844
3845 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
3846 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003847 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303848 msg->session_id);
3849 return;
3850 }
3851
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003852 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303853 msg->param_type, msg->param_val);
3854 switch (msg->param_type) {
3855 case SIR_PARAM_SSID_HIDDEN:
3856 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
3857 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303858 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
3859 session->ignore_assoc_disallowed = msg->param_val;
3860 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303861 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003862 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303863 break;
3864 }
3865}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003866
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003867/*
3868 Update the beacon Interval dynamically if beaconInterval is different in MCC
3869 */
3870static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3871{
3872 tpSirChangeBIParams pChangeBIParams;
3873 tpPESession psessionEntry;
3874 uint8_t sessionId = 0;
3875 tUpdateBeaconParams beaconParams;
3876
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003877 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003878
3879 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003880 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003881 return;
3882 }
3883
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303884 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003885 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
3886
3887 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08003888 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003889 &sessionId);
3890 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003891 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003892 return;
3893 }
3894
3895 /*Update sessionEntry Beacon Interval */
3896 if (psessionEntry->beaconParams.beaconInterval !=
3897 pChangeBIParams->beaconInterval) {
3898 psessionEntry->beaconParams.beaconInterval =
3899 pChangeBIParams->beaconInterval;
3900 }
3901
3902 /*Update sch beaconInterval */
3903 if (pMac->sch.schObject.gSchBeaconInterval !=
3904 pChangeBIParams->beaconInterval) {
3905 pMac->sch.schObject.gSchBeaconInterval =
3906 pChangeBIParams->beaconInterval;
3907
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003908 pe_debug("LIM send update BeaconInterval Indication: %d",
3909 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003910
3911 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
3912 /* Update beacon */
3913 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3914
3915 beaconParams.bssIdx = psessionEntry->bssIdx;
3916 /* Set change in beacon Interval */
3917 beaconParams.beaconInterval =
3918 pChangeBIParams->beaconInterval;
3919 beaconParams.paramChangeBitmap =
3920 PARAM_BCN_INTERVAL_CHANGED;
3921 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
3922 }
3923 }
3924
3925 return;
3926} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
3927
3928#ifdef QCA_HT_2040_COEX
3929static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
3930 uint32_t *pMsgBuf)
3931{
3932 tpSirSetHT2040Mode pSetHT2040Mode;
3933 tpPESession psessionEntry;
3934 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003935 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003936 tUpdateVHTOpMode *pHtOpMode = NULL;
3937 uint16_t staId = 0;
3938 tpDphHashNode pStaDs = NULL;
3939
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003940 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003941 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003942 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003943 return;
3944 }
3945
3946 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
3947
3948 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08003949 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003950 &sessionId);
3951 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003952 pe_debug("Session does not exist for given BSSID");
3953 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003954 return;
3955 }
3956
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003957 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003958 pSetHT2040Mode->cbMode);
3959 /*Update sessionEntry HT related fields */
3960 switch (pSetHT2040Mode->cbMode) {
3961 case PHY_SINGLE_CHANNEL_CENTERED:
3962 psessionEntry->htSecondaryChannelOffset =
3963 PHY_SINGLE_CHANNEL_CENTERED;
3964 psessionEntry->htRecommendedTxWidthSet = 0;
3965 if (pSetHT2040Mode->obssEnabled)
3966 psessionEntry->htSupportedChannelWidthSet
3967 = eHT_CHANNEL_WIDTH_40MHZ;
3968 else
3969 psessionEntry->htSupportedChannelWidthSet
3970 = eHT_CHANNEL_WIDTH_20MHZ;
3971 break;
3972 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
3973 psessionEntry->htSecondaryChannelOffset =
3974 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3975 psessionEntry->htRecommendedTxWidthSet = 1;
3976 break;
3977 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
3978 psessionEntry->htSecondaryChannelOffset =
3979 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3980 psessionEntry->htRecommendedTxWidthSet = 1;
3981 break;
3982 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003983 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003984 return;
3985 }
3986
3987 /* Update beacon */
3988 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3989 lim_send_beacon_ind(pMac, psessionEntry);
3990
3991 /* update OP Mode for each associated peer */
3992 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
3993 pStaDs = dph_get_hash_entry(pMac, staId,
3994 &psessionEntry->dph.dphHashTable);
3995 if (NULL == pStaDs)
3996 continue;
3997
3998 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303999 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004000 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004001 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004002 return;
4003 }
4004 pHtOpMode->opMode =
4005 (psessionEntry->htSecondaryChannelOffset ==
4006 PHY_SINGLE_CHANNEL_CENTERED) ?
4007 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4008 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304009 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004010 sizeof(tSirMacAddr));
4011 pHtOpMode->smesessionId = sessionId;
4012
4013 msg.type = WMA_UPDATE_OP_MODE;
4014 msg.reserved = 0;
4015 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004016 if (!QDF_IS_STATUS_SUCCESS
4017 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
4018 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304019 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004020 return;
4021 }
Jeff Johnson47d75242018-05-12 15:58:53 -07004022 pe_debug("Notified FW about OP mode: %d for staId=%d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004023 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004024
4025 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004026 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004027 }
4028
4029 return;
4030}
4031#endif
4032
4033/* -------------------------------------------------------------------- */
4034/**
4035 * __lim_process_report_message
4036 *
4037 * FUNCTION: Processes the next received Radio Resource Management message
4038 *
4039 * LOGIC:
4040 *
4041 * ASSUMPTIONS:
4042 *
4043 * NOTE:
4044 *
4045 * @param None
4046 * @return None
4047 */
4048
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004049static void __lim_process_report_message(tpAniSirGlobal pMac,
4050 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004052 switch (pMsg->type) {
4053 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4054 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4055 break;
4056 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004057 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004058 break;
4059 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004060 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004061 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004062}
4063
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004064/* -------------------------------------------------------------------- */
4065/**
4066 * lim_send_set_max_tx_power_req
4067 *
4068 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4069 *
4070 * LOGIC:
4071 *
4072 * ASSUMPTIONS:
4073 *
4074 * NOTE:
4075 *
4076 * @param txPower txPower to be set.
4077 * @param pSessionEntry session entry.
4078 * @return None
4079 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004080QDF_STATUS
Amar Singhala297bfa2015-10-15 15:07:29 -07004081lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004082 tpPESession pSessionEntry)
4083{
4084 tpMaxTxPowerParams pMaxTxParams = NULL;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004085 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004086 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004087
4088 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004089 pe_err("Invalid parameters");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004090 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004091 }
4092
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304093 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004094 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004095 pe_err("Unable to allocate memory for pMaxTxParams");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004096 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004097
4098 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004099 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304100 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304101 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304102 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004103 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304104 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004105
4106 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4107 msgQ.bodyptr = pMaxTxParams;
4108 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004109 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004110 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4111 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004112 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004113 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304114 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004115 }
4116 return retCode;
4117}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004118
4119/**
4120 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4121 *
4122 * @mac_ctx: Pointer to Global MAC structure
4123 * @msg_buf: pointer to the SME message buffer
4124 *
4125 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4126 * from SME. It Register this information within PE.
4127 *
4128 * Return: None
4129 */
4130static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4131 uint32_t *msg_buf)
4132{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304133 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004134 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4135 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4136 struct mgmt_frm_reg_info *next = NULL;
4137 bool match = false;
4138
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004139 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004140 sme_req->registerFrame, sme_req->frameType,
4141 sme_req->matchLen);
4142 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304143 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304144 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4145 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304146 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004147
4148 while (lim_mgmt_regn != NULL) {
4149 if (lim_mgmt_regn->frameType != sme_req->frameType)
4150 goto skip_match;
4151 if (sme_req->matchLen) {
4152 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304153 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004154 sme_req->matchData,
4155 lim_mgmt_regn->matchLen))) {
4156 /* found match! */
4157 match = true;
4158 break;
4159 }
4160 } else {
4161 /* found match! */
4162 match = true;
4163 break;
4164 }
4165skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304166 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304167 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004168 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304169 (qdf_list_node_t *)lim_mgmt_regn,
4170 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304171 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004172 lim_mgmt_regn = next;
4173 next = NULL;
4174 }
4175 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304176 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004177 if (QDF_STATUS_SUCCESS ==
4178 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004179 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004180 (qdf_list_node_t *)lim_mgmt_regn))
4181 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304182 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004183 }
4184
4185 if (sme_req->registerFrame) {
4186 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304187 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004188 sme_req->matchLen);
4189 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004190 lim_mgmt_regn->frameType = sme_req->frameType;
4191 lim_mgmt_regn->matchLen = sme_req->matchLen;
4192 lim_mgmt_regn->sessionId = sme_req->sessionId;
4193 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304194 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004195 sme_req->matchData,
4196 sme_req->matchLen);
4197 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304198 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004199 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304200 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201 gLimMgmtFrameRegistratinQueue,
4202 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304203 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004204 &mac_ctx->lim.lim_frame_register_lock);
4205 }
4206 }
4207 return;
4208}
4209
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004210static void
4211__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4212{
4213 tpSirResetAPCapsChange pResetCapsChange;
4214 tpPESession psessionEntry;
4215 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004216
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004217 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004218 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004219 return;
4220 }
4221
4222 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4223 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004224 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4225 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004226 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004227 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004228 return;
4229 }
4230
4231 psessionEntry->limSentCapsChangeNtf = false;
4232 return;
4233}
4234
4235/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304236 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4237 * indication callback in PE.
4238 * @mac_ptr: Mac pointer
4239 * @msg_buf: Msg pointer containing the callback
4240 *
4241 * This function is used save the Management frame
4242 * indication callback in PE.
4243 *
4244 * Return: None
4245 */
4246static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4247 uint32_t *msg_buf)
4248{
4249 struct sir_sme_mgmt_frame_cb_req *sme_req =
4250 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4251
4252 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004253 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304254 return;
4255 }
4256 if (sme_req->callback)
4257 mac_ctx->mgmt_frame_ind_cb =
4258 (sir_mgmt_frame_ind_callback)sme_req->callback;
4259 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004260 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304261}
4262
4263/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304264 *__lim_process_send_disassoc_frame: function processes disassoc frame
4265 * @mac_ctx: pointer to mac context
4266 * @msg_buf: message buffer
4267 *
4268 * function processes disassoc request received from SME
4269 *
4270 * return: none
4271 */
4272static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4273 uint32_t *msg_buf)
4274{
4275 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004276 QDF_STATUS status;
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304277 tpPESession session_entry = NULL;
4278 uint8_t sme_session_id;
4279 uint16_t sme_trans_id;
4280
4281 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004282 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304283 return;
4284 }
4285
4286 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4287 &sme_trans_id);
4288
4289 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4290 &sme_send_disassoc_frame_req,
4291 (uint8_t *)msg_buf);
4292
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004293 if ((QDF_STATUS_E_FAILURE == status) ||
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304294 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4295 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004296 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304297 return;
4298 }
4299
4300 session_entry = pe_find_session_by_sme_session_id(
4301 mac_ctx, sme_session_id);
4302 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004303 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304304 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4305 return;
4306 }
4307
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004308 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 +05304309 sme_send_disassoc_frame_req.msg_type,
4310 sme_send_disassoc_frame_req.length,
4311 sme_send_disassoc_frame_req.session_id,
4312 sme_send_disassoc_frame_req.trans_id,
4313 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4314 sme_send_disassoc_frame_req.reason,
4315 sme_send_disassoc_frame_req.wait_for_ack);
4316
4317 lim_send_disassoc_mgmt_frame(mac_ctx,
4318 sme_send_disassoc_frame_req.reason,
4319 sme_send_disassoc_frame_req.peer_mac,
4320 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4321}
4322
4323/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004324 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4325 * @mac_ctx: Pointer to Global MAC structure
4326 * @pdev_id: pdev id to set the IE.
4327 * @nss: Nss values to prepare the HT IE.
4328 *
4329 * Prepares the HT IE with self capabilities for different
4330 * Nss values and sends the set HT IE req to FW.
4331 *
4332 * Return: None
4333 */
4334static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4335 uint8_t nss)
4336{
4337 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004338 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004339 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004340 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004341 tHtCaps *p_ht_cap;
4342 int i;
4343
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004344 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004345 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4346 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004347 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004348 return;
4349 }
4350 ie_params->nss = i;
4351 ie_params->pdev_id = pdev_id;
4352 ie_params->ie_type = DOT11_HT_IE;
4353 /* 2 for IE len and EID */
4354 ie_params->ie_len = 2 + sizeof(tHtCaps);
4355 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4356 if (NULL == ie_params->ie_ptr) {
4357 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004358 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004359 return;
4360 }
4361 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4362 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4363 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4364 ie_params->ie_len);
4365
4366 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004367 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4368 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004369 if (NULL == p_ie) {
4370 qdf_mem_free(ie_params->ie_ptr);
4371 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004372 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004373 return;
4374 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004375 p_ht_cap = (tHtCaps *)&p_ie[2];
4376 p_ht_cap->supportedMCSSet[1] = 0;
4377 p_ht_cap->txSTBC = 0;
4378 }
4379
4380 msg.type = WMA_SET_PDEV_IE_REQ;
4381 msg.bodyptr = ie_params;
4382 msg.bodyval = 0;
4383
4384 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004385 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004386 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004387 qdf_mem_free(ie_params->ie_ptr);
4388 qdf_mem_free(ie_params);
4389 return;
4390 }
4391 }
4392}
4393
4394/**
4395 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4396 * @mac_ctx: Pointer to Global MAC structure
4397 * @pdev_id: pdev id to set the IE.
4398 * @nss: Nss values to prepare the VHT IE.
4399 *
4400 * Prepares the VHT IE with self capabilities for different
4401 * Nss values and sends the set VHT IE req to FW.
4402 *
4403 * Return: None
4404 */
4405static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4406 uint8_t nss)
4407{
4408 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004409 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004410 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004411 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004412 tSirMacVHTCapabilityInfo *vht_cap;
4413 int i;
4414 tSirVhtMcsInfo *vht_mcs;
4415
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004416 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004417 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4418 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004419 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004420 return;
4421 }
4422 ie_params->nss = i;
4423 ie_params->pdev_id = pdev_id;
4424 ie_params->ie_type = DOT11_VHT_IE;
4425 /* 2 for IE len and EID */
4426 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4427 sizeof(tSirVhtMcsInfo);
4428 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4429 if (NULL == ie_params->ie_ptr) {
4430 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004431 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004432 return;
4433 }
4434 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4435 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4436 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4437 ie_params->ie_len);
4438
4439 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004440 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4441 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004442 if (NULL == p_ie) {
4443 qdf_mem_free(ie_params->ie_ptr);
4444 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004445 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004446 return;
4447 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004448 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4449 vht_cap->txSTBC = 0;
4450 vht_mcs =
4451 (tSirVhtMcsInfo *)&p_ie[2 +
4452 sizeof(tSirMacVHTCapabilityInfo)];
4453 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4454 vht_mcs->rxHighest =
4455 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4456 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4457 vht_mcs->txHighest =
4458 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4459 }
4460 msg.type = WMA_SET_PDEV_IE_REQ;
4461 msg.bodyptr = ie_params;
4462 msg.bodyval = 0;
4463
4464 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004465 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004466 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004467 qdf_mem_free(ie_params->ie_ptr);
4468 qdf_mem_free(ie_params);
4469 return;
4470 }
4471 }
4472}
4473
4474/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004475 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4476 * @mac_ctx: Pointer to Global MAC structure
4477 * @msg_buf: Pointer to the SME message buffer
4478 *
4479 * This function is called by limProcessMessageQueue(). This function sets the
4480 * VDEV IEs to the FW.
4481 *
4482 * Return: None
4483 */
4484static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4485 uint32_t *msg_buf)
4486{
4487 struct sir_set_vdev_ies_per_band *p_msg =
4488 (struct sir_set_vdev_ies_per_band *)msg_buf;
4489
4490 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004491 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004492 return;
4493 }
4494
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004495 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004496 p_msg->vdev_id);
4497 /* intentionally using NULL here so that self capabilty are sent */
4498 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4499 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004500 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004501}
4502
4503/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004504 * lim_process_set_pdev_IEs() - process the set pdev IE req
4505 * @mac_ctx: Pointer to Global MAC structure
4506 * @msg_buf: Pointer to the SME message buffer
4507 *
4508 * This function is called by limProcessMessageQueue(). This
4509 * function sets the PDEV IEs to the FW.
4510 *
4511 * Return: None
4512 */
4513static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4514{
4515 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4516
4517 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4518
4519 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004520 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004521 return;
4522 }
4523
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004524 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004525 ht_vht_cfg->nss);
4526 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4527
4528 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4529 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4530 ht_vht_cfg->nss);
4531}
4532
4533/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304534 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4535 *
4536 * access policy
4537 * @mac_ctx: pointer to mac context
4538 * @msg: message buffer
4539 *
4540 * function processes vendor IE and access policy from SME and updates PE
4541 *
4542 * session entry
4543 *
4544 * return: none
4545*/
4546static void lim_process_sme_update_access_policy_vendor_ie(
4547 tpAniSirGlobal mac_ctx,
4548 uint32_t *msg)
4549{
4550 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4551 struct sPESession *pe_session_entry;
Pragaspathi Thilagaraj9b7a1162018-05-07 16:28:13 +05304552 uint16_t num_bytes;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304553
4554 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004555 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304556 return;
4557 }
4558 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4559 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4560 update_vendor_ie->sme_session_id);
4561
4562 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004563 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304564 update_vendor_ie->sme_session_id);
4565 return;
4566 }
4567 if (pe_session_entry->access_policy_vendor_ie)
4568 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4569
4570 num_bytes = update_vendor_ie->ie[1] + 2;
4571 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4572
4573 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004574 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304575 return;
4576 }
4577 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4578 &update_vendor_ie->ie[0], num_bytes);
4579
4580 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4581}
4582
4583/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004584 * lim_process_sme_req_messages()
4585 *
4586 ***FUNCTION:
4587 * This function is called by limProcessMessageQueue(). This
4588 * function processes SME request messages from HDD or upper layer
4589 * application.
4590 *
4591 ***LOGIC:
4592 *
4593 ***ASSUMPTIONS:
4594 *
4595 ***NOTE:
4596 *
4597 * @param pMac Pointer to Global MAC structure
4598 * @param msgType Indicates the SME message type
4599 * @param *pMsgBuf A pointer to the SME message buffer
4600 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4601 * false - if pMsgBuf is not to be freed.
4602 */
4603
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004604bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4605 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004606{
Jeff Johnson33142e62018-05-06 17:58:36 -07004607 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 -08004608 uint32_t *pMsgBuf = pMsg->bodyptr;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004609
4610 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004611 lim_msg_str(pMsg->type), pMsg->type,
4612 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4613 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004614
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004615 /* If no insert NOA required then execute the code below */
4616
4617 switch (pMsg->type) {
4618 case eWNI_SME_SYS_READY_IND:
4619 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4620 break;
4621
4622 case eWNI_SME_START_BSS_REQ:
4623 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4624 break;
4625
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004626 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4627 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4628 break;
4629 case eWNI_SME_JOIN_REQ:
4630 __lim_process_sme_join_req(pMac, pMsgBuf);
4631 break;
4632
4633 case eWNI_SME_REASSOC_REQ:
4634 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4635 break;
4636
4637 case eWNI_SME_DISASSOC_REQ:
4638 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4639 break;
4640
4641 case eWNI_SME_DISASSOC_CNF:
4642 case eWNI_SME_DEAUTH_CNF:
4643 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4644 break;
4645
4646 case eWNI_SME_DEAUTH_REQ:
4647 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4648 break;
4649
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304650 case eWNI_SME_SEND_DISASSOC_FRAME:
4651 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4652 break;
4653
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004654 case eWNI_SME_SETCONTEXT_REQ:
4655 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4656 break;
4657
4658 case eWNI_SME_STOP_BSS_REQ:
4659 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4660 break;
4661
4662 case eWNI_SME_ASSOC_CNF:
4663 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004664 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004665 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4666 pMsgBuf);
4667 break;
4668
4669 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004670 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004671 __lim_process_sme_addts_req(pMac, pMsgBuf);
4672 break;
4673
4674 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004675 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004676 __lim_process_sme_delts_req(pMac, pMsgBuf);
4677 break;
4678
4679 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004680 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004681 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4682 break;
4683
4684 case eWNI_SME_GET_STATISTICS_REQ:
4685 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4686 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4687 bufConsumed = false;
4688 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004689#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004690 case eWNI_SME_GET_TSM_STATS_REQ:
4691 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4692 bufConsumed = false;
4693 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004694#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004695 case eWNI_SME_GET_ASSOC_STAS_REQ:
4696 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4697 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304698 case eWNI_SME_SESSION_UPDATE_PARAM:
4699 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004700 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304701 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4702 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4703 bufConsumed = false;
4704 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004705 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4706 /* Update the beaconInterval */
4707 __lim_process_sme_change_bi(pMac, pMsgBuf);
4708 break;
4709
4710#ifdef QCA_HT_2040_COEX
4711 case eWNI_SME_SET_HT_2040_MODE:
4712 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4713 break;
4714#endif
4715
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004716 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4717 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4718 __lim_process_report_message(pMac, pMsg);
4719 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004720
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004721 case eWNI_SME_FT_PRE_AUTH_REQ:
4722 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4723 break;
4724 case eWNI_SME_FT_UPDATE_KEY:
4725 lim_process_ft_update_key(pMac, pMsgBuf);
4726 break;
4727
4728 case eWNI_SME_FT_AGGR_QOS_REQ:
4729 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4730 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004731
4732 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4733 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4734 break;
4735#ifdef FEATURE_WLAN_TDLS
4736 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4737 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4738 break;
4739 case eWNI_SME_TDLS_ADD_STA_REQ:
4740 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4741 break;
4742 case eWNI_SME_TDLS_DEL_STA_REQ:
4743 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4744 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004745#endif
4746 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4747 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4748 break;
4749
4750 case eWNI_SME_CHANNEL_CHANGE_REQ:
4751 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4752 break;
4753
4754 case eWNI_SME_START_BEACON_REQ:
4755 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4756 break;
4757
4758 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4759 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4760 break;
4761
4762 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4763 lim_process_update_add_ies(pMac, pMsgBuf);
4764 break;
4765
4766 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4767 lim_process_modify_add_ies(pMac, pMsgBuf);
4768 break;
4769 case eWNI_SME_SET_HW_MODE_REQ:
4770 lim_process_set_hw_mode(pMac, pMsgBuf);
4771 break;
4772 case eWNI_SME_NSS_UPDATE_REQ:
4773 lim_process_nss_update_request(pMac, pMsgBuf);
4774 break;
4775 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4776 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4777 break;
4778 case eWNI_SME_SET_IE_REQ:
4779 lim_process_set_ie_req(pMac, pMsgBuf);
4780 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304781 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4782 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
4783 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304784 case eWNI_SME_EXT_CHANGE_CHANNEL:
4785 lim_process_ext_change_channel(pMac, pMsgBuf);
4786 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08004787 case eWNI_SME_SET_ANTENNA_MODE_REQ:
4788 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
4789 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004790 case eWNI_SME_PDEV_SET_HT_VHT_IE:
4791 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07004792 break;
4793 case eWNI_SME_SET_VDEV_IES_PER_BAND:
4794 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
4795 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304796 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
4797 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
4798 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07004799 case eWNI_SME_UPDATE_CONFIG:
4800 lim_process_sme_update_config(pMac,
4801 (struct update_config *)pMsgBuf);
4802 break;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004803 case eWNI_SME_SET_ADDBA_ACCEPT:
4804 lim_process_sme_set_addba_accept(pMac,
4805 (struct sme_addba_accept *)pMsgBuf);
4806 break;
Arif Hussaineb8ba362018-03-07 19:15:13 -08004807 case eWNI_SME_UPDATE_EDCA_PROFILE:
4808 lim_process_sme_update_edca_params(pMac, pMsg->bodyval);
4809 break;
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07004810 case WNI_SME_UPDATE_MU_EDCA_PARAMS:
4811 lim_process_sme_update_mu_edca_params(pMac, pMsg->bodyval);
4812 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004813 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304814 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004815 pMsg->bodyptr = NULL;
4816 break;
4817 } /* switch (msgType) */
4818
4819 return bufConsumed;
4820} /*** end lim_process_sme_req_messages() ***/
4821
4822/**
4823 * lim_process_sme_start_beacon_req()
4824 *
4825 ***FUNCTION:
4826 * This function is called by limProcessMessageQueue(). This
4827 * function processes SME request messages from HDD or upper layer
4828 * application.
4829 *
4830 ***LOGIC:
4831 *
4832 ***ASSUMPTIONS:
4833 *
4834 ***NOTE:
4835 *
4836 * @param pMac Pointer to Global MAC structure
4837 * @param msgType Indicates the SME message type
4838 * @param *pMsgBuf A pointer to the SME message buffer
4839 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4840 * false - if pMsgBuf is not to be freed.
4841 */
4842static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
4843{
4844 tpSirStartBeaconIndication pBeaconStartInd;
4845 tpPESession psessionEntry;
4846 uint8_t sessionId; /* PE sessionID */
4847
4848 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004849 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004850 return;
4851 }
4852
4853 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
4854 psessionEntry = pe_find_session_by_bssid(pMac,
4855 pBeaconStartInd->bssid,
4856 &sessionId);
4857 if (psessionEntry == NULL) {
4858 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004859 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004860 return;
4861 }
4862
4863 if (pBeaconStartInd->beaconStartStatus == true) {
4864 /*
4865 * Currently this Indication comes from SAP
4866 * to start Beacon Tx on a DFS channel
4867 * since beaconing has to be done on DFS
4868 * channel only after CAC WAIT is completed.
4869 * On a DFS Channel LIM does not start beacon
4870 * Tx right after the WMA_ADD_BSS_RSP.
4871 */
4872 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05304873 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004874 FL("Start Beacon with ssid %s Ch %d"),
4875 psessionEntry->ssId.ssId,
4876 psessionEntry->currentOperChannel);
4877 lim_send_beacon_ind(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08004878 lim_enable_obss_detection_config(pMac, psessionEntry);
Arif Hussain05fb4872018-01-03 16:02:55 -08004879 lim_send_obss_color_collision_cfg(pMac, psessionEntry,
4880 OBSS_COLOR_COLLISION_DETECTION);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004881 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004882 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004883 return;
4884 }
4885}
4886
4887/**
4888 * lim_process_sme_channel_change_request() - process sme ch change req
4889 *
4890 * @mac_ctx: Pointer to Global MAC structure
4891 * @msg_buf: pointer to the SME message buffer
4892 *
4893 * This function is called to process SME_CHANNEL_CHANGE_REQ message
4894 *
4895 * Return: None
4896 */
4897static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
4898 uint32_t *msg_buf)
4899{
4900 tpSirChanChangeRequest ch_change_req;
4901 tpPESession session_entry;
4902 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07004903 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004904 uint32_t val = 0;
4905
4906 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004907 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004908 return;
4909 }
4910 ch_change_req = (tpSirChanChangeRequest)msg_buf;
4911
4912 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
4913 ch_change_req->targetChannel);
4914
4915 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
4916 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004917 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004918 return;
4919 }
4920
4921 session_entry = pe_find_session_by_bssid(mac_ctx,
4922 ch_change_req->bssid, &session_id);
4923 if (session_entry == NULL) {
4924 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004925 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004926 return;
4927 }
4928
Manjunathappa Prakash34fda792018-02-07 18:23:42 -08004929 if ((session_entry->currentOperChannel ==
4930 ch_change_req->targetChannel) &&
4931 (session_entry->ch_width == ch_change_req->ch_width)) {
4932 pe_err("Target channel and mode is same as current channel and mode channel %d and mode %d",
4933 session_entry->currentOperChannel, session_entry->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004934 return;
4935 }
4936
4937 if (LIM_IS_AP_ROLE(session_entry))
4938 session_entry->channelChangeReasonCode =
4939 LIM_SWITCH_CHANNEL_SAP_DFS;
4940 else
4941 session_entry->channelChangeReasonCode =
4942 LIM_SWITCH_CHANNEL_OPERATION;
4943
Bala Venkateshb39ed152017-12-26 19:35:27 +05304944 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d, nw_type %d, dot11mode %d",
4945 session_entry->currentOperChannel,
4946 ch_change_req->targetChannel,
4947 ch_change_req->ch_width,
4948 ch_change_req->nw_type,
4949 ch_change_req->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004950
4951 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004952 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004953 session_entry->ch_center_freq_seg0 =
4954 ch_change_req->center_freq_seg_0;
4955 session_entry->ch_center_freq_seg1 =
4956 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004957 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004958 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004959 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004960 session_entry->htRecommendedTxWidthSet =
4961 session_entry->htSupportedChannelWidthSet;
4962 session_entry->currentOperChannel =
4963 ch_change_req->targetChannel;
4964 session_entry->limRFBand =
4965 lim_get_rf_band(session_entry->currentOperChannel);
Vignesh Viswanathan153ae932018-04-11 14:24:13 +05304966
4967 /* Update the global beacon filter */
4968 lim_update_bcn_probe_filter(mac_ctx, session_entry);
4969
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004970 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08004971 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004972 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004973 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004974 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004975 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004976 }
4977
4978 session_entry->lim11hEnable = val;
4979 session_entry->dot11mode = ch_change_req->dot11mode;
Bala Venkateshb39ed152017-12-26 19:35:27 +05304980 session_entry->nwType = ch_change_req->nw_type;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304981 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004982 &ch_change_req->operational_rateset,
4983 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304984 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004985 &ch_change_req->extended_rateset,
4986 sizeof(session_entry->extRateSet));
4987 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
4988 session_entry->ch_center_freq_seg0,
4989 session_entry->ch_center_freq_seg1,
4990 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07004991 max_tx_pwr, session_entry->peSessionId,
4992 ch_change_req->cac_duration_ms,
4993 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004994}
4995
4996/******************************************************************************
4997* lim_start_bss_update_add_ie_buffer()
4998*
4999***FUNCTION:
5000* This function checks the src buffer and its length and then malloc for
5001* dst buffer update the same
5002*
5003***LOGIC:
5004*
5005***ASSUMPTIONS:
5006*
5007***NOTE:
5008*
5009* @param pMac Pointer to Global MAC structure
5010* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5011* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5012* @param *pSrcData_buff A pointer of uint8_t src buffer
5013* @param srcDataLen src buffer length
5014******************************************************************************/
5015
5016static void
5017lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5018 uint8_t **pDstData_buff,
5019 uint16_t *pDstDataLen,
5020 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5021{
5022
5023 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5024 *pDstDataLen = srcDataLen;
5025
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305026 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005027
5028 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005029 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005030 return;
5031 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305032 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005033 } else {
5034 *pDstData_buff = NULL;
5035 *pDstDataLen = 0;
5036 }
5037}
5038
5039/******************************************************************************
5040* lim_update_add_ie_buffer()
5041*
5042***FUNCTION:
5043* This function checks the src buffer and length if src buffer length more
5044* than dst buffer length then free the dst buffer and malloc for the new src
5045* length, and update the dst buffer and length. But if dst buffer is bigger
5046* than src buffer length then it just update the dst buffer and length
5047*
5048***LOGIC:
5049*
5050***ASSUMPTIONS:
5051*
5052***NOTE:
5053*
5054* @param pMac Pointer to Global MAC structure
5055* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5056* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5057* @param *pSrcData_buff A pointer of uint8_t src buffer
5058* @param srcDataLen src buffer length
5059******************************************************************************/
5060
5061static void
5062lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5063 uint8_t **pDstData_buff,
5064 uint16_t *pDstDataLen,
5065 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5066{
5067
5068 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005069 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005070 return;
5071 }
5072
5073 if (srcDataLen > *pDstDataLen) {
5074 *pDstDataLen = srcDataLen;
5075 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305076 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005077 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305078 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005079
5080 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005081 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005082 *pDstDataLen = 0;
5083 return;
5084 }
5085 }
5086
5087 /* copy the content of buffer into dst buffer
5088 */
5089 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305090 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005091
5092}
5093
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005094/**
5095 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5096 * @pMac : Pointer to Global MAC structure
5097 * @pDstData_buff : A pointer to pointer of dst buffer
5098 * @pDstDataLen : A pointer to pointer of dst buffer length
5099 * @pModifyIE : A pointer to tSirModifyIE
5100 *
5101 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5102 *
5103 * Return:
5104 * True or false depending upon whether IE is updated or not
5105 */
5106static bool
5107lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5108 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5109{
Hong Shi1553d692016-09-28 12:16:19 +08005110 int32_t oui_length;
5111 uint8_t *ibss_ie = NULL;
5112 uint8_t *vendor_ie;
5113#define MAC_VENDOR_OUI "\x00\x16\x32"
5114#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005115
5116 ibss_ie = pModifyIE->pIEBuffer;
5117 oui_length = pModifyIE->oui_length;
5118
5119 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005120 pe_err("Invalid set IBSS vendor IE command length %d",
5121 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005122 return false;
5123 }
5124
Hong Shi1553d692016-09-28 12:16:19 +08005125 /*
5126 * Why replace only beacon OUI data here:
5127 * 1. other ie (such as wpa) shall not be overwritten here.
5128 * 2. per spec, beacon oui ie might be set twice and original one
5129 * shall be updated.
5130 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005131 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005132 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5133 if (vendor_ie) {
5134 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5135 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5136 pModifyIE->ieBufferlength);
5137 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005138 uint16_t new_length;
5139 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005140
Naveen Rawat668dee32017-09-29 14:39:40 -07005141 /*
5142 * check for uint16 overflow before using sum of two numbers as
5143 * length of size to malloc
5144 */
5145 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5146 pe_err("U16 overflow due to %d + %d",
5147 pModifyIE->ieBufferlength, *pDstDataLen);
5148 return false;
5149 }
5150
5151 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5152 new_ptr = qdf_mem_malloc(new_length);
Hong Shi1553d692016-09-28 12:16:19 +08005153 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005154 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005155 return false;
5156 }
5157 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5158 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5159 pModifyIE->ieBufferlength);
5160 qdf_mem_free(*pDstData_buff);
5161 *pDstDataLen = new_length;
5162 *pDstData_buff = new_ptr;
5163 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005164 return true;
5165}
5166
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005167/*
5168* lim_process_modify_add_ies() - process modify additional IE req.
5169*
5170* @mac_ctx: Pointer to Global MAC structure
5171* @msg_buf: pointer to the SME message buffer
5172*
5173* This function update the PE buffers for additional IEs.
5174*
5175* Return: None
5176*/
5177static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5178 uint32_t *msg_buf)
5179{
5180 tpSirModifyIEsInd modify_add_ies;
5181 tpPESession session_entry;
5182 uint8_t session_id;
5183 bool ret = false;
5184 tSirAddIeParams *add_ie_params;
5185
5186 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005187 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005188 return;
5189 }
5190
5191 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5192 /* Incoming message has smeSession, use BSSID to find PE session */
5193 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005194 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005195
5196 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005197 pe_err("Session not found for given bssid"
5198 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005199 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005200 goto end;
5201 }
5202 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5203 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5204 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005205 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005206 modify_add_ies->modifyIE.pIEBuffer,
5207 modify_add_ies->modifyIE.ieBufferlength,
5208 modify_add_ies->modifyIE.ieID,
5209 modify_add_ies->modifyIE.ieIDLen,
5210 modify_add_ies->updateType);
5211 goto end;
5212 }
5213 add_ie_params = &session_entry->addIeParams;
5214 switch (modify_add_ies->updateType) {
5215 case eUPDATE_IE_PROBE_RESP:
5216 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005217 if (LIM_IS_IBSS_ROLE(session_entry)) {
5218 lim_update_ibss_prop_add_ies(mac_ctx,
5219 &add_ie_params->probeRespData_buff,
5220 &add_ie_params->probeRespDataLen,
5221 &modify_add_ies->modifyIE);
5222 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005223 break;
5224 case eUPDATE_IE_ASSOC_RESP:
5225 /* assoc resp IE */
5226 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305227 QDF_TRACE(QDF_MODULE_ID_PE,
5228 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005229 "assoc resp add ie not present %d"),
5230 add_ie_params->assocRespDataLen);
5231 }
5232 /* search through the buffer and modify the IE */
5233 break;
5234 case eUPDATE_IE_PROBE_BCN:
5235 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005236 if (LIM_IS_IBSS_ROLE(session_entry)) {
5237 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5238 &add_ie_params->probeRespBCNData_buff,
5239 &add_ie_params->probeRespBCNDataLen,
5240 &modify_add_ies->modifyIE);
5241 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005242 if (ret == true && modify_add_ies->modifyIE.notify) {
5243 lim_handle_param_update(mac_ctx,
5244 modify_add_ies->updateType);
5245 }
5246 break;
5247 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005248 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005249 modify_add_ies->updateType);
5250 break;
5251 }
5252end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305253 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005254 modify_add_ies->modifyIE.pIEBuffer = NULL;
5255}
5256
5257/*
5258* lim_process_update_add_ies() - process additional IE update req
5259*
5260* @mac_ctx: Pointer to Global MAC structure
5261* @msg_buf: pointer to the SME message buffer
5262*
5263* This function update the PE buffers for additional IEs.
5264*
5265* Return: None
5266*/
5267static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5268 uint32_t *msg_buf)
5269{
5270 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5271 uint8_t session_id;
5272 tpPESession session_entry;
5273 tSirAddIeParams *addn_ie;
5274 uint16_t new_length = 0;
5275 uint8_t *new_ptr = NULL;
5276 tSirUpdateIE *update_ie;
5277
5278 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005279 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005280 return;
5281 }
5282 update_ie = &update_add_ies->updateIE;
5283 /* incoming message has smeSession, use BSSID to find PE session */
5284 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005285 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005286
5287 if (NULL == session_entry) {
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05305288 pe_debug("Session not found for given bssid"
5289 MAC_ADDRESS_STR,
5290 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005291 goto end;
5292 }
5293 addn_ie = &session_entry->addIeParams;
5294 /* if len is 0, upper layer requested freeing of buffer */
5295 if (0 == update_ie->ieBufferlength) {
5296 switch (update_add_ies->updateType) {
5297 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305298 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005299 addn_ie->probeRespData_buff = NULL;
5300 addn_ie->probeRespDataLen = 0;
5301 break;
5302 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305303 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005304 addn_ie->assocRespData_buff = NULL;
5305 addn_ie->assocRespDataLen = 0;
5306 break;
5307 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305308 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005309 addn_ie->probeRespBCNData_buff = NULL;
5310 addn_ie->probeRespBCNDataLen = 0;
5311
5312 if (update_ie->notify)
5313 lim_handle_param_update(mac_ctx,
5314 update_add_ies->updateType);
5315 break;
5316 default:
5317 break;
5318 }
5319 return;
5320 }
5321 switch (update_add_ies->updateType) {
5322 case eUPDATE_IE_PROBE_RESP:
5323 if (update_ie->append) {
5324 /*
5325 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005326 * with combined length.
5327 * Multiple back to back append commands
5328 * can lead to a huge length.So, check
5329 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005330 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005331 if (addn_ie->probeRespDataLen >
5332 (USHRT_MAX - update_ie->ieBufferlength)) {
5333 pe_err("IE Length overflow, curr:%d, new:%d",
5334 addn_ie->probeRespDataLen,
5335 update_ie->ieBufferlength);
5336 goto end;
5337 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005338 new_length = update_ie->ieBufferlength +
5339 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305340 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005341 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005342 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005343 goto end;
5344 }
5345 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305346 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005347 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305348 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005349 update_ie->pAdditionIEBuffer,
5350 update_ie->ieBufferlength);
5351 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305352 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005353 /* adjust length accordingly */
5354 addn_ie->probeRespDataLen = new_length;
5355 /* save refernece of local buffer in PE session */
5356 addn_ie->probeRespData_buff = new_ptr;
5357 goto end;
5358 }
5359 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5360 &addn_ie->probeRespDataLen,
5361 update_ie->pAdditionIEBuffer,
5362 update_ie->ieBufferlength);
5363 break;
5364 case eUPDATE_IE_ASSOC_RESP:
5365 /* assoc resp IE */
5366 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5367 &addn_ie->assocRespDataLen,
5368 update_ie->pAdditionIEBuffer,
5369 update_ie->ieBufferlength);
5370 break;
5371 case eUPDATE_IE_PROBE_BCN:
5372 /* probe resp Bcn IE */
5373 lim_update_add_ie_buffer(mac_ctx,
5374 &addn_ie->probeRespBCNData_buff,
5375 &addn_ie->probeRespBCNDataLen,
5376 update_ie->pAdditionIEBuffer,
5377 update_ie->ieBufferlength);
5378 if (update_ie->notify)
5379 lim_handle_param_update(mac_ctx,
5380 update_add_ies->updateType);
5381 break;
5382 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005383 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005384 break;
5385 }
5386end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305387 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005388 update_ie->pAdditionIEBuffer = NULL;
5389}
5390
5391/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305392 * send_extended_chan_switch_action_frame()- function to send ECSA
5393 * action frame for each sta connected to SAP/GO and AP in case of
5394 * STA .
5395 * @mac_ctx: pointer to global mac structure
5396 * @new_channel: new channel to switch to.
5397 * @ch_bandwidth: BW of channel to calculate op_class
5398 * @session_entry: pe session
5399 *
5400 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5401 *
5402 * Return: void
5403 */
5404
5405static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5406 uint16_t new_channel, uint8_t ch_bandwidth,
5407 tpPESession session_entry)
5408{
5409 uint16_t op_class;
5410 uint8_t switch_mode = 0, i;
5411 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005412 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305413
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005414 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305415 mac_ctx->scan.countryCodeCurrent,
5416 new_channel,
5417 ch_bandwidth);
5418
5419 if (LIM_IS_AP_ROLE(session_entry) &&
5420 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005421 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305422
gaoleze2920bd2017-03-21 17:38:42 +08005423 switch_count = session_entry->gLimChannelSwitch.switchCount;
5424
Abhishek Singh518323d2015-10-19 17:42:01 +05305425 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005426 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305427 psta =
5428 session_entry->dph.dphHashTable.pDphNodeArray + i;
5429 if (psta && psta->added)
5430 lim_send_extended_chan_switch_action_frame(
5431 mac_ctx,
5432 psta->staAddr,
5433 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005434 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305435 }
5436 } else if (LIM_IS_STA_ROLE(session_entry)) {
5437 lim_send_extended_chan_switch_action_frame(mac_ctx,
5438 session_entry->bssId,
5439 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005440 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305441 }
5442
5443}
5444
gaolez76d2a162017-03-21 19:23:58 +08005445void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5446 uint16_t new_channel,
5447 uint8_t ch_bandwidth,
5448 tpPESession session_entry)
5449{
5450 uint16_t op_class;
5451 uint8_t switch_mode = 0, i;
5452 uint8_t switch_count;
5453 tpDphHashNode psta;
5454 tpDphHashNode dph_node_array_ptr;
5455
5456 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5457
5458 op_class = wlan_reg_dmn_get_opclass_from_channel(
5459 mac_ctx->scan.countryCodeCurrent,
5460 new_channel, ch_bandwidth);
5461
5462 if (LIM_IS_AP_ROLE(session_entry) &&
5463 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5464 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5465
5466 switch_count = session_entry->gLimChannelSwitch.switchCount;
5467
5468 if (LIM_IS_AP_ROLE(session_entry)) {
5469 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5470 psta = dph_node_array_ptr + i;
5471 if (!(psta && psta->added))
5472 continue;
5473 if (session_entry->lim_non_ecsa_cap_num == 0)
5474 lim_send_extended_chan_switch_action_frame
5475 (mac_ctx, psta->staAddr, switch_mode,
5476 op_class, new_channel, switch_count,
5477 session_entry);
5478 else
5479 lim_send_channel_switch_mgmt_frame
5480 (mac_ctx, psta->staAddr, switch_mode,
5481 new_channel, switch_count,
5482 session_entry);
5483 }
5484 } else if (LIM_IS_STA_ROLE(session_entry)) {
5485 lim_send_extended_chan_switch_action_frame
5486 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5487 new_channel, switch_count, session_entry);
5488 }
5489}
5490
5491/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005492 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5493 *
5494 * @mac_ctx: Pointer to Global MAC structure
5495 * @msg_buf: pointer to the SME message buffer
5496 *
5497 * This function processes SME request messages from HDD or upper layer
5498 * application.
5499 *
5500 * Return: None
5501 */
5502static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5503 uint32_t *msg_buf)
5504{
5505 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5506 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005507 uint8_t session_id;
5508 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005509 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005510
5511 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005512 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005513 return;
5514 }
5515
5516 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5517 session_entry = pe_find_session_by_bssid(mac_ctx,
5518 dfs_csa_ie_req->bssid, &session_id);
5519 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005520 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005521 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5522 return;
5523 }
5524
5525 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005526 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005527 GET_LIM_SYSTEM_ROLE(session_entry));
5528 return;
5529 }
5530
5531 /* target channel */
5532 session_entry->gLimChannelSwitch.primaryChannel =
5533 dfs_csa_ie_req->targetChannel;
5534
5535 /* Channel switch announcement needs to be included in beacon */
5536 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005537 session_entry->gLimChannelSwitch.switchCount =
5538 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005539 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005540 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305541 session_entry->gLimChannelSwitch.sec_ch_offset =
5542 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005543 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005544 session_entry->gLimChannelSwitch.switchMode =
5545 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005546
5547 /*
5548 * Validate if SAP is operating HT or VHT mode and set the Channel
5549 * Switch Wrapper element with the Wide Band Switch subelement.
5550 */
5551 if (true != session_entry->vhtCapability)
5552 goto skip_vht;
5553
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005554 /* Now encode the Wider Ch BW element depending on the ch width */
5555 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005556 switch (dfs_csa_ie_req->ch_params.ch_width) {
5557 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005558 /*
5559 * Wide channel BW sublement in channel wrapper element is not
5560 * required in case of 20 Mhz operation. Currently It is set
5561 * only set in case of 40/80 Mhz Operation.
5562 */
5563 session_entry->dfsIncludeChanWrapperIe = false;
5564 wider_bw_ch_switch->newChanWidth =
5565 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5566 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005567 case CH_WIDTH_40MHZ:
5568 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005569 wider_bw_ch_switch->newChanWidth =
5570 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5571 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005572 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005573 session_entry->dfsIncludeChanWrapperIe = true;
5574 wider_bw_ch_switch->newChanWidth =
5575 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5576 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005577 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005578 session_entry->dfsIncludeChanWrapperIe = true;
5579 wider_bw_ch_switch->newChanWidth =
5580 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5581 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005582 case CH_WIDTH_80P80MHZ:
5583 session_entry->dfsIncludeChanWrapperIe = true;
5584 wider_bw_ch_switch->newChanWidth =
5585 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005586 /*
5587 * This is not applicable for 20/40/80 Mhz.
5588 * Only used when we support 80+80 Mhz operation.
5589 * In case of 80+80 Mhz, this parameter indicates
5590 * center channel frequency index of 80 Mhz channel of
5591 * frequency segment 1.
5592 */
5593 wider_bw_ch_switch->newCenterChanFreq1 =
5594 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005595 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005596 default:
5597 session_entry->dfsIncludeChanWrapperIe = false;
5598 /*
5599 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5600 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5601 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005602 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005603 break;
5604 }
5605 /* Fetch the center channel based on the channel width */
5606 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005607 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005608skip_vht:
5609 /* Send CSA IE request from here */
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05305610 lim_send_dfs_chan_sw_ie_update(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305611
5612 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5613 ch_offset = BW80;
5614 else
5615 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5616
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005617 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305618 session_entry->gLimChannelSwitch.switchCount,
5619 session_entry->gLimChannelSwitch.primaryChannel,
5620 session_entry->gLimChannelSwitch.ch_width,
5621 session_entry->dfsIncludeChanWrapperIe,
5622 ch_offset);
5623
gaolez76d2a162017-03-21 19:23:58 +08005624 /* Send ECSA/CSA Action frame after updating the beacon */
5625 if (CHAN_HOP_ALL_BANDS_ENABLE)
5626 lim_send_chan_switch_action_frame(mac_ctx,
5627 session_entry->gLimChannelSwitch.primaryChannel,
5628 ch_offset, session_entry);
5629 else
5630 send_extended_chan_switch_action_frame(mac_ctx,
5631 session_entry->gLimChannelSwitch.primaryChannel,
5632 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005633}
5634
5635/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305636 * lim_process_ext_change_channel()- function to send ECSA
5637 * action frame for STA/CLI .
5638 * @mac_ctx: pointer to global mac structure
5639 * @msg: params from sme for new channel.
5640 *
5641 * This function is called to send ECSA frame for STA/CLI.
5642 *
5643 * Return: void
5644 */
5645
5646static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5647 uint32_t *msg)
5648{
5649 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5650 (struct sir_sme_ext_cng_chan_req *) msg;
5651 tpPESession session_entry = NULL;
5652
5653 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005654 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305655 return;
5656 }
5657 session_entry =
5658 pe_find_session_by_sme_session_id(mac_ctx,
5659 ext_chng_channel->session_id);
5660 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005661 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305662 ext_chng_channel->session_id);
5663 return;
5664 }
5665 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005666 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305667 return;
5668 }
5669 send_extended_chan_switch_action_frame(mac_ctx,
5670 ext_chng_channel->new_channel,
5671 0, session_entry);
5672}
5673
5674/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005675 * lim_process_nss_update_request() - process sme nss update req
5676 *
5677 * @mac_ctx: Pointer to Global MAC structure
5678 * @msg_buf: pointer to the SME message buffer
5679 *
5680 * This function processes SME request messages from HDD or upper layer
5681 * application.
5682 *
5683 * Return: None
5684 */
5685static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5686 uint32_t *msg_buf)
5687{
5688 struct sir_nss_update_request *nss_update_req_ptr;
5689 tpPESession session_entry = NULL;
5690
5691 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005692 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005693 return;
5694 }
5695
5696 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305697 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005698 nss_update_req_ptr->vdev_id);
5699 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005700 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005701 nss_update_req_ptr->vdev_id);
5702 return;
5703 }
5704
5705 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005706 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005707 GET_LIM_SYSTEM_ROLE(session_entry));
5708 return;
5709 }
5710
5711 /* populate nss field in the beacon */
5712 session_entry->gLimOperatingMode.present = 1;
5713 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05305714 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
5715
5716 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
5717 (session_entry->ch_width > CH_WIDTH_80MHZ))
5718 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
5719
5720 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
5721
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005722 /* Send nss update request from here */
5723 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005724 QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005725 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005726 return;
5727 }
5728
5729 lim_send_beacon_ind(mac_ctx, session_entry);
5730}
5731
5732/**
5733 * lim_process_set_ie_req() - process sme set IE request
5734 *
5735 * @mac_ctx: Pointer to Global MAC structure
5736 * @msg_buf: pointer to the SME message buffer
5737 *
5738 * This function processes SME request messages from HDD or upper layer
5739 * application.
5740 *
5741 * Return: None
5742 */
5743static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5744{
5745 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305746 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005747
5748 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005749 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005750 return;
5751 }
5752
5753 msg = (struct send_extcap_ie *)msg_buf;
5754 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305755 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005756 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005757
5758}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005759
5760#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Arif Hussain05fb4872018-01-03 16:02:55 -08005761
5762/**
5763 * obss_color_collision_process_color_disable() - Disable bss color
5764 * @mac_ctx: Pointer to Global MAC structure
5765 * @session: pointer to session
5766 *
5767 * This function will disbale bss color.
5768 *
5769 * Return: None
5770 */
5771static void obss_color_collision_process_color_disable(tpAniSirGlobal mac_ctx,
5772 tpPESession session)
5773{
5774 tUpdateBeaconParams beacon_params;
5775
5776 if (!session) {
5777 pe_err("Invalid session");
5778 return;
5779 }
5780
5781 if (session->valid && !LIM_IS_AP_ROLE(session)) {
5782 pe_err("Invalid SystemRole %d",
5783 GET_LIM_SYSTEM_ROLE(session));
5784 return;
5785 }
5786
5787 if (session->bss_color_changing == 1) {
5788 pe_warn("%d: color change in progress", session->smeSessionId);
5789 /* Continue color collision detection */
5790 lim_send_obss_color_collision_cfg(mac_ctx, session,
5791 OBSS_COLOR_COLLISION_DETECTION);
5792 return;
5793 }
5794
5795 if (session->he_op.bss_col_disabled == 1) {
5796 pe_warn("%d: bss color already disabled",
5797 session->smeSessionId);
5798 /* Continue free color detection */
5799 lim_send_obss_color_collision_cfg(mac_ctx, session,
5800 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5801 return;
5802 }
5803
5804 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5805 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5806 session->he_op.bss_col_disabled = 1;
Arif Hussain05fb4872018-01-03 16:02:55 -08005807 beacon_params.bss_color_disabled = 1;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005808 beacon_params.bss_color = session->he_op.bss_color;
Arif Hussain05fb4872018-01-03 16:02:55 -08005809
5810 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005811 QDF_STATUS_SUCCESS) {
Arif Hussain05fb4872018-01-03 16:02:55 -08005812 pe_err("Unable to set op mode IE in beacon");
5813 return;
5814 }
5815
5816 lim_send_beacon_params(mac_ctx, &beacon_params, session);
5817 lim_send_obss_color_collision_cfg(mac_ctx, session,
5818 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5819}
5820
5821/**
5822 * obss_color_collision_process_color_change() - Process bss color change
5823 * @mac_ctx: Pointer to Global MAC structure
5824 * @session: pointer to session
5825 * @obss_color_info: obss color collision/free slot indication info
5826 *
5827 * This function selects new color ib case of bss color collision.
5828 *
5829 * Return: None
5830 */
5831static void obss_color_collision_process_color_change(tpAniSirGlobal mac_ctx,
5832 tpPESession session,
5833 struct wmi_obss_color_collision_info *obss_color_info)
5834{
5835 int i, num_bss_color = 0;
5836 uint32_t bss_color_bitmap;
5837 uint8_t bss_color_index_array[MAX_BSS_COLOR_VALUE];
5838 uint32_t rand_byte = 0;
5839 struct sir_set_he_bss_color he_bss_color;
5840 bool is_color_collision = false;
5841
5842
5843 if (session->bss_color_changing == 1) {
5844 pe_err("%d: color change in progress", session->smeSessionId);
5845 return;
5846 }
5847
5848 if (!session->he_op.bss_col_disabled) {
5849 if (session->he_op.bss_color < 32)
5850 is_color_collision = (obss_color_info->
5851 obss_color_bitmap_bit0to31 >>
5852 session->he_op.bss_color) & 0x01;
5853 else
5854 is_color_collision = (obss_color_info->
5855 obss_color_bitmap_bit32to63 >>
5856 (session->he_op.bss_color -
Arif Hussain9e8c5612018-04-12 16:35:48 -07005857 32)) & 0x01;
Arif Hussain05fb4872018-01-03 16:02:55 -08005858 if (!is_color_collision) {
5859 pe_err("%d: color collision not found, curr_color: %d",
5860 session->smeSessionId,
5861 session->he_op.bss_color);
5862 return;
5863 }
5864 }
5865
5866 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit0to31;
5867
5868 /* Skip color zero */
5869 bss_color_bitmap = bss_color_bitmap >> 1;
5870 for (i = 0; (i < 31) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5871 if (!(bss_color_bitmap & 0x01)) {
5872 bss_color_index_array[num_bss_color] = i + 1;
5873 num_bss_color++;
5874 }
5875 bss_color_bitmap = bss_color_bitmap >> 1;
5876 }
5877
5878 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit32to63;
5879 for (i = 0; (i < 32) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5880 if (!(bss_color_bitmap & 0x01)) {
5881 bss_color_index_array[num_bss_color] = i + 32;
5882 num_bss_color++;
5883 }
5884 bss_color_bitmap = bss_color_bitmap >> 1;
5885 }
5886
5887 if (num_bss_color) {
5888 qdf_get_random_bytes((void *) &rand_byte, 1);
5889 i = (rand_byte + qdf_mc_timer_get_system_ticks()) %
5890 num_bss_color;
5891 pe_debug("New bss color = %d", bss_color_index_array[i]);
5892 he_bss_color.session_id = obss_color_info->vdev_id;
5893 he_bss_color.bss_color = bss_color_index_array[i];
5894 lim_process_set_he_bss_color(mac_ctx,
5895 (uint32_t *)&he_bss_color);
5896 } else {
5897 pe_err("Unable to find bss color from bitmasp");
5898 if (obss_color_info->evt_type ==
5899 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY &&
5900 session->obss_color_collision_dec_evt ==
5901 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
5902 /* In dot11BSSColorCollisionAPPeriod and
5903 * timer expired, time to disable bss color.
5904 */
5905 obss_color_collision_process_color_disable(mac_ctx,
5906 session);
5907 else
5908 /*
5909 * Enter dot11BSSColorCollisionAPPeriod period.
5910 */
5911 lim_send_obss_color_collision_cfg(mac_ctx, session,
5912 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY);
5913 }
5914}
5915
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005916void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5917{
5918 struct sir_set_he_bss_color *bss_color;
5919 tpPESession session_entry = NULL;
5920 tUpdateBeaconParams beacon_params;
5921
5922 if (!msg_buf) {
5923 pe_err("Buffer is Pointing to NULL");
5924 return;
5925 }
5926
5927 bss_color = (struct sir_set_he_bss_color *)msg_buf;
5928 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5929 bss_color->session_id);
5930 if (!session_entry) {
5931 pe_err("Session not found for given session_id %d",
5932 bss_color->session_id);
5933 return;
5934 }
5935
5936 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5937 pe_err("Invalid SystemRole %d",
5938 GET_LIM_SYSTEM_ROLE(session_entry));
5939 return;
5940 }
5941
5942 if (bss_color->bss_color == session_entry->he_op.bss_color) {
5943 pe_err("No change in BSS color, current BSS color %d",
5944 bss_color->bss_color);
5945 return;
5946 }
5947 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5948 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5949 session_entry->he_op.bss_col_disabled = 1;
5950 session_entry->he_bss_color_change.countdown =
5951 BSS_COLOR_SWITCH_COUNTDOWN;
5952 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005953 beacon_params.bss_color_disabled = 1;
5954 beacon_params.bss_color = session_entry->he_op.bss_color;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005955 session_entry->bss_color_changing = 1;
5956
5957 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005958 QDF_STATUS_SUCCESS) {
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005959 pe_err("Unable to set op mode IE in beacon");
5960 return;
5961 }
5962
5963 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
Arif Hussain05fb4872018-01-03 16:02:55 -08005964 lim_send_obss_color_collision_cfg(mac_ctx, session_entry,
5965 OBSS_COLOR_COLLISION_DETECTION_DISABLE);
5966}
5967
5968void lim_send_obss_color_collision_cfg(tpAniSirGlobal mac_ctx,
5969 tpPESession session,
5970 enum wmi_obss_color_collision_evt_type
5971 event_type)
5972{
5973 struct wmi_obss_color_collision_cfg_param *cfg_param;
5974 struct scheduler_msg msg = {0};
5975
5976 if (!session) {
5977 pe_err("Invalid session");
5978 return;
5979 }
5980
5981 if (!session->he_capable ||
5982 !session->is_session_obss_color_collision_det_enabled) {
5983 pe_debug("%d: obss color det not enabled, he_cap:%d, sup:%d:%d",
5984 session->smeSessionId, session->he_capable,
5985 session->is_session_obss_color_collision_det_enabled,
5986 mac_ctx->lim.global_obss_color_collision_det_offload);
5987 return;
5988 }
5989
5990 cfg_param = qdf_mem_malloc(sizeof(*cfg_param));
5991 if (!cfg_param) {
5992 pe_err("Failed to allocate memory");
5993 return;
5994 }
5995
5996 pe_debug("%d: sending event:%d", session->smeSessionId, event_type);
5997 qdf_mem_zero(cfg_param, sizeof(*cfg_param));
5998 cfg_param->vdev_id = session->smeSessionId;
5999 cfg_param->evt_type = event_type;
6000 if (LIM_IS_AP_ROLE(session))
6001 cfg_param->detection_period_ms =
6002 OBSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS;
6003 else
6004 cfg_param->detection_period_ms =
6005 OBSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS;
6006
6007 cfg_param->scan_period_ms = OBSS_COLOR_COLLISION_SCAN_PERIOD_MS;
6008 if (event_type == OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6009 cfg_param->free_slot_expiry_time_ms =
6010 OBSS_COLOR_COLLISION_FREE_SLOT_EXPIRY_MS;
6011
6012 msg.type = WMA_OBSS_COLOR_COLLISION_REQ;
6013 msg.bodyptr = cfg_param;
6014 msg.reserved = 0;
6015
6016 if (QDF_IS_STATUS_ERROR(scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
6017 pe_err("Failed to post WMA_OBSS_COLOR_COLLISION_REQ to WMA");
6018 qdf_mem_free(cfg_param);
6019 } else {
6020 session->obss_color_collision_dec_evt = event_type;
6021 }
6022}
6023
6024void lim_process_obss_color_collision_info(tpAniSirGlobal mac_ctx,
6025 uint32_t *msg_buf)
6026{
6027 struct wmi_obss_color_collision_info *obss_color_info;
6028 tpPESession session;
6029
6030 if (!msg_buf) {
6031 pe_err("Buffer is Pointing to NULL");
6032 return;
6033 }
6034
6035 obss_color_info = (struct wmi_obss_color_collision_info *)msg_buf;
6036 session = pe_find_session_by_sme_session_id(mac_ctx,
6037 obss_color_info->vdev_id);
6038 if (!session) {
6039 pe_err("Session not found for given session_id %d",
6040 obss_color_info->vdev_id);
6041 return;
6042 }
6043
6044 pe_debug("vdev_id:%d, evt:%d:%d, 0to31:0x%x, 32to63:0x%x, cap:%d:%d:%d",
6045 obss_color_info->vdev_id,
6046 obss_color_info->evt_type,
6047 session->obss_color_collision_dec_evt,
6048 obss_color_info->obss_color_bitmap_bit0to31,
6049 obss_color_info->obss_color_bitmap_bit32to63,
6050 session->he_capable,
6051 session->is_session_obss_color_collision_det_enabled,
6052 mac_ctx->lim.global_obss_color_collision_det_offload);
6053
6054 if (!session->he_capable ||
6055 !session->is_session_obss_color_collision_det_enabled) {
6056 return;
6057 }
6058
6059 switch (obss_color_info->evt_type) {
6060 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
6061 pe_err("%d: FW disabled obss color det. he_cap:%d, sup:%d:%d",
6062 session->smeSessionId, session->he_capable,
6063 session->is_session_obss_color_collision_det_enabled,
6064 mac_ctx->lim.global_obss_color_collision_det_offload);
6065 session->is_session_obss_color_collision_det_enabled = false;
6066 return;
6067 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
6068 case OBSS_COLOR_COLLISION_DETECTION:
6069 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
6070 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6071 pe_debug("Invalid System Role %d",
6072 GET_LIM_SYSTEM_ROLE(session));
6073 return;
6074 }
6075
6076 if (session->obss_color_collision_dec_evt !=
6077 obss_color_info->evt_type) {
6078 pe_debug("%d: Wrong event: %d, skiping",
6079 obss_color_info->vdev_id,
6080 obss_color_info->evt_type);
6081 return;
6082 }
6083 obss_color_collision_process_color_change(mac_ctx, session,
6084 obss_color_info);
6085 break;
6086 default:
6087 pe_err("%d: Invalid event type %d",
6088 obss_color_info->vdev_id, obss_color_info->evt_type);
6089 return;
6090 }
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006091}
6092#endif