blob: 57a5f3094de5d21df398a013a51a215d020f83d9 [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/**
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530535 * lim_send_start_vdev_req() - send vdev start request
536 *@session: pe session
537 *@mlm_start_req: vdev start req
538 *
539 * Return: QDF_STATUS
540 */
541static QDF_STATUS
542lim_send_start_vdev_req(tpPESession session, tLimMlmStartReq *mlm_start_req)
543{
544 lim_process_mlm_start_req(session->mac_ctx, mlm_start_req);
545
546 return QDF_STATUS_SUCCESS;
547}
548
549/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800550 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
551 *@mac_ctx: Pointer to Global MAC structure
552 *@msg_buf: A pointer to the SME message buffer
553 *
554 * This function is called to process SME_START_BSS_REQ message
555 * from HDD or upper layer application.
556 *
557 * Return: None
558 */
559static void
560__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
561{
562 uint16_t size;
563 uint32_t val = 0;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700564 QDF_STATUS ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800565 tSirMacChanNum channel_number;
566 tLimMlmStartReq *mlm_start_req = NULL;
567 tpSirSmeStartBssReq sme_start_bss_req = NULL;
568 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
569 /* Flag Used in case of IBSS to Auto generate BSSID. */
570 uint32_t auto_gen_bssid = false;
571 uint8_t session_id;
572 tpPESession session = NULL;
Krunal Sonib37bb352016-12-20 14:12:21 -0800573 uint8_t sme_session_id = 0xFF;
574 uint16_t sme_transaction_id = 0xFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800575 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700576 struct vdev_type_nss *vdev_type_nss;
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530577 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
gaurank kathpaliad88ef882018-08-14 15:20:11 +0530578 struct policy_mgr_hw_mode_params hw_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800579
580/* FEATURE_WLAN_DIAG_SUPPORT */
581#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
582 /*
583 * Since the session is not created yet, sending NULL.
584 * The response should have the correct state.
585 */
586 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
587 NULL, 0, 0);
588#endif /* FEATURE_WLAN_DIAG_SUPPORT */
589
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700590 pe_debug("Received START_BSS_REQ");
Krunal Sonib37bb352016-12-20 14:12:21 -0800591 size = sizeof(tSirSmeStartBssReq);
592 sme_start_bss_req = qdf_mem_malloc(size);
593 if (NULL == sme_start_bss_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700594 pe_err("Allocate Memory fail for LimStartBssReq");
Krunal Sonib37bb352016-12-20 14:12:21 -0800595 /* Send failure response to host */
596 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
597 goto free;
598 }
599 qdf_mem_copy(sme_start_bss_req, msg_buf, sizeof(tSirSmeStartBssReq));
600 sme_session_id = sme_start_bss_req->sessionId;
601 sme_transaction_id = sme_start_bss_req->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800602
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800603 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
604 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800605 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
606 sme_start_bss_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700607 pe_warn("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800608 ret_code = eSIR_SME_INVALID_PARAMETERS;
609 goto free;
610 }
611
612 /*
613 * This is the place where PE is going to create a session.
614 * If session is not existed, then create a new session
615 */
616 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800617 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800618 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700619 pe_warn("Session Already exists for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800620 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
621 session = NULL;
622 goto free;
623 } else {
624 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800625 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800626 &session_id, mac_ctx->lim.maxStation,
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +0530627 sme_start_bss_req->bssType,
628 sme_start_bss_req->sessionId);
629 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700630 pe_warn("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800631 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
632 goto free;
633 }
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +0530634
635 /* Update the beacon/probe filter in mac_ctx */
636 lim_set_bcn_probe_filter(mac_ctx, session,
637 &sme_start_bss_req->ssId,
638 sme_start_bss_req->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800639 }
640
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700641 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
642 /* Probe resp add ie */
643 lim_start_bss_update_add_ie_buffer(mac_ctx,
644 &session->addIeParams.probeRespData_buff,
645 &session->addIeParams.probeRespDataLen,
646 sme_start_bss_req->addIeParams.
647 probeRespData_buff,
648 sme_start_bss_req->addIeParams.
649 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800650
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700651 /* Probe Beacon add ie */
652 lim_start_bss_update_add_ie_buffer(mac_ctx,
653 &session->addIeParams.probeRespBCNData_buff,
654 &session->addIeParams.probeRespBCNDataLen,
655 sme_start_bss_req->addIeParams.
656 probeRespBCNData_buff,
657 sme_start_bss_req->addIeParams.
658 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800659
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700660 /* Assoc resp IE */
661 lim_start_bss_update_add_ie_buffer(mac_ctx,
662 &session->addIeParams.assocRespData_buff,
663 &session->addIeParams.assocRespDataLen,
664 sme_start_bss_req->addIeParams.
665 assocRespData_buff,
666 sme_start_bss_req->addIeParams.
667 assocRespDataLen);
668 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800669 /* Store the session related params in newly created session */
670 session->pLimStartBssReq = sme_start_bss_req;
671
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800672 session->transactionId = sme_start_bss_req->transactionId;
673
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530674 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800675 &(sme_start_bss_req->htConfig),
676 sizeof(session->htConfig));
677
Sandeep Puligilla98917432016-06-10 13:50:28 -0700678 qdf_mem_copy(&(session->vht_config),
679 &(sme_start_bss_req->vht_config),
680 sizeof(session->vht_config));
681
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800682 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800683 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800684
685 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530686 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800687 (uint8_t *) &sme_start_bss_req->ssId,
688 (sme_start_bss_req->ssId.length + 1));
689
690 session->bssType = sme_start_bss_req->bssType;
691
692 session->nwType = sme_start_bss_req->nwType;
693
694 session->beaconParams.beaconInterval =
695 sme_start_bss_req->beaconInterval;
696
697 /* Store the channel number in session Table */
698 session->currentOperChannel =
699 sme_start_bss_req->channelId;
700
701 /* Store Persona */
702 session->pePersona = sme_start_bss_req->bssPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +0530703 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800704 FL("PE PERSONA=%d"), session->pePersona);
705
706 /* Update the phymode */
707 session->gLimPhyMode = sme_start_bss_req->nwType;
708
709 session->maxTxPower =
710 cfg_get_regulatory_max_transmit_power(mac_ctx,
711 session->currentOperChannel);
712 /* Store the dot 11 mode in to the session Table */
713 session->dot11mode = sme_start_bss_req->dot11mode;
714#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
715 session->cc_switch_mode =
716 sme_start_bss_req->cc_switch_mode;
717#endif
718 session->htCapability =
719 IS_DOT11_MODE_HT(session->dot11mode);
720 session->vhtCapability =
721 IS_DOT11_MODE_VHT(session->dot11mode);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800722
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700723 pe_debug("HT[%d], VHT[%d]",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800724 session->htCapability, session->vhtCapability);
725
726 if (IS_DOT11_MODE_HE(session->dot11mode)) {
727 lim_update_session_he_capable(mac_ctx, session);
728 lim_copy_bss_he_cap(session, sme_start_bss_req);
729 }
730
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800731 session->txLdpcIniFeatureEnabled =
732 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800733#ifdef WLAN_FEATURE_11W
734 session->limRmfEnabled =
735 sme_start_bss_req->pmfCapable ? 1 : 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700736 pe_debug("Session RMF enabled: %d", session->limRmfEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800737#endif
738
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530739 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800740 (void *)&sme_start_bss_req->operationalRateSet,
741 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530742 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743 (void *)&sme_start_bss_req->extendedRateSet,
744 sizeof(tSirMacRateSet));
745
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700746 if (IS_5G_CH(session->currentOperChannel))
747 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
748 else
749 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
750
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800751 switch (sme_start_bss_req->bssType) {
752 case eSIR_INFRA_AP_MODE:
753 lim_configure_ap_start_bss_session(mac_ctx, session,
754 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700755 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700756 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700757 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700758 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800759 break;
760 case eSIR_IBSS_MODE:
761 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
762 lim_get_short_slot_from_phy_mode(mac_ctx, session,
763 session->gLimPhyMode,
764 &session->shortSlotTimeSupported);
765
766 /*
767 * initialize to "OPEN".
768 * will be updated upon key installation
769 */
770 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700771 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800772
773 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700774 case eSIR_NDI_MODE:
775 session->limSystemRole = eLIM_NDI_ROLE;
776 break;
777
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800778
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800779 /*
780 * There is one more mode called auto mode.
781 * which is used no where
782 */
783
784 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
785
786 default:
787 /* not used anywhere...used in scan function */
788 break;
789 }
790
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700791 pe_debug("persona - %d, nss - %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700792 session->pePersona, session->vdev_nss);
793 session->nss = session->vdev_nss;
Kiran Kumar Lokerebc6fb2f2018-05-09 19:04:11 -0700794 if (!mac_ctx->roam.configParam.enable2x2)
795 session->nss = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700797 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800798 * parsed (Re)Assoc request structure
799 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700800 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800801 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530802 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700803 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800804 if (NULL == session->parsedAssocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700805 pe_warn("AllocateMemory() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800806 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
807 goto free;
808 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800809 }
810
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700811 if (!sme_start_bss_req->channelId &&
812 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700813 pe_err("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800814 ret_code = eSIR_SME_INVALID_PARAMETERS;
815 goto free;
816 }
817 channel_number = sme_start_bss_req->channelId;
818#ifdef QCA_HT_2040_COEX
819 if (sme_start_bss_req->obssEnabled)
820 session->htSupportedChannelWidthSet =
821 session->htCapability;
822 else
823#endif
824 session->htSupportedChannelWidthSet =
825 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
826 session->htSecondaryChannelOffset =
827 sme_start_bss_req->sec_ch_offset;
828 session->htRecommendedTxWidthSet =
829 (session->htSecondaryChannelOffset) ? 1 : 0;
Abhishek Singh4294f802017-08-10 16:37:07 +0530830 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800831 FL("cbMode %u"), sme_start_bss_req->cbMode);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800832 if (lim_is_session_he_capable(session) ||
833 session->vhtCapability || session->htCapability) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800834 chanwidth = sme_start_bss_req->vht_channel_width;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700835 pe_debug("vht_channel_width %u htSupportedChannelWidthSet %d",
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800836 sme_start_bss_req->vht_channel_width,
837 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838 session->ch_width = chanwidth;
839 if (session->htSupportedChannelWidthSet) {
840 session->ch_center_freq_seg0 =
841 sme_start_bss_req->center_freq_seg0;
842 session->ch_center_freq_seg1 =
843 sme_start_bss_req->center_freq_seg1;
844 } else {
845 session->ch_center_freq_seg0 = 0;
846 session->ch_center_freq_seg1 = 0;
847 }
848 }
gaurank kathpaliad88ef882018-08-14 15:20:11 +0530849 if (policy_mgr_is_hw_dbs_capable(mac_ctx->psoc) &&
850 (policy_mgr_get_current_hw_mode(mac_ctx->psoc, &hw_mode) ==
851 QDF_STATUS_SUCCESS) &&
852 hw_mode.dbs_cap) {
853 session->nss = 1;
854 pe_debug("HW is in DBS mode. Nss set to [%d]",
855 session->nss);
856 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800857 if (session->vhtCapability &&
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800858 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800859 session->nss = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700860 pe_debug("nss set to [%d]", session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800861 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700862 pe_debug("vht su tx bformer %d",
Krunal Soni53993f72016-07-08 18:20:03 -0700863 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800864
865 /* Delete pre-auth list if any */
866 lim_delete_pre_auth_list(mac_ctx);
867
868 /*
869 * keep the RSN/WPA IE information in PE Session Entry
870 * later will be using this to check when received (Re)Assoc req
871 */
872 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
873 &sme_start_bss_req->rsnIE, session);
874
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700875 if (LIM_IS_AP_ROLE(session) ||
876 LIM_IS_IBSS_ROLE(session) ||
877 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800878 session->gLimProtectionControl =
879 sme_start_bss_req->protEnabled;
880 /*
881 * each byte will have the following info
882 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
883 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
884 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530885 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800886 (void *)&sme_start_bss_req->ht_capab,
887 sizeof(uint16_t));
888 /* Initialize WPS PBC session link list */
889 session->pAPWPSPBCSession = NULL;
890 }
891 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530892 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800893 if (NULL == mlm_start_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700894 pe_err("Allocate Memory failed for mlmStartReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800895 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
896 goto free;
897 }
898
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800899 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530900 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800901 (uint8_t *) &sme_start_bss_req->ssId,
902 sme_start_bss_req->ssId.length + 1);
903 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
904 mlm_start_req->obssProtEnabled =
905 sme_start_bss_req->obssProtEnabled;
906
907 mlm_start_req->bssType = session->bssType;
908
909 /* Fill PE session Id from the session Table */
910 mlm_start_req->sessionId = session->peSessionId;
911
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700912 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
913 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800914 /*
915 * Copy the BSSId from sessionTable to
916 * mlmStartReq struct
917 */
918 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
919 } else {
920 /* ibss mode */
921 mac_ctx->lim.gLimIbssCoalescingHappened = false;
922
923 ret_status = wlan_cfg_get_int(mac_ctx,
924 WNI_CFG_IBSS_AUTO_BSSID,
925 &auto_gen_bssid);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700926 if (ret_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700927 pe_err("Get Auto Gen BSSID fail,Status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800928 ret_status);
Abhishek Singh4294f802017-08-10 16:37:07 +0530929 ret_code = eSIR_LOGE_EXCEPTION;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800930 goto free;
931 }
932
933 if (!auto_gen_bssid) {
934 /*
935 * We're not auto generating BSSID.
936 * Instead, get it from session entry
937 */
938 sir_copy_mac_addr(mlm_start_req->bssId,
939 session->bssId);
940 /*
941 * Start IBSS group BSSID
942 * Auto Generating BSSID.
943 */
944 auto_gen_bssid = ((mlm_start_req->bssId[0] &
945 0x01) ? true : false);
946 }
947
948 if (auto_gen_bssid) {
949 /*
950 * if BSSID is not any uc id.
951 * then use locally generated BSSID.
952 * Autogenerate the BSSID
953 */
954 lim_get_random_bssid(mac_ctx,
955 mlm_start_req->bssId);
956 mlm_start_req->bssId[0] = 0x02;
957
958 /*
959 * Copy randomly generated BSSID
960 * to the session Table
961 */
962 sir_copy_mac_addr(session->bssId,
963 mlm_start_req->bssId);
964 }
965 }
966 /* store the channel num in mlmstart req structure */
967 mlm_start_req->channelNumber = session->currentOperChannel;
968 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
969 mlm_start_req->beaconPeriod =
970 session->beaconParams.beaconInterval;
Arif Hussain671a1902017-03-17 09:08:32 -0700971 mlm_start_req->cac_duration_ms =
972 sme_start_bss_req->cac_duration_ms;
973 mlm_start_req->dfs_regdomain =
974 sme_start_bss_req->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800975 if (LIM_IS_AP_ROLE(session)) {
976 mlm_start_req->dtimPeriod = session->dtimPeriod;
977 mlm_start_req->wps_state = session->wps_state;
978
979 } else {
980 if (wlan_cfg_get_int(mac_ctx,
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700981 WNI_CFG_DTIM_PERIOD, &val) != QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700982 pe_err("could not retrieve DTIM Period");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800983 mlm_start_req->dtimPeriod = (uint8_t) val;
984 }
985
Karthik Kantamneni22dd0f62018-08-07 14:53:50 +0530986 mlm_start_req->cfParamSet.cfpPeriod =
987 mac_ctx->mlme_cfg->rates.cfp_period;
988 mlm_start_req->cfParamSet.cfpMaxDuration =
989 mac_ctx->mlme_cfg->rates.cfp_max_duration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800990
991 /*
992 * this may not be needed anymore now,
993 * as rateSet is now included in the
994 * session entry and MLM has session context.
995 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530996 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800997 (void *)&session->rateSet,
998 sizeof(tSirMacRateSet));
999
1000 /* Now populate the 11n related parameters */
1001 mlm_start_req->nwType = session->nwType;
1002 mlm_start_req->htCapable = session->htCapability;
1003
1004 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1005 /* Unused */
1006 mlm_start_req->dualCTSProtection =
1007 mac_ctx->lim.gHTDualCTSProtection;
1008 mlm_start_req->txChannelWidthSet =
1009 session->htRecommendedTxWidthSet;
1010
1011 session->limRFBand = lim_get_rf_band(channel_number);
1012
1013 /* Initialize 11h Enable Flag */
1014 session->lim11hEnable = 0;
gaolez76d2a162017-03-21 19:23:58 +08001015 if (mlm_start_req->bssType != eSIR_IBSS_MODE &&
1016 (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001017 BAND_5G == session->limRFBand)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001018 if (wlan_cfg_get_int(mac_ctx,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001019 WNI_CFG_11H_ENABLED, &val) != QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001020 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001021 else
1022 session->lim11hEnable = val;
1023
1024 if (session->lim11hEnable &&
1025 (eSIR_INFRA_AP_MODE ==
1026 mlm_start_req->bssType)) {
Abhishek Singhdfa69c32018-08-30 15:39:34 +05301027 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001028 wlan_cfg_get_int(mac_ctx,
1029 WNI_CFG_DFS_MASTER_ENABLED,
1030 &val);
1031 session->lim11hEnable = val;
1032 }
Abhishek Singhdfa69c32018-08-30 15:39:34 +05301033 if (QDF_IS_STATUS_ERROR(qdf_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001034 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001035 pe_err("Get Fail, CFG DFS ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001036 }
1037
1038 if (!session->lim11hEnable) {
1039 if (cfg_set_int(mac_ctx,
1040 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001041 QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001042 /*
1043 * Failed to set the CFG param
1044 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1045 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001046 pe_err("Set LOCAL_POWER_CONSTRAINT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001047 }
1048
Jiachao Wu712d4fd2017-08-23 16:52:34 +08001049 mlm_start_req->beacon_tx_rate = session->beacon_tx_rate;
1050
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051 session->limPrevSmeState = session->limSmeState;
1052 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1053 MTRACE(mac_trace
1054 (mac_ctx, TRACE_CODE_SME_STATE,
1055 session->peSessionId,
1056 session->limSmeState));
1057
Abhishek Singhdfa69c32018-08-30 15:39:34 +05301058 qdf_status = lim_send_start_vdev_req(session, mlm_start_req);
1059 if (QDF_IS_STATUS_ERROR(qdf_status))
1060 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001061 return;
1062 } else {
1063
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001064 pe_err("Received unexpected START_BSS_REQ, in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001065 mac_ctx->lim.gLimSmeState);
1066 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001067 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001068 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1069
1070free:
1071 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001072 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001073 session->pLimStartBssReq = NULL;
1074 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001075 if (NULL != sme_start_bss_req)
1076 qdf_mem_free(sme_start_bss_req);
1077 if (NULL != mlm_start_req)
1078 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001079 if (NULL != session) {
1080 pe_delete_session(mac_ctx, session);
1081 session = NULL;
1082 }
1083 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1084 session, sme_session_id, sme_transaction_id);
1085}
1086
1087/**
1088 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1089 *
1090 * @pMac: Global MAC context
1091 * @pMsg: Message pointer
1092 *
1093 * Wrapper for the function __lim_handle_sme_start_bss_request
1094 * This message will be defered until softmac come out of
1095 * scan mode or if we have detected radar on the current
1096 * operating channel.
1097 *
1098 * return true - If we consumed the buffer
1099 * false - If have defered the message.
1100 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001101static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1102 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001103{
1104 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1105 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1106 /**
1107 * If message defered, buffer is not consumed yet.
1108 * So return false
1109 */
1110 return false;
1111 }
1112
1113 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1114 return true;
1115}
1116
1117/**
1118 * lim_get_random_bssid()
1119 *
1120 * FUNCTION:This function is called to process generate the random number for bssid
1121 * This function is called to process SME_SCAN_REQ message
1122 * from HDD or upper layer application.
1123 *
1124 * LOGIC:
1125 *
1126 * ASSUMPTIONS:
1127 *
1128 * NOTE:
1129 * 1. geneartes the unique random number for bssid in ibss
1130 *
1131 * @param pMac Pointer to Global MAC structure
1132 * @param *data Pointer to bssid buffer
1133 * @return None
1134 */
1135void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1136{
1137 uint32_t random[2];
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001138
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001139 random[0] = tx_time_get();
1140 random[0] |= (random[0] << 15);
1141 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301142 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001143}
1144
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001145/**
1146 * __lim_process_clear_dfs_channel_list()
1147 *
1148 ***FUNCTION:
Jeff Johnsonc00ae5b2018-05-06 16:06:35 -07001149 ***Clear DFS channel list when country is changed/acquired.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001150 .*This message is sent from SME.
1151 *
1152 ***LOGIC:
1153 *
1154 ***ASSUMPTIONS:
1155 *
1156 ***NOTE:
1157 *
1158 * @param pMac Pointer to Global MAC structure
1159 * @param *pMsgBuf A pointer to the SME message buffer
1160 * @return None
1161 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001162static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1163 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001164{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301165 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001166}
1167
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301168#ifdef WLAN_FEATURE_SAE
1169
1170/**
1171 * lim_update_sae_config()- This API update SAE session info to csr config
1172 * from join request.
1173 * @session: PE session
1174 * @sme_join_req: pointer to join request
1175 *
1176 * Return: None
1177 */
1178static void lim_update_sae_config(tpPESession session,
1179 tpSirSmeJoinReq sme_join_req)
1180{
1181 session->sae_pmk_cached = sme_join_req->sae_pmk_cached;
1182
1183 pe_debug("pmk_cached %d for BSSID=" MAC_ADDRESS_STR,
1184 session->sae_pmk_cached,
1185 MAC_ADDR_ARRAY(sme_join_req->bssDescription.bssId));
1186}
1187#else
1188static inline void lim_update_sae_config(tpPESession session,
1189 tpSirSmeJoinReq sme_join_req)
1190{}
1191#endif
1192
1193
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001194/**
1195 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1196 * @mac_ctx: Pointer to Global MAC structure
1197 * @msg_buf: A pointer to the SME message buffer
1198 *
1199 * This function is called to process SME_JOIN_REQ message
1200 * from HDD or upper layer application.
1201 *
1202 * Return: None
1203 */
1204static void
1205__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1206{
1207 tpSirSmeJoinReq sme_join_req = NULL;
1208 tLimMlmJoinReq *mlm_join_req;
1209 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1210 uint32_t val = 0;
1211 uint16_t n_size;
1212 uint8_t session_id;
1213 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301214 uint8_t sme_session_id = 0;
1215 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001216 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001217 uint16_t ie_len;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001218 const uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001219 tSirBssDescription *bss_desc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001220
Arif Hussain995fcaf2016-07-18 11:28:22 -07001221 if (!mac_ctx || !msg_buf) {
1222 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1223 FL("JOIN REQ with invalid data"));
1224 return;
1225 }
1226
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001227/* FEATURE_WLAN_DIAG_SUPPORT */
1228#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1229 /*
1230 * Not sending any session, since it is not created yet.
1231 * The response whould have correct state.
1232 */
1233 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1234#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1235
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001236 /*
1237 * Expect Join request in idle state.
1238 * Reassociate request is expected in link established state.
1239 */
1240
1241 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1242 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1243 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1244 msg_buf);
1245
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301246 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247 if (NULL == sme_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001248 pe_err("AllocateMemory failed for sme_join_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001249 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301250 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001251 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301252 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001253 n_size);
1254
1255 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1256 /* Received invalid eWNI_SME_JOIN_REQ */
1257 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001258 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001259 sme_join_req->sessionId);
1260 ret_code = eSIR_SME_INVALID_PARAMETERS;
1261 goto end;
1262 }
1263
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001264 /*
1265 * Update the capability here itself as this is used in
1266 * lim_extract_ap_capability() below. If not updated issues
1267 * like not honoring power constraint on 1st association after
1268 * driver loading might occur.
1269 */
1270 lim_update_rrm_capability(mac_ctx, sme_join_req);
1271
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001272 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001273 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001274 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001275 &session_id);
1276
1277 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001278 pe_err("Session(%d) Already exists for BSSID: "
1279 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001280 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001281 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001282 session->limSmeState);
1283
1284 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1285 session->smeSessionId == sme_join_req->sessionId) {
1286 /*
1287 * Received eWNI_SME_JOIN_REQ for same
1288 * BSS as currently associated.
1289 * Log the event and send success
1290 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001291 pe_warn("SessionId: %d", session_id);
1292 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293 /* Send Join success response to host */
1294 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1295 session = NULL;
1296 goto end;
1297 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001298 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001299 ret_code = eSIR_SME_REFUSED;
1300 session = NULL;
1301 goto end;
1302 }
1303 } else {
1304 /*
1305 * Session Entry does not exist for given BSSId
1306 * Try to Create a new session
1307 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001308 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001309 &session_id, mac_ctx->lim.maxStation,
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +05301310 eSIR_INFRASTRUCTURE_MODE,
1311 sme_join_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001313 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001314 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1315 goto end;
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301316 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001317 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001318 session_id);
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301319 }
1320
1321 /* Update the beacon/probe filter in mac_ctx */
1322 lim_set_bcn_probe_filter(mac_ctx, session,
1323 &sme_join_req->ssId,
1324 bss_desc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001326 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Arif Hussain6686c0b2018-08-21 18:21:05 -07001327 session->enable_session_twt_support =
1328 sme_join_req->enable_session_twt_support;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001329 /*
1330 * Store Session related parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001331 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001332
1333 /* store the smejoin req handle in session table */
1334 session->pLimJoinReq = sme_join_req;
1335
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001336 /* Store SME transaction Id in session Table */
1337 session->transactionId = sme_join_req->transactionId;
1338
1339 /* Store beaconInterval */
1340 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001341 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001342
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301343 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001344 sizeof(session->htConfig));
1345
Sandeep Puligilla98917432016-06-10 13:50:28 -07001346 qdf_mem_copy(&(session->vht_config),
1347 &(sme_join_req->vht_config),
1348 sizeof(session->vht_config));
1349
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001350 /* Copying of bssId is already done, while creating session */
1351 sir_copy_mac_addr(session->selfMacAddr,
1352 sme_join_req->selfMacAddr);
1353 session->bssType = sme_join_req->bsstype;
1354
1355 session->statypeForBss = STA_ENTRY_PEER;
1356 session->limWmeEnabled = sme_join_req->isWMEenabled;
1357 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301358 session->wps_registration = sme_join_req->wps_registration;
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001359 session->he_with_wep_tkip = sme_join_req->he_with_wep_tkip;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001360
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301361 session->enable_bcast_probe_rsp =
1362 sme_join_req->enable_bcast_probe_rsp;
1363
Jeff Johnson179fd8a2018-05-11 14:20:05 -07001364 /* Store vendor specific IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001365 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001366 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1367
Naveen Rawat08db88f2017-09-08 15:07:48 -07001368 vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001369 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001370 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001371
1372 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001373 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001374 session->isCiscoVendorAP = true;
1375 } else {
1376 session->isCiscoVendorAP = false;
1377 }
1378
1379 /* Copy the dot 11 mode in to the session table */
1380
1381 session->dot11mode = sme_join_req->dot11mode;
1382#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1383 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1384#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001385 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001386 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1387 session->enableHtSmps = sme_join_req->enableHtSmps;
1388 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001389 session->send_smps_action =
1390 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001391 /*
1392 * By default supported NSS 1x1 is set to true
1393 * and later on updated while determining session
1394 * supported rates which is the intersection of
1395 * self and peer rates
1396 */
1397 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301398 /*Store Persona */
1399 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001400 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 -08001401 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001402 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001403 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301404 session->supported_nss_1x1,
1405 session->pePersona,
1406 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001407
1408 /*Store Persona */
1409 session->pePersona = sme_join_req->staPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +05301410 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301411 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d force_24ghz_in_ht20 %d"),
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001412 session->pePersona, sme_join_req->cbMode,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301413 session->nwType, session->dot11mode,
1414 sme_join_req->force_24ghz_in_ht20);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001415
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001416 /* Copy The channel Id to the session Table */
1417 session->currentOperChannel = bss_desc->channelId;
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301418
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001419 session->vhtCapability =
1420 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001421 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301422 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001423 session->vht_config.su_beam_formee =
1424 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001425 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001426 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001427 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001428 session->enableVhtpAid =
1429 sme_join_req->enableVhtpAid;
1430 session->enableVhtGid =
1431 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001432 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001433 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001434 }
Krunal Soni53993f72016-07-08 18:20:03 -07001435
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001436 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301437 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001438 session->vht_config.su_beam_formee,
1439 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001440 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001442 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001443 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301444 session->force_24ghz_in_ht20 =
1445 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001446 /* cbMode is already merged value of peer and self -
1447 * done by csr in csr_get_cb_mode_from_ies */
1448 session->htSupportedChannelWidthSet =
1449 (sme_join_req->cbMode) ? 1 : 0;
1450 session->htRecommendedTxWidthSet =
1451 session->htSupportedChannelWidthSet;
1452 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1453
1454 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1455 session->ch_center_freq_seg0 =
1456 session->currentOperChannel - 2;
1457 session->ch_width = CH_WIDTH_40MHZ;
1458 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1459 sme_join_req->cbMode) {
1460 session->ch_center_freq_seg0 =
1461 session->currentOperChannel + 2;
1462 session->ch_width = CH_WIDTH_40MHZ;
1463 } else {
1464 session->ch_center_freq_seg0 = 0;
1465 session->ch_width = CH_WIDTH_20MHZ;
1466 }
1467
Naveen Rawataeca1b92017-10-16 16:55:31 -07001468 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1469 lim_update_session_he_capable(mac_ctx, session);
1470 lim_copy_join_req_he_cap(session, sme_join_req);
1471 }
1472
1473
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001474 /* Record if management frames need to be protected */
1475#ifdef WLAN_FEATURE_11W
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +05301476 if ((eSIR_ED_AES_128_CMAC ==
1477 sme_join_req->MgmtEncryptionType) ||
1478 (eSIR_ED_AES_GMAC_128 == sme_join_req->MgmtEncryptionType) ||
1479 (eSIR_ED_AES_GMAC_256 == sme_join_req->MgmtEncryptionType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001480 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001481 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001482 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001483#endif
1484
1485#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001486 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001487#endif
1488
1489 /* Copy the SSID from smejoinreq to session entry */
1490 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301491 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001492 session->ssId.length);
1493
1494 /*
1495 * Determin 11r or ESE connection based on input from SME
1496 * which inturn is dependent on the profile the user wants
1497 * to connect to, So input is coming from supplicant
1498 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001499 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001500#ifdef FEATURE_WLAN_ESE
1501 session->isESEconnection = sme_join_req->isESEconnection;
1502#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001503 session->isFastTransitionEnabled =
1504 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001505
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001506 session->isFastRoamIniFeatureEnabled =
1507 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001508 session->txLdpcIniFeatureEnabled =
1509 sme_join_req->txLdpcIniFeatureEnabled;
1510
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301511 lim_update_fils_config(session, sme_join_req);
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301512 lim_update_sae_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001513 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1514 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001515 } else {
1516 /*
1517 * Throw an error and return and make
1518 * sure to delete the session.
1519 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001520 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521 session->bssType);
1522 ret_code = eSIR_SME_INVALID_PARAMETERS;
1523 goto end;
1524 }
1525
1526 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301527 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001528 &sme_join_req->addIEScan, sizeof(tSirAddie));
1529
1530 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301531 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001532 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1533
1534 val = sizeof(tLimMlmJoinReq) +
1535 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301536 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001537 if (NULL == mlm_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001538 pe_err("AllocateMemory failed for mlmJoinReq");
Nitesh Shah0102cac2016-07-13 14:38:30 +05301539 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1540 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001541 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001542
1543 /* PE SessionId is stored as a part of JoinReq */
1544 mlm_join_req->sessionId = session->peSessionId;
1545
1546 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1547 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001548 QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001549 pe_err("couldn't retrieve JoinFailureTimer value"
1550 " setting to default value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001551 mlm_join_req->joinFailureTimeout =
1552 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1553 }
1554
1555 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301556 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001557 (void *)&sme_join_req->operationalRateSet,
1558 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301559 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001560 (void *)&sme_join_req->extendedRateSet,
1561 sizeof(tSirMacRateSet));
1562 /*
1563 * this may not be needed anymore now, as rateSet is now
1564 * included in the session entry and MLM has session context.
1565 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301566 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001567 (void *)&session->rateSet,
1568 sizeof(tSirMacRateSet));
1569
1570 session->encryptType = sme_join_req->UCEncryptionType;
1571
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301572 session->supported_nss_1x1 = sme_join_req->supported_nss_1x1;
1573 session->vdev_nss = sme_join_req->vdev_nss;
1574 session->nss = sme_join_req->nss;
1575 session->nss_forced_1x1 = sme_join_req->nss_forced_1x1;
1576
1577 pe_debug("nss %d, vdev_nss %d, supported_nss_1x1 %d",
1578 session->nss,
1579 session->vdev_nss,
1580 session->supported_nss_1x1);
1581
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582 mlm_join_req->bssDescription.length =
1583 session->pLimJoinReq->bssDescription.length;
1584
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301585 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001586 (uint8_t *)
1587 &session->pLimJoinReq->bssDescription.bssId,
1588 session->pLimJoinReq->bssDescription.length + 2);
1589
1590 session->limCurrentBssCaps =
1591 session->pLimJoinReq->bssDescription.capabilityInfo;
1592
1593 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1594 session->currentOperChannel);
1595 local_power_constraint = reg_max;
1596
1597 lim_extract_ap_capability(mac_ctx,
1598 (uint8_t *)
1599 session->pLimJoinReq->bssDescription.ieFields,
1600 lim_get_ielen_from_bss_description(
1601 &session->pLimJoinReq->bssDescription),
1602 &session->limCurrentBssQosCaps,
1603 &session->limCurrentBssPropCap,
1604 &session->gLimCurrentBssUapsd,
1605 &local_power_constraint, session);
1606
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001607 session->maxTxPower = lim_get_max_tx_power(reg_max,
1608 local_power_constraint,
1609 mac_ctx->roam.configParam.nTxPowerCap);
Abhinav Kumard528d192018-03-09 17:31:12 +05301610 session->def_max_tx_pwr = session->maxTxPower;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301611
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001612 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301613 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001614
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301615 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1616 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1617 pe_debug("Update MaxTxPower in join Req to %d",
1618 sme_join_req->powerCap.maxTxPower);
1619 }
1620
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001621 if (session->gLimCurrentBssUapsd) {
1622 session->gUapsdPerAcBitmask =
1623 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001624 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001625 session->gUapsdPerAcBitmask);
1626
1627 /* resetting the dynamic uapsd mask */
1628 session->gUapsdPerAcDeliveryEnableMask = 0;
1629 session->gUapsdPerAcTriggerEnableMask = 0;
1630 }
1631
1632 session->limRFBand =
1633 lim_get_rf_band(session->currentOperChannel);
1634
1635 /* Initialize 11h Enable Flag */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001636 if (BAND_5G == session->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001638 &val) != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001639 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001640 session->lim11hEnable =
1641 WNI_CFG_11H_ENABLED_STADEF;
1642 } else {
1643 session->lim11hEnable = val;
1644 }
1645 } else {
1646 session->lim11hEnable = 0;
1647 }
1648
1649 /*
1650 * To care of the scenario when STA transitions from
1651 * IBSS to Infrastructure mode.
1652 */
1653 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1654
1655 session->limPrevSmeState = session->limSmeState;
1656 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1657 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1658 session->peSessionId,
1659 session->limSmeState));
1660
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001661 /* Indicate whether spectrum management is enabled */
1662 session->spectrumMgtEnabled =
1663 sme_join_req->spectrumMgtIndicator;
1664
1665 /* Enable the spectrum management if this is a DFS channel */
1666 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001667 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001668 session->currentOperChannel))
1669 session->spectrumMgtEnabled = true;
1670
1671 session->isOSENConnection = sme_join_req->isOSENConnection;
1672
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001673 /* Issue LIM_MLM_JOIN_REQ to MLM */
1674 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1675 (uint32_t *) mlm_join_req);
1676 return;
1677
1678 } else {
1679 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001680 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001681 mac_ctx->lim.gLimSmeState);
1682 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1683 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1684 session = NULL;
1685 goto end;
1686 }
1687
1688end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301689 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1690 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001691
1692 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301693 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001694 sme_join_req = NULL;
1695 if (NULL != session)
1696 session->pLimJoinReq = NULL;
1697 }
1698 if (ret_code != eSIR_SME_SUCCESS) {
1699 if (NULL != session) {
1700 pe_delete_session(mac_ctx, session);
1701 session = NULL;
1702 }
1703 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001704 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001705 sme_session_id, ret_code);
1706 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1707 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1708 sme_transaction_id);
1709}
1710
Amar Singhala297bfa2015-10-15 15:07:29 -07001711uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001712 uint8_t iniTxPower)
1713{
1714 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301715 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001716
Anurag Chouhan6d760662016-02-20 16:05:43 +05301717 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1719 maxTxPower = txPower;
1720 else if (txPower < MIN_TX_PWR_CAP)
1721 maxTxPower = MIN_TX_PWR_CAP;
1722 else
1723 maxTxPower = MAX_TX_PWR_CAP;
1724
1725 return maxTxPower;
1726}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001727
1728/**
1729 * __lim_process_sme_reassoc_req() - process reassoc req
1730 *
1731 * @mac_ctx: Pointer to Global MAC structure
1732 * @msg_buf: pointer to the SME message buffer
1733 *
1734 * This function is called to process SME_REASSOC_REQ message
1735 * from HDD or upper layer application.
1736 *
1737 * Return: None
1738 */
1739
1740static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
1741 uint32_t *msg_buf)
1742{
1743 uint16_t caps;
1744 uint32_t val;
1745 tpSirSmeJoinReq reassoc_req = NULL;
1746 tLimMlmReassocReq *mlm_reassoc_req;
1747 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1748 tpPESession session_entry = NULL;
1749 uint8_t session_id;
1750 uint8_t sme_session_id;
1751 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001752 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001753 uint32_t tele_bcn_en = 0;
1754 uint16_t size;
1755
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301757 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001759 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001760
1761 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1762 goto end;
1763 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301764 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001765
1766 if (!lim_is_sme_join_req_valid(mac_ctx,
1767 (tpSirSmeJoinReq)reassoc_req)) {
1768 /*
1769 * Received invalid eWNI_SME_REASSOC_REQ
1770 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001771 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001772
1773 ret_code = eSIR_SME_INVALID_PARAMETERS;
1774 goto end;
1775 }
1776
1777 session_entry = pe_find_session_by_bssid(mac_ctx,
1778 reassoc_req->bssDescription.bssId,
1779 &session_id);
1780 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001781 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001782 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
1783 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001785 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
1786 &sme_session_id, &transaction_id);
1787 session_entry =
1788 pe_find_session_by_sme_session_id(mac_ctx,
1789 sme_session_id);
1790 if (session_entry != NULL)
1791 lim_handle_sme_join_result(mac_ctx,
1792 eSIR_SME_INVALID_PARAMETERS,
1793 eSIR_MAC_UNSPEC_FAILURE_STATUS,
1794 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001795 goto end;
1796 }
1797#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
1798 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001799 session_entry, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001800#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1801 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
1802
1803 /* Store the reassoc handle in the session Table */
1804 session_entry->pLimReAssocReq = reassoc_req;
1805
1806 session_entry->dot11mode = reassoc_req->dot11mode;
1807 session_entry->vhtCapability =
1808 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001809
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301810 if (session_entry->vhtCapability) {
1811 if (session_entry->pePersona == QDF_STA_MODE) {
1812 session_entry->vht_config.su_beam_formee =
1813 reassoc_req->vht_config.su_beam_formee;
1814 } else {
1815 reassoc_req->vht_config.su_beam_formee = 0;
1816 }
1817 session_entry->enableVhtpAid =
1818 reassoc_req->enableVhtpAid;
1819 session_entry->enableVhtGid =
1820 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001821 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301822 }
1823
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301824 session_entry->supported_nss_1x1 = reassoc_req->supported_nss_1x1;
1825 session_entry->vdev_nss = reassoc_req->vdev_nss;
1826 session_entry->nss = reassoc_req->nss;
1827 session_entry->nss_forced_1x1 = reassoc_req->nss_forced_1x1;
1828
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001829 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301830 session_entry->vhtCapability,
1831 session_entry->vht_config.su_beam_formee,
1832 session_entry->vht_config.su_beam_former);
1833
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001834 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
1835 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001836 session_entry->send_smps_action =
1837 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001838 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001839 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001840 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001841 session_entry->send_smps_action,
1842 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001843 /*
1844 * Reassociate request is expected
1845 * in link established state only.
1846 */
1847
1848 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001849 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
1850 /*
1851 * May be from 11r FT pre-auth. So lets check it
1852 * before we bail out
1853 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001854 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001855 session_entry->peSessionId);
1856
1857 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301858 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001859 session_entry->limReAssocbssId,
1860 6)) {
1861 lim_print_mac_addr(mac_ctx,
1862 reassoc_req->bssDescription.
1863 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001864 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001865 ret_code = eSIR_SME_INVALID_PARAMETERS;
1866 goto end;
1867 }
1868
1869 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
1870 session_entry);
1871 return;
1872 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001873 /*
1874 * Should not have received eWNI_SME_REASSOC_REQ
1875 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001876 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001877 session_entry->limSmeState);
1878 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
1879
1880 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1881 goto end;
1882 }
1883
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301884 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001885 session_entry->pLimReAssocReq->bssDescription.bssId,
1886 sizeof(tSirMacAddr));
1887
1888 session_entry->limReassocChannelId =
1889 session_entry->pLimReAssocReq->bssDescription.channelId;
1890
1891 session_entry->reAssocHtSupportedChannelWidthSet =
1892 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
1893 session_entry->reAssocHtRecommendedTxWidthSet =
1894 session_entry->reAssocHtSupportedChannelWidthSet;
1895 session_entry->reAssocHtSecondaryChannelOffset =
1896 session_entry->pLimReAssocReq->cbMode;
1897
1898 session_entry->limReassocBssCaps =
1899 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
1900 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1901 session_entry->currentOperChannel);
1902 local_pwr_constraint = reg_max;
1903
1904 lim_extract_ap_capability(mac_ctx,
1905 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
1906 lim_get_ielen_from_bss_description(
1907 &session_entry->pLimReAssocReq->bssDescription),
1908 &session_entry->limReassocBssQosCaps,
1909 &session_entry->limReassocBssPropCap,
1910 &session_entry->gLimCurrentBssUapsd,
1911 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05301912 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001913 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301914 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001915 /* Copy the SSID from session entry to local variable */
1916 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301917 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001918 reassoc_req->ssId.ssId,
1919 session_entry->limReassocSSID.length);
1920 if (session_entry->gLimCurrentBssUapsd) {
1921 session_entry->gUapsdPerAcBitmask =
1922 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001923 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001924 session_entry->gUapsdPerAcBitmask);
1925 }
1926
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301927 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001928 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001929 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001930
1931 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1932 goto end;
1933 }
1934
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301935 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001936 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
1937
1938 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
1939 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001940 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001941 pe_err("could not retrieve ReassocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001942
1943 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001944 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001945 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301946
1947 lim_update_caps_info_for_bss(mac_ctx, &caps,
1948 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001949 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301950
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001951 mlm_reassoc_req->capabilityInfo = caps;
1952
1953 /* Update PE session_id */
1954 mlm_reassoc_req->sessionId = session_id;
1955
1956 /*
1957 * If telescopic beaconing is enabled, set listen interval to
1958 * WNI_CFG_TELE_BCN_MAX_LI
1959 */
1960 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001961 &tele_bcn_en) != QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001962 pe_err("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001963
1964 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
1965
1966 if (tele_bcn_en) {
1967 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001968 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001969 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970 } else {
1971 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001972 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001973 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001974 }
1975
1976 mlm_reassoc_req->listenInterval = (uint16_t) val;
1977
1978 /* Indicate whether spectrum management is enabled */
1979 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
1980
1981 /* Enable the spectrum management if this is a DFS channel */
1982 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001983 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001984 session_entry->currentOperChannel))
1985 session_entry->spectrumMgtEnabled = true;
1986
1987 session_entry->limPrevSmeState = session_entry->limSmeState;
1988 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
1989
1990 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1991 session_entry->peSessionId,
1992 session_entry->limSmeState));
1993
1994 lim_post_mlm_message(mac_ctx,
1995 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
1996 return;
1997end:
1998 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301999 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000 if (session_entry)
2001 session_entry->pLimReAssocReq = NULL;
2002 }
2003
2004 if (session_entry) {
2005 /*
2006 * error occurred after we determined the session so extract
2007 * session and transaction info from there
2008 */
2009 sme_session_id = session_entry->smeSessionId;
2010 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002011 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002012 /*
2013 * error occurred before or during the time we determined
2014 * the session so extract the session and transaction info
2015 * from the message
2016 */
2017 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2018 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002019 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002020 /*
2021 * Send Reassoc failure response to host
2022 * (note session_entry may be NULL, but that's OK)
2023 */
2024 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2025 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2026 session_entry, sme_session_id,
2027 transaction_id);
2028}
2029
2030bool send_disassoc_frame = 1;
2031/**
2032 * __lim_process_sme_disassoc_req()
2033 *
2034 ***FUNCTION:
2035 * This function is called to process SME_DISASSOC_REQ message
2036 * from HDD or upper layer application.
2037 *
2038 ***LOGIC:
2039 *
2040 ***ASSUMPTIONS:
2041 *
2042 ***NOTE:
2043 *
2044 * @param pMac Pointer to Global MAC structure
2045 * @param *pMsgBuf A pointer to the SME message buffer
2046 * @return None
2047 */
2048
2049static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2050{
2051 uint16_t disassocTrigger, reasonCode;
2052 tLimMlmDisassocReq *pMlmDisassocReq;
2053 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2054 tSirSmeDisassocReq smeDisassocReq;
2055 tpPESession psessionEntry = NULL;
2056 uint8_t sessionId;
2057 uint8_t smesessionId;
2058 uint16_t smetransactionId;
2059
2060 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002061 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002062 return;
2063 }
2064
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302065 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002066 smesessionId = smeDisassocReq.sessionId;
2067 smetransactionId = smeDisassocReq.transactionId;
2068 if (!lim_is_sme_disassoc_req_valid(pMac,
2069 &smeDisassocReq,
2070 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002071 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002072 if (pMac->lim.gLimRspReqd) {
2073 pMac->lim.gLimRspReqd = false;
2074
2075 retCode = eSIR_SME_INVALID_PARAMETERS;
2076 disassocTrigger = eLIM_HOST_DISASSOC;
2077 goto sendDisassoc;
2078 }
2079
2080 return;
2081 }
2082
2083 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002084 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002085 &sessionId);
2086 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002087 pe_err("session does not exist for given bssId "
2088 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002089 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002090 retCode = eSIR_SME_INVALID_PARAMETERS;
2091 disassocTrigger = eLIM_HOST_DISASSOC;
2092 goto sendDisassoc;
2093 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002094 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2095 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002096 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2097 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002098 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002099
2100#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2101 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2102 0, smeDisassocReq.reasonCode);
2103#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2104
2105 /* Update SME session Id and SME transaction ID */
2106
2107 psessionEntry->smeSessionId = smesessionId;
2108 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002109 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002110 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002111
2112 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2113 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002114 switch (psessionEntry->limSmeState) {
2115 case eLIM_SME_ASSOCIATED_STATE:
2116 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002117 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002118 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002119 psessionEntry->limPrevSmeState =
2120 psessionEntry->limSmeState;
2121 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002122 /* Delete all TDLS peers connected before leaving BSS */
2123 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002124 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2125 psessionEntry->peSessionId,
2126 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002127 break;
2128
2129 case eLIM_SME_WT_DEAUTH_STATE:
2130 /* PE shall still process the DISASSOC_REQ and proceed with
2131 * link tear down even if it had already sent a DEAUTH_IND to
2132 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2133 * its been set when PE entered WT_DEAUTH_STATE.
2134 */
2135 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2136 MTRACE(mac_trace
2137 (pMac, TRACE_CODE_SME_STATE,
2138 psessionEntry->peSessionId,
2139 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002140 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002141 break;
2142
2143 case eLIM_SME_WT_DISASSOC_STATE:
Jeff Johnson47d75242018-05-12 15:58:53 -07002144 /* PE Received a Disassoc frame. Normally it gets DISASSOC_CNF but it
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002145 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2146 * PE can continue processing DISASSOC_REQ and send the response instead
2147 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2148 * for disassoc frame.
2149 *
2150 * It will send a disassoc, which is ok. However, we can use the global flag
2151 * sendDisassoc to not send disassoc frame.
2152 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002153 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002154 break;
2155
2156 case eLIM_SME_JOIN_FAILURE_STATE: {
2157 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002158 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002159 if (pMac->lim.gLimRspReqd) {
2160 retCode = eSIR_SME_SUCCESS;
2161 disassocTrigger = eLIM_HOST_DISASSOC;
2162 goto sendDisassoc;
2163 }
2164 }
2165 break;
2166 default:
2167 /**
2168 * STA is not currently associated.
2169 * Log error and send response to host
2170 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002171 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002172 psessionEntry->limSmeState);
2173 lim_print_sme_state(pMac, LOGE,
2174 psessionEntry->limSmeState);
2175
2176 if (pMac->lim.gLimRspReqd) {
2177 if (psessionEntry->limSmeState !=
2178 eLIM_SME_WT_ASSOC_STATE)
2179 pMac->lim.gLimRspReqd = false;
2180
2181 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2182 disassocTrigger = eLIM_HOST_DISASSOC;
2183 goto sendDisassoc;
2184 }
2185
2186 return;
2187 }
2188
2189 break;
2190
2191 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002192 /* Fall through */
2193 break;
2194
2195 case eLIM_STA_IN_IBSS_ROLE:
2196 default:
2197 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002198 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002199 GET_LIM_SYSTEM_ROLE(psessionEntry));
2200
2201 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2202 disassocTrigger = eLIM_HOST_DISASSOC;
2203 goto sendDisassoc;
2204 } /* end switch (pMac->lim.gLimSystemRole) */
2205
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302206 disassocTrigger = eLIM_HOST_DISASSOC;
2207 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002208
2209 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002210 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002211 send_disassoc_frame = 0;
2212 }
2213 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002214 pe_debug("Sending Disasscoc with disassoc Trigger"
2215 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002216 disassocTrigger, reasonCode);
2217
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302218 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002219 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002220 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002221 return;
2222 }
2223
Anurag Chouhanc5548422016-02-24 18:33:27 +05302224 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002225 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002226
2227 pMlmDisassocReq->reasonCode = reasonCode;
2228 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2229
2230 /* Update PE session ID */
2231 pMlmDisassocReq->sessionId = sessionId;
2232
2233 lim_post_mlm_message(pMac,
2234 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2235 return;
2236
2237sendDisassoc:
2238 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002239 lim_send_sme_disassoc_ntf(pMac,
2240 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002241 retCode,
2242 disassocTrigger,
2243 1, smesessionId, smetransactionId,
2244 psessionEntry);
2245 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002246 lim_send_sme_disassoc_ntf(pMac,
2247 smeDisassocReq.peer_macaddr.bytes,
2248 retCode, disassocTrigger, 1,
2249 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002250
2251} /*** end __lim_process_sme_disassoc_req() ***/
2252
2253/** -----------------------------------------------------------------
2254 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2255
2256 This function is called to process SME_DISASSOC_CNF message
2257 from HDD or upper layer application.
2258
2259 \param pMac - global mac structure
2260 \param pStaDs - station dph hash node
2261 \return none
2262 \sa
2263 ----------------------------------------------------------------- */
2264static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2265{
2266 tSirSmeDisassocCnf smeDisassocCnf;
2267 uint16_t aid;
2268 tpDphHashNode pStaDs;
2269 tpPESession psessionEntry;
2270 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302271 uint32_t *msg = NULL;
2272 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002273
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302274 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002275 sizeof(struct sSirSmeDisassocCnf));
2276
2277 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002278 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002279 &sessionId);
2280 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002281 pe_err("session does not exist for given bssId");
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302282 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302283 smeDisassocCnf.sme_session_id,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302284 eSIR_SME_INVALID_SESSION,
2285 NULL);
2286 if (QDF_IS_STATUS_SUCCESS(status))
2287 lim_send_sme_disassoc_deauth_ntf(pMac,
2288 QDF_STATUS_SUCCESS,
2289 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002290 return;
2291 }
2292
2293 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002294 pe_err("received invalid SME_DISASSOC_CNF message");
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302295 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2296 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302297 eSIR_SME_INVALID_PARAMETERS,
2298 &smeDisassocCnf.bssid.bytes[0]);
2299 if (QDF_IS_STATUS_SUCCESS(status))
2300 lim_send_sme_disassoc_deauth_ntf(pMac,
2301 QDF_STATUS_SUCCESS,
2302 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002303 return;
2304 }
2305#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2306 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2307 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2308 psessionEntry,
2309 (uint16_t) smeDisassocCnf.statusCode, 0);
2310 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2311 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2312 psessionEntry,
2313 (uint16_t) smeDisassocCnf.statusCode, 0);
2314#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2315
2316 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2317 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002318 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2319 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2320 && (psessionEntry->limSmeState !=
2321 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002322 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002323 psessionEntry->limSmeState);
2324 lim_print_sme_state(pMac, LOGE,
2325 psessionEntry->limSmeState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302326 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302327 psessionEntry->smeSessionId,
2328 eSIR_SME_INVALID_STATE,
2329 &smeDisassocCnf.bssid.bytes[0]);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302330 if (QDF_IS_STATUS_SUCCESS(status))
2331 lim_send_sme_disassoc_deauth_ntf(pMac,
2332 QDF_STATUS_SUCCESS,
2333 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002334 return;
2335 }
2336 break;
2337
2338 case eLIM_AP_ROLE:
2339 /* Fall through */
2340 break;
2341
2342 case eLIM_STA_IN_IBSS_ROLE:
2343 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002344 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002345 GET_LIM_SYSTEM_ROLE(psessionEntry));
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302346 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2347 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302348 eSIR_SME_INVALID_STATE,
2349 &smeDisassocCnf.bssid.bytes[0]);
2350 if (QDF_IS_STATUS_SUCCESS(status))
2351 lim_send_sme_disassoc_deauth_ntf(pMac,
2352 QDF_STATUS_SUCCESS,
2353 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002354 return;
2355 }
2356
2357 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2358 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2359 LIM_IS_AP_ROLE(psessionEntry)) {
2360 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002361 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002362 &psessionEntry->dph.dphHashTable);
2363 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002364 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2365 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002366 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302367 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302368 psessionEntry->smeSessionId,
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05302369 eSIR_SME_INVALID_PARAMETERS,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302370 &smeDisassocCnf.bssid.bytes[0]);
2371 if (QDF_IS_STATUS_SUCCESS(status))
2372 lim_send_sme_disassoc_deauth_ntf(pMac,
2373 QDF_STATUS_SUCCESS,
2374 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002375 return;
2376 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302377
2378 if ((pStaDs->mlmStaContext.mlmState ==
2379 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2380 (pStaDs->mlmStaContext.mlmState ==
Arif Hussain5fa13782018-05-10 11:29:52 -07002381 eLIM_MLM_WT_DEL_BSS_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002382 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002383 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302384 pStaDs->mlmStaContext.mlmState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302385 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302386 psessionEntry->smeSessionId,
2387 eSIR_SME_SUCCESS,
2388 NULL);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302389 if (QDF_IS_STATUS_SUCCESS(status))
2390 lim_send_sme_disassoc_deauth_ntf(pMac,
2391 QDF_STATUS_SUCCESS,
2392 (uint32_t *)msg);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302393 return;
2394 }
2395
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002396 /* Delete FT session if there exists one */
2397 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002398 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2399
2400 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002401 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002402 }
2403
2404 return;
2405}
2406
2407/**
2408 * __lim_process_sme_deauth_req() - process sme deauth req
2409 * @mac_ctx: Pointer to Global MAC structure
2410 * @msg_buf: pointer to the SME message buffer
2411 *
2412 * This function is called to process SME_DEAUTH_REQ message
2413 * from HDD or upper layer application.
2414 *
2415 * Return: None
2416 */
2417
2418static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2419 uint32_t *msg_buf)
2420{
2421 uint16_t deauth_trigger, reason_code;
2422 tLimMlmDeauthReq *mlm_deauth_req;
2423 tSirSmeDeauthReq sme_deauth_req;
2424 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2425 tpPESession session_entry;
2426 uint8_t session_id; /* PE sessionId */
2427 uint8_t sme_session_id;
2428 uint16_t sme_transaction_id;
2429
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302430 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002431 sme_session_id = sme_deauth_req.sessionId;
2432 sme_transaction_id = sme_deauth_req.transactionId;
2433
2434 /*
2435 * We need to get a session first but we don't even know
2436 * if the message is correct.
2437 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002438 session_entry = pe_find_session_by_bssid(mac_ctx,
2439 sme_deauth_req.bssid.bytes,
2440 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002441 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002442 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002443 ret_code = eSIR_SME_INVALID_PARAMETERS;
2444 deauth_trigger = eLIM_HOST_DEAUTH;
2445 goto send_deauth;
2446 }
2447
2448 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2449 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002450 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002451 mac_ctx->lim.gLimRspReqd = false;
2452
2453 ret_code = eSIR_SME_INVALID_PARAMETERS;
2454 deauth_trigger = eLIM_HOST_DEAUTH;
2455 goto send_deauth;
2456 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002457 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2458 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002459 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2460 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002461 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002462#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2463 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2464 session_entry, 0, sme_deauth_req.reasonCode);
2465#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2466
2467 /* Update SME session ID and Transaction ID */
2468 session_entry->smeSessionId = sme_session_id;
2469 session_entry->transactionId = sme_transaction_id;
2470
2471 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2472 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002473 switch (session_entry->limSmeState) {
2474 case eLIM_SME_ASSOCIATED_STATE:
2475 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302476 /* Delete all TDLS peers connected before leaving BSS */
2477 lim_delete_tdls_peers(mac_ctx, session_entry);
Abhinav Kumarac12c762018-05-02 13:51:02 +05302478 /* fallthrough */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002479 case eLIM_SME_WT_ASSOC_STATE:
2480 case eLIM_SME_JOIN_FAILURE_STATE:
2481 case eLIM_SME_IDLE_STATE:
2482 session_entry->limPrevSmeState =
2483 session_entry->limSmeState;
2484 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2485 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2486 session_entry->peSessionId,
2487 session_entry->limSmeState));
2488 /* Send Deauthentication request to MLM below */
2489 break;
2490 case eLIM_SME_WT_DEAUTH_STATE:
2491 case eLIM_SME_WT_DISASSOC_STATE:
2492 /*
Jeff Johnson47d75242018-05-12 15:58:53 -07002493 * PE Received a Deauth/Disassoc frame. Normally it get
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002494 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2495 * Which means host is also trying to disconnect.
2496 * PE can continue processing DEAUTH_REQ and send
2497 * the response instead of failing the request.
2498 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2499 * was sent for deauth/disassoc frame.
2500 */
2501 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002502 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002503 break;
2504 default:
2505 /*
2506 * STA is not in a state to deauthenticate with
2507 * peer. Log error and send response to host.
2508 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002509 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002510 session_entry->limSmeState);
2511 lim_print_sme_state(mac_ctx, LOGE,
2512 session_entry->limSmeState);
2513
2514 if (mac_ctx->lim.gLimRspReqd) {
2515 mac_ctx->lim.gLimRspReqd = false;
2516
2517 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2518 deauth_trigger = eLIM_HOST_DEAUTH;
2519
wadesong42968e92017-06-08 14:11:21 +08002520 /*
2521 * here we received deauth request from AP so
2522 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2523 * have ISSUED delSta then mlm state should be
2524 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2525 * delBSS rsp then mlm state should be
2526 * eLIM_MLM_IDLE_STATE so the below condition
2527 * captures the state where delSta not done
2528 * and firmware still in connected state.
2529 */
2530 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002531 eLIM_SME_WT_DEAUTH_STATE &&
2532 session_entry->limMlmState !=
2533 eLIM_MLM_IDLE_STATE &&
2534 session_entry->limMlmState !=
2535 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002536 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002537 goto send_deauth;
2538 }
2539 return;
2540 }
2541 break;
2542
2543 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002544 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002545 if (mac_ctx->lim.gLimRspReqd) {
2546 mac_ctx->lim.gLimRspReqd = false;
2547 ret_code = eSIR_SME_INVALID_PARAMETERS;
2548 deauth_trigger = eLIM_HOST_DEAUTH;
2549 goto send_deauth;
2550 }
2551 return;
2552 case eLIM_AP_ROLE:
2553 break;
2554 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002555 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002556 GET_LIM_SYSTEM_ROLE(session_entry));
2557 if (mac_ctx->lim.gLimRspReqd) {
2558 mac_ctx->lim.gLimRspReqd = false;
2559 ret_code = eSIR_SME_INVALID_PARAMETERS;
2560 deauth_trigger = eLIM_HOST_DEAUTH;
2561 goto send_deauth;
2562 }
2563 return;
2564 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2565
2566 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2567 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002568 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002569 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2570 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2571 } else {
2572 deauth_trigger = eLIM_HOST_DEAUTH;
2573 reason_code = sme_deauth_req.reasonCode;
2574 }
2575
2576 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302577 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002578 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002579 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002580 if (mac_ctx->lim.gLimRspReqd) {
2581 mac_ctx->lim.gLimRspReqd = false;
2582 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2583 deauth_trigger = eLIM_HOST_DEAUTH;
2584 goto send_deauth;
2585 }
2586 return;
2587 }
2588
Anurag Chouhanc5548422016-02-24 18:33:27 +05302589 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002590 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002591
2592 mlm_deauth_req->reasonCode = reason_code;
2593 mlm_deauth_req->deauthTrigger = deauth_trigger;
2594
2595 /* Update PE session Id */
2596 mlm_deauth_req->sessionId = session_id;
2597
2598 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2599 (uint32_t *)mlm_deauth_req);
2600 return;
2601
2602send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002603 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2604 ret_code, deauth_trigger, 1,
2605 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606}
2607
2608/**
2609 * __lim_process_sme_set_context_req()
2610 *
2611 * @mac_ctx: Pointer to Global MAC structure
2612 * @msg_buf: pointer to the SME message buffer
2613 *
2614 * This function is called to process SME_SETCONTEXT_REQ message
2615 * from HDD or upper layer application.
2616 *
2617 * Return: None
2618 */
2619
2620static void
2621__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2622{
2623 tpSirSmeSetContextReq set_context_req;
2624 tLimMlmSetKeysReq *mlm_set_key_req;
2625 tpPESession session_entry;
2626 uint8_t session_id; /* PE sessionID */
2627 uint8_t sme_session_id;
2628 uint16_t sme_transaction_id;
2629
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002630 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002631 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002632 return;
2633 }
2634
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302635 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002636 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002637 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002638 return;
2639 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302640 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002641 sizeof(struct sSirSmeSetContextReq));
2642 sme_session_id = set_context_req->sessionId;
2643 sme_transaction_id = set_context_req->transactionId;
2644
2645 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002646 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002647 goto end;
2648 }
2649
2650 if (set_context_req->keyMaterial.numKeys >
2651 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002652 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002653 set_context_req->keyMaterial.numKeys);
2654 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002655 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002656 eSIR_SME_INVALID_PARAMETERS, NULL,
2657 sme_session_id, sme_transaction_id);
2658 goto end;
2659 }
2660
2661 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002662 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002663 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002664 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002665 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002666 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002667 eSIR_SME_INVALID_PARAMETERS, NULL,
2668 sme_session_id, sme_transaction_id);
2669 goto end;
2670 }
2671#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2672 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2673 session_entry, 0, 0);
2674#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2675
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002676 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002677 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2678 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002679 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002680 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2681 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302682 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002683 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002684 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002685 goto end;
2686 }
2687 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2688 mlm_set_key_req->numKeys =
2689 set_context_req->keyMaterial.numKeys;
2690 if (mlm_set_key_req->numKeys >
2691 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002692 pe_err("no.of keys exceeded max num of default keys limit");
Jingxiang Ge4168a232018-01-03 18:47:15 +08002693 qdf_mem_free(mlm_set_key_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002694 goto end;
2695 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302696 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002697 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002698
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302699 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002700 (uint8_t *) &set_context_req->keyMaterial.key,
2701 sizeof(tSirKeys) *
2702 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2703 numKeys : 1));
2704
2705 mlm_set_key_req->sessionId = session_id;
2706 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002707 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002708 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002709
2710 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2711 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2712 LIM_IS_AP_ROLE(session_entry)) {
2713 if (set_context_req->keyMaterial.key[0].keyLength) {
2714 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002715
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002716 key_id =
2717 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302718 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002719 &session_entry->WEPKeyMaterial[key_id],
2720 (uint8_t *) &set_context_req->keyMaterial,
2721 sizeof(tSirKeyMaterial));
2722 } else {
2723 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002724
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002725 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2726 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302727 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002728 &mlm_set_key_req->key[i],
2729 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2730 sizeof(tSirKeys));
2731 }
2732 }
2733 }
2734 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2735 (uint32_t *) mlm_set_key_req);
2736 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002737 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002738 GET_LIM_SYSTEM_ROLE(session_entry),
2739 session_entry->limSmeState);
2740 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2741
2742 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002743 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002744 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2745 session_entry, sme_session_id,
2746 sme_transaction_id);
2747 }
2748end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302749 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002750 return;
2751}
2752
2753/**
2754 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2755 *
2756 * @mac_ctx: Pointer to Global MAC structure
2757 * @msg_buf: pointer to the SME message buffer
2758 *
2759 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2760 * from HDD or upper layer application.
2761 *
2762 * Return: None
2763 */
2764
Jeff Johnson801f1532016-10-07 07:54:50 -07002765static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2766 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002767{
2768 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2769 tpDphHashNode sta_ds = NULL;
2770 tpPESession session_entry = NULL;
2771 tSap_Event sap_event;
2772 tpWLAN_SAPEventCB sap_event_cb = NULL;
2773 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2774 uint8_t session_id = CSR_SESSION_ID_INVALID;
2775 uint8_t assoc_id = 0;
2776 uint8_t sta_cnt = 0;
2777
2778 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002779 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002780 return;
2781 }
2782
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302783 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002784 sizeof(struct sSirSmeGetAssocSTAsReq));
2785 /*
2786 * Get Associated stations from PE.
2787 * Find PE session Entry
2788 */
2789 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08002790 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002791 &session_id);
2792 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002793 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002794 goto lim_assoc_sta_end;
2795 }
2796
2797 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002798 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002799 session_entry->limSmeState,
2800 GET_LIM_SYSTEM_ROLE(session_entry));
2801 goto lim_assoc_sta_end;
2802 }
2803 /* Retrieve values obtained in the request message */
2804 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
2805 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2806
2807 if (NULL == assoc_sta_tmp)
2808 goto lim_assoc_sta_end;
2809 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
2810 assoc_id++) {
2811 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
2812 &session_entry->dph.dphHashTable);
2813 if (NULL == sta_ds)
2814 continue;
2815 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302816 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002817 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302818 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002819 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
2820 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
2821
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302822 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002823 (uint8_t *)&sta_ds->supportedRates,
2824 sizeof(tSirSupportedRates));
2825 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
2826 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
2827 assoc_sta_tmp->Support40Mhz =
2828 sta_ds->htDsssCckRate40MHzSupport;
2829
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002830 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002831 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002832 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002833 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002834 pe_debug("Association Id: %d Station Index: %d",
2835 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002836 assoc_sta_tmp++;
2837 sta_cnt++;
2838 }
2839 }
2840lim_assoc_sta_end:
2841 /*
2842 * Call hdd callback with sap event to send the list of
2843 * associated stations from PE
2844 */
2845 if (sap_event_cb != NULL) {
2846 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
2847 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302848 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002849 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
2850 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
2851 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2852 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
2853 }
2854}
2855
2856/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002857 * __lim_counter_measures()
2858 *
2859 * FUNCTION:
2860 * This function is called to "implement" MIC counter measure
2861 * and is *temporary* only
2862 *
2863 * LOGIC: on AP, disassoc all STA associated thru TKIP,
2864 * we don't do the proper STA disassoc sequence since the
Jeff Johnsond460e842018-05-11 13:25:53 -07002865 * BSS will be stopped anyway
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002866 *
2867 ***ASSUMPTIONS:
2868 *
2869 ***NOTE:
2870 *
2871 * @param pMac Pointer to Global MAC structure
2872 * @return None
2873 */
2874
2875static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
2876{
2877 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002878
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002879 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002880 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
2881 mac, psessionEntry, false);
2882};
2883
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002884static void
2885__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2886{
2887 tSirSmeStopBssReq stopBssReq;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002888 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002889 tLimSmeStates prevState;
2890 tpPESession psessionEntry;
2891 uint8_t smesessionId;
2892 uint8_t sessionId;
2893 uint16_t smetransactionId;
2894 uint8_t i = 0;
2895 tpDphHashNode pStaDs = NULL;
2896
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302897 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002898 smesessionId = stopBssReq.sessionId;
2899 smetransactionId = stopBssReq.transactionId;
2900
2901 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002902 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002903 /* Send Stop BSS response to host */
2904 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2905 eSIR_SME_INVALID_PARAMETERS, smesessionId,
2906 smetransactionId);
2907 return;
2908 }
2909
2910 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08002911 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002912 &sessionId);
2913 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002914 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002915 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2916 eSIR_SME_INVALID_PARAMETERS, smesessionId,
2917 smetransactionId);
2918 return;
2919 }
2920#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2921 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
2922 0, 0);
2923#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2924
2925 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
2926 LIM_IS_STA_ROLE(psessionEntry)) {
2927 /**
2928 * Should not have received STOP_BSS_REQ in states
2929 * other than 'normal' state or on STA in Infrastructure
2930 * mode. Log error and return response to host.
2931 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002932 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002933 psessionEntry->limSmeState,
2934 GET_LIM_SYSTEM_ROLE(psessionEntry));
2935 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
2936 /* / Send Stop BSS response to host */
2937 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2938 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
2939 smetransactionId);
2940 return;
2941 }
2942
2943 if (LIM_IS_AP_ROLE(psessionEntry))
2944 lim_wpspbc_close(pMac, psessionEntry);
2945
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002946 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002947 stopBssReq.reasonCode);
2948
2949 prevState = psessionEntry->limSmeState;
2950
2951 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
2952 MTRACE(mac_trace
2953 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
2954 psessionEntry->limSmeState));
2955
2956 /* Update SME session Id and Transaction Id */
2957 psessionEntry->smeSessionId = smesessionId;
2958 psessionEntry->transactionId = smetransactionId;
2959
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002960 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
2961 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
2962 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002963 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002964
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002965 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
2966 /* Send disassoc all stations associated thru TKIP */
2967 __lim_counter_measures(pMac, psessionEntry);
2968 else
2969 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002970 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
2971 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002972 }
2973
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002974 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
2975 /* Free the buffer allocated in START_BSS_REQ */
2976 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
2977 psessionEntry->addIeParams.probeRespDataLen = 0;
2978 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002979
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002980 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
2981 psessionEntry->addIeParams.assocRespDataLen = 0;
2982 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002983
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002984 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
2985 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
2986 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002987
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002988 /*
2989 * lim_del_bss is also called as part of coalescing,
2990 * when we send DEL BSS followed by Add Bss msg.
2991 */
2992 pMac->lim.gLimIbssCoalescingHappened = false;
2993 }
Sandeep Puligillaa894ffc2018-06-01 15:33:36 -07002994 for (i = 1; i < psessionEntry->dph.dphHashTable.size; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002995 pStaDs =
2996 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
2997 if (NULL == pStaDs)
2998 continue;
2999 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003000 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003001 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3002 pStaDs->assocId, psessionEntry);
3003 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3004 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003005 pe_err("lim_del_sta failed with Status: %d", status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303006 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003007 }
3008 }
3009 /* send a delBss to HAL and wait for a response */
3010 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3011
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003012 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003013 pe_err("delBss failed for bss %d", psessionEntry->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003014 psessionEntry->limSmeState = prevState;
3015
3016 MTRACE(mac_trace
3017 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3018 psessionEntry->limSmeState));
3019
3020 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3021 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3022 smetransactionId);
3023 }
3024}
3025
3026/**
3027 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3028 * @pMac: Global MAC context
3029 * @pMsg: Message from SME
3030 *
3031 * Wrapper for the function __lim_handle_sme_stop_bss_request
3032 * This message will be defered until softmac come out of
3033 * scan mode. Message should be handled even if we have
3034 * detected radar in the current operating channel.
3035 *
3036 * Return: true - If we consumed the buffer
3037 * false - If have defered the message.
3038 */
3039
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003040static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3041 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003042{
3043 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3044 /**
3045 * If message defered, buffer is not consumed yet.
3046 * So return false
3047 */
3048 return false;
3049 }
3050 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3051 return true;
3052} /*** end __lim_process_sme_stop_bss_req() ***/
3053
3054void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3055 uint32_t body, tpPESession psessionEntry)
3056{
3057
3058 (void)body;
3059 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3060 lim_ibss_delete(pMac, psessionEntry);
3061 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3062 lim_delete_pre_auth_list(pMac);
3063 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3064 psessionEntry->smeSessionId,
3065 psessionEntry->transactionId);
3066 return;
3067}
3068
3069/**
3070 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3071 *
3072 * @mac_ctx: pointer to mac context
3073 * @msg_type: message type
3074 * @msg_buf: pointer to the SME message buffer
3075 *
3076 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3077 * in BTAMP AP.
3078 *
3079 * Return: None
3080 */
3081
3082void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3083 uint32_t *msg_buf)
3084{
3085 tSirSmeAssocCnf assoc_cnf;
3086 tpDphHashNode sta_ds = NULL;
3087 tpPESession session_entry = NULL;
3088 uint8_t session_id;
3089 tpSirAssocReq assoc_req;
3090
3091 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003092 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003093 goto end;
3094 }
3095
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303096 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003097 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003098 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003099 goto end;
3100 }
3101
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003102 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003103 &session_id);
3104 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003105 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003106 goto end;
3107 }
3108
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003109 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003110 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3111 (session_entry->limSmeState !=
3112 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003113 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003114 msg_type, session_entry->limSmeState,
3115 GET_LIM_SYSTEM_ROLE(session_entry));
3116 goto end;
3117 }
3118 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3119 &session_entry->dph.dphHashTable);
3120 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003121 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003122 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303123 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003124
3125 /*
3126 * send a DISASSOC_IND message to WSM to make sure
3127 * the state in WSM and LIM is the same
3128 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003129 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130 eSIR_SME_STA_NOT_ASSOCIATED,
3131 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3132 session_entry->smeSessionId,
3133 session_entry->transactionId,
3134 session_entry);
3135 goto end;
3136 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303137 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003138 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303139 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003140 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003141 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303142 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003143 goto end;
3144 }
3145
3146 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3147 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3148 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3149 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3150 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003151 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3152 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003153 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303154 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003155 goto end;
3156 }
3157 /*
3158 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3159 * has been received
3160 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003161 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003162 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3163 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3164
3165 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3166 /*
3167 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3168 * when it had received Assoc Request frame. Now, PE just needs
3169 * to send association rsp frame to the requesting BTAMP-STA.
3170 */
3171 sta_ds->mlmStaContext.mlmState =
3172 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003173 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003174 sta_ds->assocId);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003175 lim_send_assoc_rsp_mgmt_frame(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003176 sta_ds->assocId, sta_ds->staAddr,
3177 sta_ds->mlmStaContext.subType, sta_ds,
3178 session_entry);
3179 goto end;
3180 } else {
3181 /*
3182 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3183 * to be associated since the HAL sta entry is created for
3184 * denied STA we need to remove this HAL entry.
3185 * So to do that set updateContext to 1
3186 */
3187 if (!sta_ds->mlmStaContext.updateContext)
3188 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003189 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003190 assoc_cnf.statusCode, sta_ds->assocId);
3191 lim_reject_association(mac_ctx, sta_ds->staAddr,
3192 sta_ds->mlmStaContext.subType,
3193 true, sta_ds->mlmStaContext.authType,
3194 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003195 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003196 session_entry);
3197 }
3198end:
3199 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3200 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3201 assoc_req = (tpSirAssocReq)
3202 session_entry->parsedAssocReq[sta_ds->assocId];
3203 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303204 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003205 assoc_req->assocReqFrame = NULL;
3206 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303207 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003208 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3209 }
3210}
3211
3212static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3213{
3214 tpDphHashNode pStaDs;
3215 tSirMacAddr peerMac;
3216 tpSirAddtsReq pSirAddts;
3217 uint32_t timeout;
3218 tpPESession psessionEntry;
3219 uint8_t sessionId; /* PE sessionId */
3220 uint8_t smesessionId;
3221 uint16_t smetransactionId;
3222
3223 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003224 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003225 return;
3226 }
3227
3228 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3229 &smetransactionId);
3230
3231 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3232
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003233 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3234 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003235 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003236 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003237 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303238 NULL, pSirAddts->req.tspec,
3239 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003240 return;
3241 }
3242#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3243 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3244 0);
3245#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3246
3247 /* if sta
3248 * - verify assoc state
3249 * - send addts request to ap
3250 * - wait for addts response from ap
3251 * if ap, just ignore with error log
3252 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003253 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3254 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3255 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003256
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003257 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003258 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303259 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003260 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003261
3262 pStaDs =
3263 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3264 &psessionEntry->dph.dphHashTable);
3265
3266 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003267 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303268 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003269 }
3270
3271 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3272 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003273 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303274 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003275 }
3276
3277 pSirAddts->req.wsmTspecPresent = 0;
3278 pSirAddts->req.wmeTspecPresent = 0;
3279 pSirAddts->req.lleTspecPresent = 0;
3280
3281 if ((pStaDs->wsmEnabled) &&
3282 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3283 SIR_MAC_ACCESSPOLICY_EDCA))
3284 pSirAddts->req.wsmTspecPresent = 1;
3285 else if (pStaDs->wmeEnabled)
3286 pSirAddts->req.wmeTspecPresent = 1;
3287 else if (pStaDs->lleEnabled)
3288 pSirAddts->req.lleTspecPresent = 1;
3289 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003290 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303291 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003292 }
3293
3294 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3295 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003296 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003297 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303298 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003299 }
3300
3301 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003302 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003303 pMac->lim.gLimAddtsReq.req.dialogToken,
3304 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3305 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3306 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303307 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003308 }
3309
3310 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3311
3312 /* save the addts request */
3313 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303314 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003315 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3316
3317 /* ship out the message now */
3318 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3319 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303320 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321 /* start a timer to wait for the response */
3322 if (pSirAddts->timeout)
3323 timeout = pSirAddts->timeout;
3324 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003325 QDF_STATUS_SUCCESS) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303326 pe_debug("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003327 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303328 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003329 }
3330
3331 timeout = SYS_MS_TO_TICKS(timeout);
3332 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3333 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003334 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303335 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003336 }
3337 pMac->lim.gLimAddtsRspTimerCount++;
3338 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3339 pMac->lim.gLimAddtsRspTimerCount) !=
3340 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003341 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303342 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003343 }
3344 MTRACE(mac_trace
3345 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3346 eLIM_ADDTS_RSP_TIMER));
3347
3348 /* add the sessionId to the timer object */
3349 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3350 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3351 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003352 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303353 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003354 }
3355 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303356
3357send_failure_addts_rsp:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003358 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303359 psessionEntry, pSirAddts->req.tspec,
3360 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003361}
3362
3363static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3364{
3365 tSirMacAddr peerMacAddr;
3366 uint8_t ac;
3367 tSirMacTSInfo *pTsinfo;
3368 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3369 tpDphHashNode pStaDs = NULL;
3370 tpPESession psessionEntry;
3371 uint8_t sessionId;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003372 uint32_t status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003373 uint8_t smesessionId;
3374 uint16_t smetransactionId;
3375
3376 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3377 &smetransactionId);
3378
3379 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003380 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003381 &sessionId);
3382 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003383 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003384 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003385 goto end;
3386 }
3387#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3388 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3389 0);
3390#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3391
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003392 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003393 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003394 pe_err("lim_validate_delts_req failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003395 status = QDF_STATUS_E_FAILURE;
3396 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_E_FAILURE, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003397 smesessionId, smetransactionId);
3398 return;
3399 }
3400
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003401 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3402 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003403 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3404
3405 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3406 pDeltsReq->req.wmeTspecPresent,
3407 &pDeltsReq->req.tsinfo,
3408 &pDeltsReq->req.tspec, psessionEntry);
3409
3410 pTsinfo =
3411 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3412 tsinfo : &pDeltsReq->req.tsinfo;
3413
3414 /* We've successfully send DELTS frame to AP. Update the
3415 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3416 * is no longer trigger enabled or delivery enabled
3417 */
3418 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3419 pTsinfo, CLEAR_UAPSD_MASK);
3420
3421 /* We're deleting the TSPEC, so this particular AC is no longer
3422 * admitted. PE needs to downgrade the EDCA
3423 * parameters(for the AC for which TS is being deleted) to the
3424 * next best AC for which ACM is not enabled, and send the
3425 * updated values to HAL.
3426 */
3427 ac = upToAc(pTsinfo->traffic.userPrio);
3428
3429 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3430 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3431 ~(1 << ac);
3432 } else if (pTsinfo->traffic.direction ==
3433 SIR_MAC_DIRECTION_DNLINK) {
3434 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3435 ~(1 << ac);
3436 } else if (pTsinfo->traffic.direction ==
3437 SIR_MAC_DIRECTION_BIDIR) {
3438 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3439 ~(1 << ac);
3440 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3441 ~(1 << ac);
3442 }
3443
3444 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3445 psessionEntry);
3446
3447 pStaDs =
3448 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3449 &psessionEntry->dph.dphHashTable);
3450 if (pStaDs != NULL) {
3451 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003452 pStaDs->bssId, false);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003453 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003454 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003455 pe_err("Self entry missing in Hash Table");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003456 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003457 }
3458#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003459 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003460#endif
3461
3462 /* send an sme response back */
3463end:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003464 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_SUCCESS, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003465 smesessionId, smetransactionId);
3466}
3467
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303468void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003469{
3470 /* fetch the sessionEntry based on the sessionId */
3471 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003472
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003473 psessionEntry = pe_find_session_by_session_id(pMac,
3474 pMac->lim.limTimers.gLimAddtsRspTimer.
3475 sessionId);
3476 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003477 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003478 return;
3479 }
3480
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003481 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003482 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003483 GET_LIM_SYSTEM_ROLE(psessionEntry));
3484 pMac->lim.gLimAddtsSent = false;
3485 return;
3486 }
3487
3488 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003489 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003490 return;
3491 }
3492
3493 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003494 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003495 pMac->lim.gLimAddtsRspTimerCount);
3496 return;
3497 }
3498 /* this a real response timeout */
3499 pMac->lim.gLimAddtsSent = false;
3500 pMac->lim.gLimAddtsRspTimerCount++;
3501
3502 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3503 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3504 psessionEntry->smeSessionId,
3505 psessionEntry->transactionId);
3506}
3507
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003508#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003509/**
3510 * __lim_process_sme_get_statistics_request()
3511 *
3512 ***FUNCTION:
3513 *
3514 *
3515 ***NOTE:
3516 *
3517 * @param pMac Pointer to Global MAC structure
3518 * @param *pMsgBuf A pointer to the SME message buffer
3519 * @return None
3520 */
3521static void
3522__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3523{
3524 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003525 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003526
3527 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3528
3529 msgQ.type = WMA_GET_STATISTICS_REQ;
3530
3531 msgQ.reserved = 0;
3532 msgQ.bodyptr = pMsgBuf;
3533 msgQ.bodyval = 0;
3534 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3535
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003536 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303537 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003538 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003539 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003540 return;
3541 }
3542
3543 return;
3544}
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003545#else
3546static void __lim_process_sme_get_statistics_request(
3547 struct sAniSirGlobal *mac_ctx, uint32_t *pMsgBuf) {}
3548#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003549
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003550#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003551/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003552 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003553 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003554 * @pMac: Pointer to Global MAC structure
3555 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003556 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003557 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003558 */
3559static void
3560__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3561{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003562 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003563
3564 msgQ.type = WMA_TSM_STATS_REQ;
3565 msgQ.reserved = 0;
3566 msgQ.bodyptr = pMsgBuf;
3567 msgQ.bodyval = 0;
3568 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3569
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003570 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303571 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003572 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003573 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003574 return;
3575 }
3576}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003577#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003578
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08003579static void lim_process_sme_set_addba_accept(tpAniSirGlobal mac_ctx,
3580 struct sme_addba_accept *msg)
3581{
3582 if (!msg) {
3583 pe_err("Msg Buffer is NULL");
3584 return;
3585 }
3586 if (!msg->addba_accept)
3587 mac_ctx->reject_addba_req = 1;
3588 else
3589 mac_ctx->reject_addba_req = 0;
3590}
3591
Arif Hussaineb8ba362018-03-07 19:15:13 -08003592static void lim_process_sme_update_edca_params(tpAniSirGlobal mac_ctx,
3593 uint32_t sme_session_id)
3594{
3595 tpPESession pe_session;
3596 tpDphHashNode sta_ds_ptr;
3597
3598 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3599 if (!pe_session) {
3600 pe_err("Session does not exist: sme_id %d", sme_session_id);
3601 return;
3602 }
3603 pe_session->gLimEdcaParamsActive[EDCA_AC_BE].no_ack =
3604 mac_ctx->no_ack_policy_cfg[EDCA_AC_BE];
3605 pe_session->gLimEdcaParamsActive[EDCA_AC_BK].no_ack =
3606 mac_ctx->no_ack_policy_cfg[EDCA_AC_BK];
3607 pe_session->gLimEdcaParamsActive[EDCA_AC_VI].no_ack =
3608 mac_ctx->no_ack_policy_cfg[EDCA_AC_VI];
3609 pe_session->gLimEdcaParamsActive[EDCA_AC_VO].no_ack =
3610 mac_ctx->no_ack_policy_cfg[EDCA_AC_VO];
3611 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3612 &pe_session->dph.dphHashTable);
3613 if (sta_ds_ptr)
3614 lim_send_edca_params(mac_ctx,
3615 pe_session->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003616 sta_ds_ptr->bssId, false);
Arif Hussaineb8ba362018-03-07 19:15:13 -08003617 else
3618 pe_err("Self entry missing in Hash Table");
3619}
3620
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07003621static void lim_process_sme_update_mu_edca_params(tpAniSirGlobal mac_ctx,
3622 uint32_t sme_session_id)
3623{
3624 tpPESession pe_session;
3625 tpDphHashNode sta_ds_ptr;
3626
3627 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3628 if (!pe_session) {
3629 pe_err("Session does not exist: sme_id %d", sme_session_id);
3630 return;
3631 }
3632 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3633 &pe_session->dph.dphHashTable);
3634 if (sta_ds_ptr)
3635 lim_send_edca_params(mac_ctx, mac_ctx->usr_mu_edca_params,
3636 sta_ds_ptr->bssId, true);
3637 else
3638 pe_err("Self entry missing in Hash Table");
3639}
3640
Naveen Rawat8029a402017-06-01 10:54:19 -07003641static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3642 struct update_config *msg)
3643{
3644 tpPESession pe_session;
3645
3646 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3647 if (msg == NULL) {
3648 pe_err("Buffer is Pointing to NULL");
3649 return;
3650 }
3651
3652 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3653 msg->sme_session_id);
3654 if (pe_session == NULL) {
3655 pe_warn("Session does not exist for given BSSID");
3656 return;
3657 }
3658
3659 switch (msg->capab) {
3660 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3661 pe_session->htConfig.ht_rx_ldpc = msg->value;
3662 break;
3663 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3664 pe_session->htConfig.ht_tx_stbc = msg->value;
3665 break;
3666 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3667 pe_session->htConfig.ht_rx_stbc = msg->value;
3668 break;
3669 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3670 pe_session->htConfig.ht_sgi20 = msg->value;
3671 break;
3672 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3673 pe_session->htConfig.ht_sgi40 = msg->value;
3674 break;
3675 }
3676
3677 if (LIM_IS_AP_ROLE(pe_session)) {
3678 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3679 lim_send_beacon_ind(mac_ctx, pe_session);
3680 }
3681}
3682
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003683void
3684lim_send_vdev_restart(tpAniSirGlobal pMac,
3685 tpPESession psessionEntry, uint8_t sessionId)
3686{
3687 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003688 struct scheduler_msg msgQ = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003689 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003690
3691 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003692 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003693 return;
3694 }
3695
3696 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303697 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003698 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003699 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003700 return;
3701 }
3702
3703 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3704 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003705 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003706
3707 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3708 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3709 msgQ.bodyval = 0;
3710
3711 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003712 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003713 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303714 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003715 }
3716}
3717
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303718/**
3719 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3720 * @mac_ctx: Pointer to Global MAC structure
3721 * @msg_buf: Pointer to SME message buffer
3722 *
3723 * Return: None
3724 */
3725static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3726 uint32_t *msg_buf)
3727{
3728 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003729 struct scheduler_msg wma_msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003730 QDF_STATUS status;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303731 tSirRoamOffloadScanReq *req_buffer;
3732 uint16_t local_ie_len;
3733 uint8_t *local_ie_buf;
3734
3735 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3736 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3737 req_buffer->sessionId);
3738
3739 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3740 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003741 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303742 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303743 return;
3744 }
3745
3746 local_ie_len = req_buffer->assoc_ie.length;
3747 /* Update ext cap IE if present */
3748 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003749 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3750 local_ie_buf, &local_ie_len)) {
3751 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003752 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3753 req_buffer->assoc_ie.length = local_ie_len;
3754 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3755 local_ie_buf, local_ie_len);
3756 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303757 }
3758 qdf_mem_free(local_ie_buf);
3759
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303760 if (pe_session)
3761 lim_update_fils_rik(pe_session, req_buffer);
3762
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303763 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3764 wma_msg.bodyptr = req_buffer;
3765
3766 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003767 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003768 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303769 qdf_mem_free(req_buffer);
3770 }
3771}
3772
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303773/*
3774 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3775 * @mac_ctx: Pointer to global mac context
3776 * @session: Pointer to PE session
3777 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3778 * 1 - Disable broadcast SSID
3779 *
3780 * Return: None
3781 */
3782static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3783 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003784{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003785 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003786 session->ssidHidden, ssid_hidden);
3787
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003788 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303789 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003790 } else {
3791 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05303792 return;
3793 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003794
3795 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303796 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003797
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003798 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303799}
3800
3801/**
3802 * __lim_process_sme_session_update - process SME session update msg
3803 *
3804 * @mac_ctx: Pointer to global mac context
3805 * @msg_buf: Pointer to the received message buffer
3806 *
3807 * Return: None
3808 */
3809static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
3810 uint32_t *msg_buf)
3811{
3812 struct sir_update_session_param *msg;
3813 tpPESession session;
3814
3815 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003816 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303817 return;
3818 }
3819
3820 msg = (struct sir_update_session_param *) msg_buf;
3821
3822 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
3823 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003824 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303825 msg->session_id);
3826 return;
3827 }
3828
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003829 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303830 msg->param_type, msg->param_val);
3831 switch (msg->param_type) {
3832 case SIR_PARAM_SSID_HIDDEN:
3833 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
3834 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303835 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
3836 session->ignore_assoc_disallowed = msg->param_val;
3837 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303838 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003839 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303840 break;
3841 }
3842}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003843
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003844/*
3845 Update the beacon Interval dynamically if beaconInterval is different in MCC
3846 */
3847static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3848{
3849 tpSirChangeBIParams pChangeBIParams;
3850 tpPESession psessionEntry;
3851 uint8_t sessionId = 0;
3852 tUpdateBeaconParams beaconParams;
3853
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003854 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003855
3856 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003857 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003858 return;
3859 }
3860
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303861 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003862 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
3863
3864 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08003865 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003866 &sessionId);
3867 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003868 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003869 return;
3870 }
3871
3872 /*Update sessionEntry Beacon Interval */
3873 if (psessionEntry->beaconParams.beaconInterval !=
3874 pChangeBIParams->beaconInterval) {
3875 psessionEntry->beaconParams.beaconInterval =
3876 pChangeBIParams->beaconInterval;
3877 }
3878
3879 /*Update sch beaconInterval */
3880 if (pMac->sch.schObject.gSchBeaconInterval !=
3881 pChangeBIParams->beaconInterval) {
3882 pMac->sch.schObject.gSchBeaconInterval =
3883 pChangeBIParams->beaconInterval;
3884
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003885 pe_debug("LIM send update BeaconInterval Indication: %d",
3886 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003887
3888 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
3889 /* Update beacon */
3890 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3891
3892 beaconParams.bssIdx = psessionEntry->bssIdx;
3893 /* Set change in beacon Interval */
3894 beaconParams.beaconInterval =
3895 pChangeBIParams->beaconInterval;
3896 beaconParams.paramChangeBitmap =
3897 PARAM_BCN_INTERVAL_CHANGED;
3898 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
3899 }
3900 }
3901
3902 return;
3903} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
3904
3905#ifdef QCA_HT_2040_COEX
3906static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
3907 uint32_t *pMsgBuf)
3908{
3909 tpSirSetHT2040Mode pSetHT2040Mode;
3910 tpPESession psessionEntry;
3911 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003912 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003913 tUpdateVHTOpMode *pHtOpMode = NULL;
3914 uint16_t staId = 0;
3915 tpDphHashNode pStaDs = NULL;
3916
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003917 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003918 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003919 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003920 return;
3921 }
3922
3923 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
3924
3925 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08003926 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003927 &sessionId);
3928 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003929 pe_debug("Session does not exist for given BSSID");
3930 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003931 return;
3932 }
3933
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003934 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003935 pSetHT2040Mode->cbMode);
3936 /*Update sessionEntry HT related fields */
3937 switch (pSetHT2040Mode->cbMode) {
3938 case PHY_SINGLE_CHANNEL_CENTERED:
3939 psessionEntry->htSecondaryChannelOffset =
3940 PHY_SINGLE_CHANNEL_CENTERED;
3941 psessionEntry->htRecommendedTxWidthSet = 0;
3942 if (pSetHT2040Mode->obssEnabled)
3943 psessionEntry->htSupportedChannelWidthSet
3944 = eHT_CHANNEL_WIDTH_40MHZ;
3945 else
3946 psessionEntry->htSupportedChannelWidthSet
3947 = eHT_CHANNEL_WIDTH_20MHZ;
3948 break;
3949 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
3950 psessionEntry->htSecondaryChannelOffset =
3951 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3952 psessionEntry->htRecommendedTxWidthSet = 1;
3953 break;
3954 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
3955 psessionEntry->htSecondaryChannelOffset =
3956 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3957 psessionEntry->htRecommendedTxWidthSet = 1;
3958 break;
3959 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003960 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003961 return;
3962 }
3963
3964 /* Update beacon */
3965 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3966 lim_send_beacon_ind(pMac, psessionEntry);
3967
3968 /* update OP Mode for each associated peer */
3969 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
3970 pStaDs = dph_get_hash_entry(pMac, staId,
3971 &psessionEntry->dph.dphHashTable);
3972 if (NULL == pStaDs)
3973 continue;
3974
3975 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303976 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003977 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003978 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003979 return;
3980 }
3981 pHtOpMode->opMode =
3982 (psessionEntry->htSecondaryChannelOffset ==
3983 PHY_SINGLE_CHANNEL_CENTERED) ?
3984 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
3985 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303986 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003987 sizeof(tSirMacAddr));
3988 pHtOpMode->smesessionId = sessionId;
3989
3990 msg.type = WMA_UPDATE_OP_MODE;
3991 msg.reserved = 0;
3992 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003993 if (!QDF_IS_STATUS_SUCCESS
3994 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
3995 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303996 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003997 return;
3998 }
Jeff Johnson47d75242018-05-12 15:58:53 -07003999 pe_debug("Notified FW about OP mode: %d for staId=%d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004000 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004001
4002 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004003 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004004 }
4005
4006 return;
4007}
4008#endif
4009
4010/* -------------------------------------------------------------------- */
4011/**
4012 * __lim_process_report_message
4013 *
4014 * FUNCTION: Processes the next received Radio Resource Management message
4015 *
4016 * LOGIC:
4017 *
4018 * ASSUMPTIONS:
4019 *
4020 * NOTE:
4021 *
4022 * @param None
4023 * @return None
4024 */
4025
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004026static void __lim_process_report_message(tpAniSirGlobal pMac,
4027 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004028{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004029 switch (pMsg->type) {
4030 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4031 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4032 break;
4033 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004034 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004035 break;
4036 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004037 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004038 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004039}
4040
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004041/* -------------------------------------------------------------------- */
4042/**
4043 * lim_send_set_max_tx_power_req
4044 *
4045 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4046 *
4047 * LOGIC:
4048 *
4049 * ASSUMPTIONS:
4050 *
4051 * NOTE:
4052 *
4053 * @param txPower txPower to be set.
4054 * @param pSessionEntry session entry.
4055 * @return None
4056 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004057QDF_STATUS
Amar Singhala297bfa2015-10-15 15:07:29 -07004058lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004059 tpPESession pSessionEntry)
4060{
4061 tpMaxTxPowerParams pMaxTxParams = NULL;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004062 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004063 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004064
4065 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004066 pe_err("Invalid parameters");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004067 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004068 }
4069
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304070 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004071 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004072 pe_err("Unable to allocate memory for pMaxTxParams");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004073 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004074
4075 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004076 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304077 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304078 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304079 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004080 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304081 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004082
4083 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4084 msgQ.bodyptr = pMaxTxParams;
4085 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004086 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004087 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4088 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004089 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004090 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304091 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004092 }
4093 return retCode;
4094}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004095
4096/**
4097 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4098 *
4099 * @mac_ctx: Pointer to Global MAC structure
4100 * @msg_buf: pointer to the SME message buffer
4101 *
4102 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4103 * from SME. It Register this information within PE.
4104 *
4105 * Return: None
4106 */
4107static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4108 uint32_t *msg_buf)
4109{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304110 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004111 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4112 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4113 struct mgmt_frm_reg_info *next = NULL;
4114 bool match = false;
4115
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004116 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004117 sme_req->registerFrame, sme_req->frameType,
4118 sme_req->matchLen);
4119 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304120 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304121 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4122 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304123 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004124
4125 while (lim_mgmt_regn != NULL) {
4126 if (lim_mgmt_regn->frameType != sme_req->frameType)
4127 goto skip_match;
4128 if (sme_req->matchLen) {
4129 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304130 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004131 sme_req->matchData,
4132 lim_mgmt_regn->matchLen))) {
4133 /* found match! */
4134 match = true;
4135 break;
4136 }
4137 } else {
4138 /* found match! */
4139 match = true;
4140 break;
4141 }
4142skip_match:
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_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004145 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304146 (qdf_list_node_t *)lim_mgmt_regn,
4147 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304148 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004149 lim_mgmt_regn = next;
4150 next = NULL;
4151 }
4152 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304153 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004154 if (QDF_STATUS_SUCCESS ==
4155 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004156 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004157 (qdf_list_node_t *)lim_mgmt_regn))
4158 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304159 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004160 }
4161
4162 if (sme_req->registerFrame) {
4163 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304164 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004165 sme_req->matchLen);
4166 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004167 lim_mgmt_regn->frameType = sme_req->frameType;
4168 lim_mgmt_regn->matchLen = sme_req->matchLen;
4169 lim_mgmt_regn->sessionId = sme_req->sessionId;
4170 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304171 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004172 sme_req->matchData,
4173 sme_req->matchLen);
4174 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304175 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004176 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304177 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004178 gLimMgmtFrameRegistratinQueue,
4179 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304180 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004181 &mac_ctx->lim.lim_frame_register_lock);
4182 }
4183 }
4184 return;
4185}
4186
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004187static void
4188__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4189{
4190 tpSirResetAPCapsChange pResetCapsChange;
4191 tpPESession psessionEntry;
4192 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004193
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004194 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004195 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004196 return;
4197 }
4198
4199 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4200 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004201 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4202 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004203 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004204 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004205 return;
4206 }
4207
4208 psessionEntry->limSentCapsChangeNtf = false;
4209 return;
4210}
4211
4212/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304213 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4214 * indication callback in PE.
4215 * @mac_ptr: Mac pointer
4216 * @msg_buf: Msg pointer containing the callback
4217 *
4218 * This function is used save the Management frame
4219 * indication callback in PE.
4220 *
4221 * Return: None
4222 */
4223static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4224 uint32_t *msg_buf)
4225{
4226 struct sir_sme_mgmt_frame_cb_req *sme_req =
4227 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4228
4229 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004230 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304231 return;
4232 }
4233 if (sme_req->callback)
4234 mac_ctx->mgmt_frame_ind_cb =
4235 (sir_mgmt_frame_ind_callback)sme_req->callback;
4236 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004237 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304238}
4239
4240/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304241 *__lim_process_send_disassoc_frame: function processes disassoc frame
4242 * @mac_ctx: pointer to mac context
4243 * @msg_buf: message buffer
4244 *
4245 * function processes disassoc request received from SME
4246 *
4247 * return: none
4248 */
4249static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4250 uint32_t *msg_buf)
4251{
4252 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004253 QDF_STATUS status;
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304254 tpPESession session_entry = NULL;
4255 uint8_t sme_session_id;
4256 uint16_t sme_trans_id;
4257
4258 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004259 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304260 return;
4261 }
4262
4263 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4264 &sme_trans_id);
4265
4266 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4267 &sme_send_disassoc_frame_req,
4268 (uint8_t *)msg_buf);
4269
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004270 if ((QDF_STATUS_E_FAILURE == status) ||
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304271 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4272 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004273 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304274 return;
4275 }
4276
4277 session_entry = pe_find_session_by_sme_session_id(
4278 mac_ctx, sme_session_id);
4279 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004280 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304281 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4282 return;
4283 }
4284
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004285 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 +05304286 sme_send_disassoc_frame_req.msg_type,
4287 sme_send_disassoc_frame_req.length,
4288 sme_send_disassoc_frame_req.session_id,
4289 sme_send_disassoc_frame_req.trans_id,
4290 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4291 sme_send_disassoc_frame_req.reason,
4292 sme_send_disassoc_frame_req.wait_for_ack);
4293
4294 lim_send_disassoc_mgmt_frame(mac_ctx,
4295 sme_send_disassoc_frame_req.reason,
4296 sme_send_disassoc_frame_req.peer_mac,
4297 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4298}
4299
4300/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004301 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4302 * @mac_ctx: Pointer to Global MAC structure
4303 * @pdev_id: pdev id to set the IE.
4304 * @nss: Nss values to prepare the HT IE.
4305 *
4306 * Prepares the HT IE with self capabilities for different
4307 * Nss values and sends the set HT IE req to FW.
4308 *
4309 * Return: None
4310 */
4311static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4312 uint8_t nss)
4313{
4314 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004315 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004316 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004317 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004318 tHtCaps *p_ht_cap;
4319 int i;
4320
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004321 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004322 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4323 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004324 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004325 return;
4326 }
4327 ie_params->nss = i;
4328 ie_params->pdev_id = pdev_id;
4329 ie_params->ie_type = DOT11_HT_IE;
4330 /* 2 for IE len and EID */
4331 ie_params->ie_len = 2 + sizeof(tHtCaps);
4332 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4333 if (NULL == ie_params->ie_ptr) {
4334 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004335 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004336 return;
4337 }
4338 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4339 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4340 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4341 ie_params->ie_len);
4342
4343 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004344 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4345 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004346 if (NULL == p_ie) {
4347 qdf_mem_free(ie_params->ie_ptr);
4348 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004349 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004350 return;
4351 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004352 p_ht_cap = (tHtCaps *)&p_ie[2];
4353 p_ht_cap->supportedMCSSet[1] = 0;
4354 p_ht_cap->txSTBC = 0;
4355 }
4356
4357 msg.type = WMA_SET_PDEV_IE_REQ;
4358 msg.bodyptr = ie_params;
4359 msg.bodyval = 0;
4360
4361 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004362 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004363 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004364 qdf_mem_free(ie_params->ie_ptr);
4365 qdf_mem_free(ie_params);
4366 return;
4367 }
4368 }
4369}
4370
4371/**
4372 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4373 * @mac_ctx: Pointer to Global MAC structure
4374 * @pdev_id: pdev id to set the IE.
4375 * @nss: Nss values to prepare the VHT IE.
4376 *
4377 * Prepares the VHT IE with self capabilities for different
4378 * Nss values and sends the set VHT IE req to FW.
4379 *
4380 * Return: None
4381 */
4382static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4383 uint8_t nss)
4384{
4385 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004386 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004387 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004388 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004389 tSirMacVHTCapabilityInfo *vht_cap;
4390 int i;
4391 tSirVhtMcsInfo *vht_mcs;
4392
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004393 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004394 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4395 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004396 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004397 return;
4398 }
4399 ie_params->nss = i;
4400 ie_params->pdev_id = pdev_id;
4401 ie_params->ie_type = DOT11_VHT_IE;
4402 /* 2 for IE len and EID */
4403 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4404 sizeof(tSirVhtMcsInfo);
4405 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4406 if (NULL == ie_params->ie_ptr) {
4407 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004408 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004409 return;
4410 }
4411 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4412 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4413 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4414 ie_params->ie_len);
4415
4416 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004417 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4418 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004419 if (NULL == p_ie) {
4420 qdf_mem_free(ie_params->ie_ptr);
4421 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004422 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004423 return;
4424 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004425 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4426 vht_cap->txSTBC = 0;
4427 vht_mcs =
4428 (tSirVhtMcsInfo *)&p_ie[2 +
4429 sizeof(tSirMacVHTCapabilityInfo)];
4430 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4431 vht_mcs->rxHighest =
4432 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4433 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4434 vht_mcs->txHighest =
4435 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4436 }
4437 msg.type = WMA_SET_PDEV_IE_REQ;
4438 msg.bodyptr = ie_params;
4439 msg.bodyval = 0;
4440
4441 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004442 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004443 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004444 qdf_mem_free(ie_params->ie_ptr);
4445 qdf_mem_free(ie_params);
4446 return;
4447 }
4448 }
4449}
4450
4451/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004452 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4453 * @mac_ctx: Pointer to Global MAC structure
4454 * @msg_buf: Pointer to the SME message buffer
4455 *
4456 * This function is called by limProcessMessageQueue(). This function sets the
4457 * VDEV IEs to the FW.
4458 *
4459 * Return: None
4460 */
4461static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4462 uint32_t *msg_buf)
4463{
4464 struct sir_set_vdev_ies_per_band *p_msg =
4465 (struct sir_set_vdev_ies_per_band *)msg_buf;
4466
4467 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004468 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004469 return;
4470 }
4471
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004472 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004473 p_msg->vdev_id);
4474 /* intentionally using NULL here so that self capabilty are sent */
4475 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4476 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004477 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004478}
4479
4480/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004481 * lim_process_set_pdev_IEs() - process the set pdev IE req
4482 * @mac_ctx: Pointer to Global MAC structure
4483 * @msg_buf: Pointer to the SME message buffer
4484 *
4485 * This function is called by limProcessMessageQueue(). This
4486 * function sets the PDEV IEs to the FW.
4487 *
4488 * Return: None
4489 */
4490static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4491{
4492 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4493
4494 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4495
4496 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004497 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004498 return;
4499 }
4500
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004501 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004502 ht_vht_cfg->nss);
4503 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4504
4505 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4506 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4507 ht_vht_cfg->nss);
4508}
4509
4510/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304511 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4512 *
4513 * access policy
4514 * @mac_ctx: pointer to mac context
4515 * @msg: message buffer
4516 *
4517 * function processes vendor IE and access policy from SME and updates PE
4518 *
4519 * session entry
4520 *
4521 * return: none
4522*/
4523static void lim_process_sme_update_access_policy_vendor_ie(
4524 tpAniSirGlobal mac_ctx,
4525 uint32_t *msg)
4526{
4527 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4528 struct sPESession *pe_session_entry;
Pragaspathi Thilagaraj9b7a1162018-05-07 16:28:13 +05304529 uint16_t num_bytes;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304530
4531 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004532 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304533 return;
4534 }
4535 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4536 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4537 update_vendor_ie->sme_session_id);
4538
4539 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004540 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304541 update_vendor_ie->sme_session_id);
4542 return;
4543 }
4544 if (pe_session_entry->access_policy_vendor_ie)
4545 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4546
4547 num_bytes = update_vendor_ie->ie[1] + 2;
4548 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4549
4550 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004551 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304552 return;
4553 }
4554 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4555 &update_vendor_ie->ie[0], num_bytes);
4556
4557 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4558}
4559
4560/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004561 * lim_process_sme_req_messages()
4562 *
4563 ***FUNCTION:
4564 * This function is called by limProcessMessageQueue(). This
4565 * function processes SME request messages from HDD or upper layer
4566 * application.
4567 *
4568 ***LOGIC:
4569 *
4570 ***ASSUMPTIONS:
4571 *
4572 ***NOTE:
4573 *
4574 * @param pMac Pointer to Global MAC structure
4575 * @param msgType Indicates the SME message type
4576 * @param *pMsgBuf A pointer to the SME message buffer
4577 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4578 * false - if pMsgBuf is not to be freed.
4579 */
4580
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004581bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4582 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004583{
Jeff Johnson33142e62018-05-06 17:58:36 -07004584 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 -08004585 uint32_t *pMsgBuf = pMsg->bodyptr;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004586
4587 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004588 lim_msg_str(pMsg->type), pMsg->type,
4589 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4590 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004591
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004592 /* If no insert NOA required then execute the code below */
4593
4594 switch (pMsg->type) {
4595 case eWNI_SME_SYS_READY_IND:
4596 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4597 break;
4598
4599 case eWNI_SME_START_BSS_REQ:
4600 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4601 break;
4602
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004603 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4604 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4605 break;
4606 case eWNI_SME_JOIN_REQ:
4607 __lim_process_sme_join_req(pMac, pMsgBuf);
4608 break;
4609
4610 case eWNI_SME_REASSOC_REQ:
4611 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4612 break;
4613
4614 case eWNI_SME_DISASSOC_REQ:
4615 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4616 break;
4617
4618 case eWNI_SME_DISASSOC_CNF:
4619 case eWNI_SME_DEAUTH_CNF:
4620 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4621 break;
4622
4623 case eWNI_SME_DEAUTH_REQ:
4624 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4625 break;
4626
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304627 case eWNI_SME_SEND_DISASSOC_FRAME:
4628 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4629 break;
4630
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004631 case eWNI_SME_SETCONTEXT_REQ:
4632 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4633 break;
4634
4635 case eWNI_SME_STOP_BSS_REQ:
4636 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4637 break;
4638
4639 case eWNI_SME_ASSOC_CNF:
4640 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004641 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004642 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4643 pMsgBuf);
4644 break;
4645
4646 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004647 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004648 __lim_process_sme_addts_req(pMac, pMsgBuf);
4649 break;
4650
4651 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004652 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004653 __lim_process_sme_delts_req(pMac, pMsgBuf);
4654 break;
4655
4656 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004657 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004658 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4659 break;
4660
4661 case eWNI_SME_GET_STATISTICS_REQ:
4662 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4663 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4664 bufConsumed = false;
4665 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004666#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004667 case eWNI_SME_GET_TSM_STATS_REQ:
4668 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4669 bufConsumed = false;
4670 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004671#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004672 case eWNI_SME_GET_ASSOC_STAS_REQ:
4673 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4674 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304675 case eWNI_SME_SESSION_UPDATE_PARAM:
4676 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004677 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304678 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4679 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4680 bufConsumed = false;
4681 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004682 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4683 /* Update the beaconInterval */
4684 __lim_process_sme_change_bi(pMac, pMsgBuf);
4685 break;
4686
4687#ifdef QCA_HT_2040_COEX
4688 case eWNI_SME_SET_HT_2040_MODE:
4689 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4690 break;
4691#endif
4692
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004693 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4694 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4695 __lim_process_report_message(pMac, pMsg);
4696 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004697
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004698 case eWNI_SME_FT_PRE_AUTH_REQ:
4699 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4700 break;
4701 case eWNI_SME_FT_UPDATE_KEY:
4702 lim_process_ft_update_key(pMac, pMsgBuf);
4703 break;
4704
4705 case eWNI_SME_FT_AGGR_QOS_REQ:
4706 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4707 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004708
4709 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4710 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4711 break;
4712#ifdef FEATURE_WLAN_TDLS
4713 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4714 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4715 break;
4716 case eWNI_SME_TDLS_ADD_STA_REQ:
4717 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4718 break;
4719 case eWNI_SME_TDLS_DEL_STA_REQ:
4720 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4721 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004722#endif
4723 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4724 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4725 break;
4726
4727 case eWNI_SME_CHANNEL_CHANGE_REQ:
4728 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4729 break;
4730
4731 case eWNI_SME_START_BEACON_REQ:
4732 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4733 break;
4734
4735 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4736 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4737 break;
4738
4739 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4740 lim_process_update_add_ies(pMac, pMsgBuf);
4741 break;
4742
4743 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4744 lim_process_modify_add_ies(pMac, pMsgBuf);
4745 break;
4746 case eWNI_SME_SET_HW_MODE_REQ:
4747 lim_process_set_hw_mode(pMac, pMsgBuf);
4748 break;
4749 case eWNI_SME_NSS_UPDATE_REQ:
4750 lim_process_nss_update_request(pMac, pMsgBuf);
4751 break;
4752 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4753 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4754 break;
4755 case eWNI_SME_SET_IE_REQ:
4756 lim_process_set_ie_req(pMac, pMsgBuf);
4757 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304758 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4759 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
4760 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304761 case eWNI_SME_EXT_CHANGE_CHANNEL:
4762 lim_process_ext_change_channel(pMac, pMsgBuf);
4763 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08004764 case eWNI_SME_SET_ANTENNA_MODE_REQ:
4765 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
4766 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004767 case eWNI_SME_PDEV_SET_HT_VHT_IE:
4768 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07004769 break;
4770 case eWNI_SME_SET_VDEV_IES_PER_BAND:
4771 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
4772 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304773 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
4774 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
4775 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07004776 case eWNI_SME_UPDATE_CONFIG:
4777 lim_process_sme_update_config(pMac,
4778 (struct update_config *)pMsgBuf);
4779 break;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004780 case eWNI_SME_SET_ADDBA_ACCEPT:
4781 lim_process_sme_set_addba_accept(pMac,
4782 (struct sme_addba_accept *)pMsgBuf);
4783 break;
Arif Hussaineb8ba362018-03-07 19:15:13 -08004784 case eWNI_SME_UPDATE_EDCA_PROFILE:
4785 lim_process_sme_update_edca_params(pMac, pMsg->bodyval);
4786 break;
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07004787 case WNI_SME_UPDATE_MU_EDCA_PARAMS:
4788 lim_process_sme_update_mu_edca_params(pMac, pMsg->bodyval);
4789 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004790 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304791 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004792 pMsg->bodyptr = NULL;
4793 break;
4794 } /* switch (msgType) */
4795
4796 return bufConsumed;
4797} /*** end lim_process_sme_req_messages() ***/
4798
4799/**
4800 * lim_process_sme_start_beacon_req()
4801 *
4802 ***FUNCTION:
4803 * This function is called by limProcessMessageQueue(). This
4804 * function processes SME request messages from HDD or upper layer
4805 * application.
4806 *
4807 ***LOGIC:
4808 *
4809 ***ASSUMPTIONS:
4810 *
4811 ***NOTE:
4812 *
4813 * @param pMac Pointer to Global MAC structure
4814 * @param msgType Indicates the SME message type
4815 * @param *pMsgBuf A pointer to the SME message buffer
4816 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4817 * false - if pMsgBuf is not to be freed.
4818 */
4819static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
4820{
4821 tpSirStartBeaconIndication pBeaconStartInd;
4822 tpPESession psessionEntry;
4823 uint8_t sessionId; /* PE sessionID */
4824
4825 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004826 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004827 return;
4828 }
4829
4830 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
4831 psessionEntry = pe_find_session_by_bssid(pMac,
4832 pBeaconStartInd->bssid,
4833 &sessionId);
4834 if (psessionEntry == NULL) {
4835 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004836 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004837 return;
4838 }
4839
4840 if (pBeaconStartInd->beaconStartStatus == true) {
4841 /*
4842 * Currently this Indication comes from SAP
4843 * to start Beacon Tx on a DFS channel
4844 * since beaconing has to be done on DFS
4845 * channel only after CAC WAIT is completed.
4846 * On a DFS Channel LIM does not start beacon
4847 * Tx right after the WMA_ADD_BSS_RSP.
4848 */
4849 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05304850 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004851 FL("Start Beacon with ssid %s Ch %d"),
4852 psessionEntry->ssId.ssId,
4853 psessionEntry->currentOperChannel);
4854 lim_send_beacon_ind(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08004855 lim_enable_obss_detection_config(pMac, psessionEntry);
Arif Hussain05fb4872018-01-03 16:02:55 -08004856 lim_send_obss_color_collision_cfg(pMac, psessionEntry,
4857 OBSS_COLOR_COLLISION_DETECTION);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004858 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004859 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004860 return;
4861 }
4862}
4863
4864/**
4865 * lim_process_sme_channel_change_request() - process sme ch change req
4866 *
4867 * @mac_ctx: Pointer to Global MAC structure
4868 * @msg_buf: pointer to the SME message buffer
4869 *
4870 * This function is called to process SME_CHANNEL_CHANGE_REQ message
4871 *
4872 * Return: None
4873 */
4874static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
4875 uint32_t *msg_buf)
4876{
4877 tpSirChanChangeRequest ch_change_req;
4878 tpPESession session_entry;
4879 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07004880 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004881 uint32_t val = 0;
4882
4883 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004884 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004885 return;
4886 }
4887 ch_change_req = (tpSirChanChangeRequest)msg_buf;
4888
4889 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
4890 ch_change_req->targetChannel);
4891
4892 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
4893 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004894 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004895 return;
4896 }
4897
4898 session_entry = pe_find_session_by_bssid(mac_ctx,
4899 ch_change_req->bssid, &session_id);
4900 if (session_entry == NULL) {
4901 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004902 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004903 return;
4904 }
4905
Manjunathappa Prakash34fda792018-02-07 18:23:42 -08004906 if ((session_entry->currentOperChannel ==
4907 ch_change_req->targetChannel) &&
4908 (session_entry->ch_width == ch_change_req->ch_width)) {
4909 pe_err("Target channel and mode is same as current channel and mode channel %d and mode %d",
4910 session_entry->currentOperChannel, session_entry->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004911 return;
4912 }
4913
4914 if (LIM_IS_AP_ROLE(session_entry))
4915 session_entry->channelChangeReasonCode =
4916 LIM_SWITCH_CHANNEL_SAP_DFS;
4917 else
4918 session_entry->channelChangeReasonCode =
4919 LIM_SWITCH_CHANNEL_OPERATION;
4920
Bala Venkateshb39ed152017-12-26 19:35:27 +05304921 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d, nw_type %d, dot11mode %d",
4922 session_entry->currentOperChannel,
4923 ch_change_req->targetChannel,
4924 ch_change_req->ch_width,
4925 ch_change_req->nw_type,
4926 ch_change_req->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004927
4928 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004929 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004930 session_entry->ch_center_freq_seg0 =
4931 ch_change_req->center_freq_seg_0;
4932 session_entry->ch_center_freq_seg1 =
4933 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004934 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004935 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004936 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004937 session_entry->htRecommendedTxWidthSet =
4938 session_entry->htSupportedChannelWidthSet;
4939 session_entry->currentOperChannel =
4940 ch_change_req->targetChannel;
4941 session_entry->limRFBand =
4942 lim_get_rf_band(session_entry->currentOperChannel);
Vignesh Viswanathan153ae932018-04-11 14:24:13 +05304943
4944 /* Update the global beacon filter */
4945 lim_update_bcn_probe_filter(mac_ctx, session_entry);
4946
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004947 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08004948 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004949 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004950 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004951 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004952 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004953 }
4954
4955 session_entry->lim11hEnable = val;
4956 session_entry->dot11mode = ch_change_req->dot11mode;
Bala Venkateshb39ed152017-12-26 19:35:27 +05304957 session_entry->nwType = ch_change_req->nw_type;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304958 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004959 &ch_change_req->operational_rateset,
4960 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304961 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004962 &ch_change_req->extended_rateset,
4963 sizeof(session_entry->extRateSet));
4964 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
4965 session_entry->ch_center_freq_seg0,
4966 session_entry->ch_center_freq_seg1,
4967 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07004968 max_tx_pwr, session_entry->peSessionId,
4969 ch_change_req->cac_duration_ms,
4970 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004971}
4972
4973/******************************************************************************
4974* lim_start_bss_update_add_ie_buffer()
4975*
4976***FUNCTION:
4977* This function checks the src buffer and its length and then malloc for
4978* dst buffer update the same
4979*
4980***LOGIC:
4981*
4982***ASSUMPTIONS:
4983*
4984***NOTE:
4985*
4986* @param pMac Pointer to Global MAC structure
4987* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
4988* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
4989* @param *pSrcData_buff A pointer of uint8_t src buffer
4990* @param srcDataLen src buffer length
4991******************************************************************************/
4992
4993static void
4994lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
4995 uint8_t **pDstData_buff,
4996 uint16_t *pDstDataLen,
4997 uint8_t *pSrcData_buff, uint16_t srcDataLen)
4998{
4999
5000 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5001 *pDstDataLen = srcDataLen;
5002
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305003 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005004
5005 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005006 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005007 return;
5008 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305009 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005010 } else {
5011 *pDstData_buff = NULL;
5012 *pDstDataLen = 0;
5013 }
5014}
5015
5016/******************************************************************************
5017* lim_update_add_ie_buffer()
5018*
5019***FUNCTION:
5020* This function checks the src buffer and length if src buffer length more
5021* than dst buffer length then free the dst buffer and malloc for the new src
5022* length, and update the dst buffer and length. But if dst buffer is bigger
5023* than src buffer length then it just update the dst buffer and length
5024*
5025***LOGIC:
5026*
5027***ASSUMPTIONS:
5028*
5029***NOTE:
5030*
5031* @param pMac Pointer to Global MAC structure
5032* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5033* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5034* @param *pSrcData_buff A pointer of uint8_t src buffer
5035* @param srcDataLen src buffer length
5036******************************************************************************/
5037
5038static void
5039lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5040 uint8_t **pDstData_buff,
5041 uint16_t *pDstDataLen,
5042 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5043{
5044
5045 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005046 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005047 return;
5048 }
5049
5050 if (srcDataLen > *pDstDataLen) {
5051 *pDstDataLen = srcDataLen;
5052 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305053 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005054 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305055 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005056
5057 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005058 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005059 *pDstDataLen = 0;
5060 return;
5061 }
5062 }
5063
5064 /* copy the content of buffer into dst buffer
5065 */
5066 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305067 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005068
5069}
5070
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005071/**
5072 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5073 * @pMac : Pointer to Global MAC structure
5074 * @pDstData_buff : A pointer to pointer of dst buffer
5075 * @pDstDataLen : A pointer to pointer of dst buffer length
5076 * @pModifyIE : A pointer to tSirModifyIE
5077 *
5078 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5079 *
5080 * Return:
5081 * True or false depending upon whether IE is updated or not
5082 */
5083static bool
5084lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5085 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5086{
Hong Shi1553d692016-09-28 12:16:19 +08005087 int32_t oui_length;
5088 uint8_t *ibss_ie = NULL;
5089 uint8_t *vendor_ie;
5090#define MAC_VENDOR_OUI "\x00\x16\x32"
5091#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005092
5093 ibss_ie = pModifyIE->pIEBuffer;
5094 oui_length = pModifyIE->oui_length;
5095
5096 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005097 pe_err("Invalid set IBSS vendor IE command length %d",
5098 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005099 return false;
5100 }
5101
Hong Shi1553d692016-09-28 12:16:19 +08005102 /*
5103 * Why replace only beacon OUI data here:
5104 * 1. other ie (such as wpa) shall not be overwritten here.
5105 * 2. per spec, beacon oui ie might be set twice and original one
5106 * shall be updated.
5107 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005108 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005109 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5110 if (vendor_ie) {
5111 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5112 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5113 pModifyIE->ieBufferlength);
5114 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005115 uint16_t new_length;
5116 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005117
Naveen Rawat668dee32017-09-29 14:39:40 -07005118 /*
5119 * check for uint16 overflow before using sum of two numbers as
5120 * length of size to malloc
5121 */
5122 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5123 pe_err("U16 overflow due to %d + %d",
5124 pModifyIE->ieBufferlength, *pDstDataLen);
5125 return false;
5126 }
5127
5128 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5129 new_ptr = qdf_mem_malloc(new_length);
Hong Shi1553d692016-09-28 12:16:19 +08005130 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005131 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005132 return false;
5133 }
5134 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5135 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5136 pModifyIE->ieBufferlength);
5137 qdf_mem_free(*pDstData_buff);
5138 *pDstDataLen = new_length;
5139 *pDstData_buff = new_ptr;
5140 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005141 return true;
5142}
5143
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005144/*
5145* lim_process_modify_add_ies() - process modify additional IE req.
5146*
5147* @mac_ctx: Pointer to Global MAC structure
5148* @msg_buf: pointer to the SME message buffer
5149*
5150* This function update the PE buffers for additional IEs.
5151*
5152* Return: None
5153*/
5154static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5155 uint32_t *msg_buf)
5156{
5157 tpSirModifyIEsInd modify_add_ies;
5158 tpPESession session_entry;
5159 uint8_t session_id;
5160 bool ret = false;
5161 tSirAddIeParams *add_ie_params;
5162
5163 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005164 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005165 return;
5166 }
5167
5168 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5169 /* Incoming message has smeSession, use BSSID to find PE session */
5170 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005171 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005172
5173 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005174 pe_err("Session not found for given bssid"
5175 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005176 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005177 goto end;
5178 }
5179 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5180 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5181 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005182 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005183 modify_add_ies->modifyIE.pIEBuffer,
5184 modify_add_ies->modifyIE.ieBufferlength,
5185 modify_add_ies->modifyIE.ieID,
5186 modify_add_ies->modifyIE.ieIDLen,
5187 modify_add_ies->updateType);
5188 goto end;
5189 }
5190 add_ie_params = &session_entry->addIeParams;
5191 switch (modify_add_ies->updateType) {
5192 case eUPDATE_IE_PROBE_RESP:
5193 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005194 if (LIM_IS_IBSS_ROLE(session_entry)) {
5195 lim_update_ibss_prop_add_ies(mac_ctx,
5196 &add_ie_params->probeRespData_buff,
5197 &add_ie_params->probeRespDataLen,
5198 &modify_add_ies->modifyIE);
5199 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005200 break;
5201 case eUPDATE_IE_ASSOC_RESP:
5202 /* assoc resp IE */
5203 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305204 QDF_TRACE(QDF_MODULE_ID_PE,
5205 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005206 "assoc resp add ie not present %d"),
5207 add_ie_params->assocRespDataLen);
5208 }
5209 /* search through the buffer and modify the IE */
5210 break;
5211 case eUPDATE_IE_PROBE_BCN:
5212 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005213 if (LIM_IS_IBSS_ROLE(session_entry)) {
5214 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5215 &add_ie_params->probeRespBCNData_buff,
5216 &add_ie_params->probeRespBCNDataLen,
5217 &modify_add_ies->modifyIE);
5218 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005219 if (ret == true && modify_add_ies->modifyIE.notify) {
5220 lim_handle_param_update(mac_ctx,
5221 modify_add_ies->updateType);
5222 }
5223 break;
5224 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005225 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005226 modify_add_ies->updateType);
5227 break;
5228 }
5229end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305230 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005231 modify_add_ies->modifyIE.pIEBuffer = NULL;
5232}
5233
5234/*
5235* lim_process_update_add_ies() - process additional IE update req
5236*
5237* @mac_ctx: Pointer to Global MAC structure
5238* @msg_buf: pointer to the SME message buffer
5239*
5240* This function update the PE buffers for additional IEs.
5241*
5242* Return: None
5243*/
5244static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5245 uint32_t *msg_buf)
5246{
5247 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5248 uint8_t session_id;
5249 tpPESession session_entry;
5250 tSirAddIeParams *addn_ie;
5251 uint16_t new_length = 0;
5252 uint8_t *new_ptr = NULL;
5253 tSirUpdateIE *update_ie;
5254
5255 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005256 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005257 return;
5258 }
5259 update_ie = &update_add_ies->updateIE;
5260 /* incoming message has smeSession, use BSSID to find PE session */
5261 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005262 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005263
5264 if (NULL == session_entry) {
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05305265 pe_debug("Session not found for given bssid"
5266 MAC_ADDRESS_STR,
5267 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005268 goto end;
5269 }
5270 addn_ie = &session_entry->addIeParams;
5271 /* if len is 0, upper layer requested freeing of buffer */
5272 if (0 == update_ie->ieBufferlength) {
5273 switch (update_add_ies->updateType) {
5274 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305275 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005276 addn_ie->probeRespData_buff = NULL;
5277 addn_ie->probeRespDataLen = 0;
5278 break;
5279 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305280 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005281 addn_ie->assocRespData_buff = NULL;
5282 addn_ie->assocRespDataLen = 0;
5283 break;
5284 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305285 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005286 addn_ie->probeRespBCNData_buff = NULL;
5287 addn_ie->probeRespBCNDataLen = 0;
5288
5289 if (update_ie->notify)
5290 lim_handle_param_update(mac_ctx,
5291 update_add_ies->updateType);
5292 break;
5293 default:
5294 break;
5295 }
5296 return;
5297 }
5298 switch (update_add_ies->updateType) {
5299 case eUPDATE_IE_PROBE_RESP:
5300 if (update_ie->append) {
5301 /*
5302 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005303 * with combined length.
5304 * Multiple back to back append commands
5305 * can lead to a huge length.So, check
5306 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005307 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005308 if (addn_ie->probeRespDataLen >
5309 (USHRT_MAX - update_ie->ieBufferlength)) {
5310 pe_err("IE Length overflow, curr:%d, new:%d",
5311 addn_ie->probeRespDataLen,
5312 update_ie->ieBufferlength);
5313 goto end;
5314 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005315 new_length = update_ie->ieBufferlength +
5316 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305317 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005318 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005319 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005320 goto end;
5321 }
5322 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305323 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005324 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305325 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005326 update_ie->pAdditionIEBuffer,
5327 update_ie->ieBufferlength);
5328 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305329 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005330 /* adjust length accordingly */
5331 addn_ie->probeRespDataLen = new_length;
5332 /* save refernece of local buffer in PE session */
5333 addn_ie->probeRespData_buff = new_ptr;
5334 goto end;
5335 }
5336 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5337 &addn_ie->probeRespDataLen,
5338 update_ie->pAdditionIEBuffer,
5339 update_ie->ieBufferlength);
5340 break;
5341 case eUPDATE_IE_ASSOC_RESP:
5342 /* assoc resp IE */
5343 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5344 &addn_ie->assocRespDataLen,
5345 update_ie->pAdditionIEBuffer,
5346 update_ie->ieBufferlength);
5347 break;
5348 case eUPDATE_IE_PROBE_BCN:
5349 /* probe resp Bcn IE */
5350 lim_update_add_ie_buffer(mac_ctx,
5351 &addn_ie->probeRespBCNData_buff,
5352 &addn_ie->probeRespBCNDataLen,
5353 update_ie->pAdditionIEBuffer,
5354 update_ie->ieBufferlength);
5355 if (update_ie->notify)
5356 lim_handle_param_update(mac_ctx,
5357 update_add_ies->updateType);
5358 break;
5359 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005360 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005361 break;
5362 }
5363end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305364 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005365 update_ie->pAdditionIEBuffer = NULL;
5366}
5367
5368/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305369 * send_extended_chan_switch_action_frame()- function to send ECSA
5370 * action frame for each sta connected to SAP/GO and AP in case of
5371 * STA .
5372 * @mac_ctx: pointer to global mac structure
5373 * @new_channel: new channel to switch to.
5374 * @ch_bandwidth: BW of channel to calculate op_class
5375 * @session_entry: pe session
5376 *
5377 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5378 *
5379 * Return: void
5380 */
5381
5382static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5383 uint16_t new_channel, uint8_t ch_bandwidth,
5384 tpPESession session_entry)
5385{
5386 uint16_t op_class;
5387 uint8_t switch_mode = 0, i;
5388 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005389 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305390
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005391 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305392 mac_ctx->scan.countryCodeCurrent,
5393 new_channel,
5394 ch_bandwidth);
5395
5396 if (LIM_IS_AP_ROLE(session_entry) &&
5397 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005398 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305399
gaoleze2920bd2017-03-21 17:38:42 +08005400 switch_count = session_entry->gLimChannelSwitch.switchCount;
5401
Abhishek Singh518323d2015-10-19 17:42:01 +05305402 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005403 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305404 psta =
5405 session_entry->dph.dphHashTable.pDphNodeArray + i;
5406 if (psta && psta->added)
5407 lim_send_extended_chan_switch_action_frame(
5408 mac_ctx,
5409 psta->staAddr,
5410 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005411 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305412 }
5413 } else if (LIM_IS_STA_ROLE(session_entry)) {
5414 lim_send_extended_chan_switch_action_frame(mac_ctx,
5415 session_entry->bssId,
5416 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005417 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305418 }
5419
5420}
5421
gaolez76d2a162017-03-21 19:23:58 +08005422void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5423 uint16_t new_channel,
5424 uint8_t ch_bandwidth,
5425 tpPESession session_entry)
5426{
5427 uint16_t op_class;
5428 uint8_t switch_mode = 0, i;
5429 uint8_t switch_count;
5430 tpDphHashNode psta;
5431 tpDphHashNode dph_node_array_ptr;
5432
5433 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5434
5435 op_class = wlan_reg_dmn_get_opclass_from_channel(
5436 mac_ctx->scan.countryCodeCurrent,
5437 new_channel, ch_bandwidth);
5438
5439 if (LIM_IS_AP_ROLE(session_entry) &&
5440 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5441 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5442
5443 switch_count = session_entry->gLimChannelSwitch.switchCount;
5444
5445 if (LIM_IS_AP_ROLE(session_entry)) {
5446 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5447 psta = dph_node_array_ptr + i;
5448 if (!(psta && psta->added))
5449 continue;
5450 if (session_entry->lim_non_ecsa_cap_num == 0)
5451 lim_send_extended_chan_switch_action_frame
5452 (mac_ctx, psta->staAddr, switch_mode,
5453 op_class, new_channel, switch_count,
5454 session_entry);
5455 else
5456 lim_send_channel_switch_mgmt_frame
5457 (mac_ctx, psta->staAddr, switch_mode,
5458 new_channel, switch_count,
5459 session_entry);
5460 }
5461 } else if (LIM_IS_STA_ROLE(session_entry)) {
5462 lim_send_extended_chan_switch_action_frame
5463 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5464 new_channel, switch_count, session_entry);
5465 }
5466}
5467
5468/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005469 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5470 *
5471 * @mac_ctx: Pointer to Global MAC structure
5472 * @msg_buf: pointer to the SME message buffer
5473 *
5474 * This function processes SME request messages from HDD or upper layer
5475 * application.
5476 *
5477 * Return: None
5478 */
5479static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5480 uint32_t *msg_buf)
5481{
5482 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5483 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005484 uint8_t session_id;
5485 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005486 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005487
5488 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005489 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005490 return;
5491 }
5492
5493 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5494 session_entry = pe_find_session_by_bssid(mac_ctx,
5495 dfs_csa_ie_req->bssid, &session_id);
5496 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005497 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005498 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5499 return;
5500 }
5501
5502 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005503 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005504 GET_LIM_SYSTEM_ROLE(session_entry));
5505 return;
5506 }
5507
5508 /* target channel */
5509 session_entry->gLimChannelSwitch.primaryChannel =
5510 dfs_csa_ie_req->targetChannel;
5511
5512 /* Channel switch announcement needs to be included in beacon */
5513 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005514 session_entry->gLimChannelSwitch.switchCount =
5515 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005516 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005517 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305518 session_entry->gLimChannelSwitch.sec_ch_offset =
5519 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005520 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005521 session_entry->gLimChannelSwitch.switchMode =
5522 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005523
5524 /*
5525 * Validate if SAP is operating HT or VHT mode and set the Channel
5526 * Switch Wrapper element with the Wide Band Switch subelement.
5527 */
5528 if (true != session_entry->vhtCapability)
5529 goto skip_vht;
5530
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005531 /* Now encode the Wider Ch BW element depending on the ch width */
5532 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005533 switch (dfs_csa_ie_req->ch_params.ch_width) {
5534 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005535 /*
5536 * Wide channel BW sublement in channel wrapper element is not
5537 * required in case of 20 Mhz operation. Currently It is set
5538 * only set in case of 40/80 Mhz Operation.
5539 */
5540 session_entry->dfsIncludeChanWrapperIe = false;
5541 wider_bw_ch_switch->newChanWidth =
5542 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5543 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005544 case CH_WIDTH_40MHZ:
5545 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005546 wider_bw_ch_switch->newChanWidth =
5547 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5548 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005549 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005550 session_entry->dfsIncludeChanWrapperIe = true;
5551 wider_bw_ch_switch->newChanWidth =
5552 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5553 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005554 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005555 session_entry->dfsIncludeChanWrapperIe = true;
5556 wider_bw_ch_switch->newChanWidth =
5557 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5558 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005559 case CH_WIDTH_80P80MHZ:
5560 session_entry->dfsIncludeChanWrapperIe = true;
5561 wider_bw_ch_switch->newChanWidth =
5562 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005563 /*
5564 * This is not applicable for 20/40/80 Mhz.
5565 * Only used when we support 80+80 Mhz operation.
5566 * In case of 80+80 Mhz, this parameter indicates
5567 * center channel frequency index of 80 Mhz channel of
5568 * frequency segment 1.
5569 */
5570 wider_bw_ch_switch->newCenterChanFreq1 =
5571 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005572 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005573 default:
5574 session_entry->dfsIncludeChanWrapperIe = false;
5575 /*
5576 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5577 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5578 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005579 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005580 break;
5581 }
5582 /* Fetch the center channel based on the channel width */
5583 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005584 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005585skip_vht:
5586 /* Send CSA IE request from here */
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05305587 lim_send_dfs_chan_sw_ie_update(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305588
5589 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5590 ch_offset = BW80;
5591 else
5592 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5593
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005594 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305595 session_entry->gLimChannelSwitch.switchCount,
5596 session_entry->gLimChannelSwitch.primaryChannel,
5597 session_entry->gLimChannelSwitch.ch_width,
5598 session_entry->dfsIncludeChanWrapperIe,
5599 ch_offset);
5600
gaolez76d2a162017-03-21 19:23:58 +08005601 /* Send ECSA/CSA Action frame after updating the beacon */
5602 if (CHAN_HOP_ALL_BANDS_ENABLE)
5603 lim_send_chan_switch_action_frame(mac_ctx,
5604 session_entry->gLimChannelSwitch.primaryChannel,
5605 ch_offset, session_entry);
5606 else
5607 send_extended_chan_switch_action_frame(mac_ctx,
5608 session_entry->gLimChannelSwitch.primaryChannel,
5609 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005610}
5611
5612/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305613 * lim_process_ext_change_channel()- function to send ECSA
5614 * action frame for STA/CLI .
5615 * @mac_ctx: pointer to global mac structure
5616 * @msg: params from sme for new channel.
5617 *
5618 * This function is called to send ECSA frame for STA/CLI.
5619 *
5620 * Return: void
5621 */
5622
5623static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5624 uint32_t *msg)
5625{
5626 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5627 (struct sir_sme_ext_cng_chan_req *) msg;
5628 tpPESession session_entry = NULL;
5629
5630 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005631 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305632 return;
5633 }
5634 session_entry =
5635 pe_find_session_by_sme_session_id(mac_ctx,
5636 ext_chng_channel->session_id);
5637 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005638 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305639 ext_chng_channel->session_id);
5640 return;
5641 }
5642 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005643 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305644 return;
5645 }
5646 send_extended_chan_switch_action_frame(mac_ctx,
5647 ext_chng_channel->new_channel,
5648 0, session_entry);
5649}
5650
5651/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005652 * lim_process_nss_update_request() - process sme nss update req
5653 *
5654 * @mac_ctx: Pointer to Global MAC structure
5655 * @msg_buf: pointer to the SME message buffer
5656 *
5657 * This function processes SME request messages from HDD or upper layer
5658 * application.
5659 *
5660 * Return: None
5661 */
5662static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5663 uint32_t *msg_buf)
5664{
5665 struct sir_nss_update_request *nss_update_req_ptr;
5666 tpPESession session_entry = NULL;
5667
5668 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005669 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005670 return;
5671 }
5672
5673 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305674 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005675 nss_update_req_ptr->vdev_id);
5676 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005677 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005678 nss_update_req_ptr->vdev_id);
5679 return;
5680 }
5681
5682 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005683 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005684 GET_LIM_SYSTEM_ROLE(session_entry));
5685 return;
5686 }
5687
5688 /* populate nss field in the beacon */
5689 session_entry->gLimOperatingMode.present = 1;
5690 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05305691 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
5692
5693 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
5694 (session_entry->ch_width > CH_WIDTH_80MHZ))
5695 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
5696
5697 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
5698
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005699 /* Send nss update request from here */
5700 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005701 QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005702 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005703 return;
5704 }
5705
5706 lim_send_beacon_ind(mac_ctx, session_entry);
5707}
5708
5709/**
5710 * lim_process_set_ie_req() - process sme set IE request
5711 *
5712 * @mac_ctx: Pointer to Global MAC structure
5713 * @msg_buf: pointer to the SME message buffer
5714 *
5715 * This function processes SME request messages from HDD or upper layer
5716 * application.
5717 *
5718 * Return: None
5719 */
5720static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5721{
5722 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305723 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005724
5725 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005726 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005727 return;
5728 }
5729
5730 msg = (struct send_extcap_ie *)msg_buf;
5731 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305732 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005733 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005734
5735}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005736
5737#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Arif Hussain05fb4872018-01-03 16:02:55 -08005738
5739/**
5740 * obss_color_collision_process_color_disable() - Disable bss color
5741 * @mac_ctx: Pointer to Global MAC structure
5742 * @session: pointer to session
5743 *
5744 * This function will disbale bss color.
5745 *
5746 * Return: None
5747 */
5748static void obss_color_collision_process_color_disable(tpAniSirGlobal mac_ctx,
5749 tpPESession session)
5750{
5751 tUpdateBeaconParams beacon_params;
5752
5753 if (!session) {
5754 pe_err("Invalid session");
5755 return;
5756 }
5757
5758 if (session->valid && !LIM_IS_AP_ROLE(session)) {
5759 pe_err("Invalid SystemRole %d",
5760 GET_LIM_SYSTEM_ROLE(session));
5761 return;
5762 }
5763
5764 if (session->bss_color_changing == 1) {
5765 pe_warn("%d: color change in progress", session->smeSessionId);
5766 /* Continue color collision detection */
5767 lim_send_obss_color_collision_cfg(mac_ctx, session,
5768 OBSS_COLOR_COLLISION_DETECTION);
5769 return;
5770 }
5771
5772 if (session->he_op.bss_col_disabled == 1) {
5773 pe_warn("%d: bss color already disabled",
5774 session->smeSessionId);
5775 /* Continue free color detection */
5776 lim_send_obss_color_collision_cfg(mac_ctx, session,
5777 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5778 return;
5779 }
5780
5781 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5782 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5783 session->he_op.bss_col_disabled = 1;
Arif Hussain05fb4872018-01-03 16:02:55 -08005784 beacon_params.bss_color_disabled = 1;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005785 beacon_params.bss_color = session->he_op.bss_color;
Arif Hussain05fb4872018-01-03 16:02:55 -08005786
5787 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005788 QDF_STATUS_SUCCESS) {
Arif Hussain05fb4872018-01-03 16:02:55 -08005789 pe_err("Unable to set op mode IE in beacon");
5790 return;
5791 }
5792
5793 lim_send_beacon_params(mac_ctx, &beacon_params, session);
5794 lim_send_obss_color_collision_cfg(mac_ctx, session,
5795 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5796}
5797
5798/**
5799 * obss_color_collision_process_color_change() - Process bss color change
5800 * @mac_ctx: Pointer to Global MAC structure
5801 * @session: pointer to session
5802 * @obss_color_info: obss color collision/free slot indication info
5803 *
5804 * This function selects new color ib case of bss color collision.
5805 *
5806 * Return: None
5807 */
5808static void obss_color_collision_process_color_change(tpAniSirGlobal mac_ctx,
5809 tpPESession session,
5810 struct wmi_obss_color_collision_info *obss_color_info)
5811{
5812 int i, num_bss_color = 0;
5813 uint32_t bss_color_bitmap;
5814 uint8_t bss_color_index_array[MAX_BSS_COLOR_VALUE];
5815 uint32_t rand_byte = 0;
5816 struct sir_set_he_bss_color he_bss_color;
5817 bool is_color_collision = false;
5818
5819
5820 if (session->bss_color_changing == 1) {
5821 pe_err("%d: color change in progress", session->smeSessionId);
5822 return;
5823 }
5824
5825 if (!session->he_op.bss_col_disabled) {
5826 if (session->he_op.bss_color < 32)
5827 is_color_collision = (obss_color_info->
5828 obss_color_bitmap_bit0to31 >>
5829 session->he_op.bss_color) & 0x01;
5830 else
5831 is_color_collision = (obss_color_info->
5832 obss_color_bitmap_bit32to63 >>
5833 (session->he_op.bss_color -
Arif Hussain9e8c5612018-04-12 16:35:48 -07005834 32)) & 0x01;
Arif Hussain05fb4872018-01-03 16:02:55 -08005835 if (!is_color_collision) {
5836 pe_err("%d: color collision not found, curr_color: %d",
5837 session->smeSessionId,
5838 session->he_op.bss_color);
5839 return;
5840 }
5841 }
5842
5843 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit0to31;
5844
5845 /* Skip color zero */
5846 bss_color_bitmap = bss_color_bitmap >> 1;
5847 for (i = 0; (i < 31) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5848 if (!(bss_color_bitmap & 0x01)) {
5849 bss_color_index_array[num_bss_color] = i + 1;
5850 num_bss_color++;
5851 }
5852 bss_color_bitmap = bss_color_bitmap >> 1;
5853 }
5854
5855 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit32to63;
5856 for (i = 0; (i < 32) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5857 if (!(bss_color_bitmap & 0x01)) {
5858 bss_color_index_array[num_bss_color] = i + 32;
5859 num_bss_color++;
5860 }
5861 bss_color_bitmap = bss_color_bitmap >> 1;
5862 }
5863
5864 if (num_bss_color) {
5865 qdf_get_random_bytes((void *) &rand_byte, 1);
5866 i = (rand_byte + qdf_mc_timer_get_system_ticks()) %
5867 num_bss_color;
5868 pe_debug("New bss color = %d", bss_color_index_array[i]);
5869 he_bss_color.session_id = obss_color_info->vdev_id;
5870 he_bss_color.bss_color = bss_color_index_array[i];
5871 lim_process_set_he_bss_color(mac_ctx,
5872 (uint32_t *)&he_bss_color);
5873 } else {
5874 pe_err("Unable to find bss color from bitmasp");
5875 if (obss_color_info->evt_type ==
5876 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY &&
5877 session->obss_color_collision_dec_evt ==
5878 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
5879 /* In dot11BSSColorCollisionAPPeriod and
5880 * timer expired, time to disable bss color.
5881 */
5882 obss_color_collision_process_color_disable(mac_ctx,
5883 session);
5884 else
5885 /*
5886 * Enter dot11BSSColorCollisionAPPeriod period.
5887 */
5888 lim_send_obss_color_collision_cfg(mac_ctx, session,
5889 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY);
5890 }
5891}
5892
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005893void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5894{
5895 struct sir_set_he_bss_color *bss_color;
5896 tpPESession session_entry = NULL;
5897 tUpdateBeaconParams beacon_params;
5898
5899 if (!msg_buf) {
5900 pe_err("Buffer is Pointing to NULL");
5901 return;
5902 }
5903
5904 bss_color = (struct sir_set_he_bss_color *)msg_buf;
5905 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5906 bss_color->session_id);
5907 if (!session_entry) {
5908 pe_err("Session not found for given session_id %d",
5909 bss_color->session_id);
5910 return;
5911 }
5912
5913 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5914 pe_err("Invalid SystemRole %d",
5915 GET_LIM_SYSTEM_ROLE(session_entry));
5916 return;
5917 }
5918
5919 if (bss_color->bss_color == session_entry->he_op.bss_color) {
5920 pe_err("No change in BSS color, current BSS color %d",
5921 bss_color->bss_color);
5922 return;
5923 }
5924 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5925 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5926 session_entry->he_op.bss_col_disabled = 1;
5927 session_entry->he_bss_color_change.countdown =
5928 BSS_COLOR_SWITCH_COUNTDOWN;
5929 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005930 beacon_params.bss_color_disabled = 1;
5931 beacon_params.bss_color = session_entry->he_op.bss_color;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005932 session_entry->bss_color_changing = 1;
5933
5934 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005935 QDF_STATUS_SUCCESS) {
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005936 pe_err("Unable to set op mode IE in beacon");
5937 return;
5938 }
5939
5940 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
Arif Hussain05fb4872018-01-03 16:02:55 -08005941 lim_send_obss_color_collision_cfg(mac_ctx, session_entry,
5942 OBSS_COLOR_COLLISION_DETECTION_DISABLE);
5943}
5944
5945void lim_send_obss_color_collision_cfg(tpAniSirGlobal mac_ctx,
5946 tpPESession session,
5947 enum wmi_obss_color_collision_evt_type
5948 event_type)
5949{
5950 struct wmi_obss_color_collision_cfg_param *cfg_param;
5951 struct scheduler_msg msg = {0};
5952
5953 if (!session) {
5954 pe_err("Invalid session");
5955 return;
5956 }
5957
5958 if (!session->he_capable ||
5959 !session->is_session_obss_color_collision_det_enabled) {
5960 pe_debug("%d: obss color det not enabled, he_cap:%d, sup:%d:%d",
5961 session->smeSessionId, session->he_capable,
5962 session->is_session_obss_color_collision_det_enabled,
5963 mac_ctx->lim.global_obss_color_collision_det_offload);
5964 return;
5965 }
5966
5967 cfg_param = qdf_mem_malloc(sizeof(*cfg_param));
5968 if (!cfg_param) {
5969 pe_err("Failed to allocate memory");
5970 return;
5971 }
5972
5973 pe_debug("%d: sending event:%d", session->smeSessionId, event_type);
5974 qdf_mem_zero(cfg_param, sizeof(*cfg_param));
5975 cfg_param->vdev_id = session->smeSessionId;
5976 cfg_param->evt_type = event_type;
5977 if (LIM_IS_AP_ROLE(session))
5978 cfg_param->detection_period_ms =
5979 OBSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS;
5980 else
5981 cfg_param->detection_period_ms =
5982 OBSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS;
5983
5984 cfg_param->scan_period_ms = OBSS_COLOR_COLLISION_SCAN_PERIOD_MS;
5985 if (event_type == OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
5986 cfg_param->free_slot_expiry_time_ms =
5987 OBSS_COLOR_COLLISION_FREE_SLOT_EXPIRY_MS;
5988
5989 msg.type = WMA_OBSS_COLOR_COLLISION_REQ;
5990 msg.bodyptr = cfg_param;
5991 msg.reserved = 0;
5992
5993 if (QDF_IS_STATUS_ERROR(scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
5994 pe_err("Failed to post WMA_OBSS_COLOR_COLLISION_REQ to WMA");
5995 qdf_mem_free(cfg_param);
5996 } else {
5997 session->obss_color_collision_dec_evt = event_type;
5998 }
5999}
6000
6001void lim_process_obss_color_collision_info(tpAniSirGlobal mac_ctx,
6002 uint32_t *msg_buf)
6003{
6004 struct wmi_obss_color_collision_info *obss_color_info;
6005 tpPESession session;
6006
6007 if (!msg_buf) {
6008 pe_err("Buffer is Pointing to NULL");
6009 return;
6010 }
6011
6012 obss_color_info = (struct wmi_obss_color_collision_info *)msg_buf;
6013 session = pe_find_session_by_sme_session_id(mac_ctx,
6014 obss_color_info->vdev_id);
6015 if (!session) {
6016 pe_err("Session not found for given session_id %d",
6017 obss_color_info->vdev_id);
6018 return;
6019 }
6020
6021 pe_debug("vdev_id:%d, evt:%d:%d, 0to31:0x%x, 32to63:0x%x, cap:%d:%d:%d",
6022 obss_color_info->vdev_id,
6023 obss_color_info->evt_type,
6024 session->obss_color_collision_dec_evt,
6025 obss_color_info->obss_color_bitmap_bit0to31,
6026 obss_color_info->obss_color_bitmap_bit32to63,
6027 session->he_capable,
6028 session->is_session_obss_color_collision_det_enabled,
6029 mac_ctx->lim.global_obss_color_collision_det_offload);
6030
6031 if (!session->he_capable ||
6032 !session->is_session_obss_color_collision_det_enabled) {
6033 return;
6034 }
6035
6036 switch (obss_color_info->evt_type) {
6037 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
6038 pe_err("%d: FW disabled obss color det. he_cap:%d, sup:%d:%d",
6039 session->smeSessionId, session->he_capable,
6040 session->is_session_obss_color_collision_det_enabled,
6041 mac_ctx->lim.global_obss_color_collision_det_offload);
6042 session->is_session_obss_color_collision_det_enabled = false;
6043 return;
6044 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
6045 case OBSS_COLOR_COLLISION_DETECTION:
6046 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
6047 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6048 pe_debug("Invalid System Role %d",
6049 GET_LIM_SYSTEM_ROLE(session));
6050 return;
6051 }
6052
6053 if (session->obss_color_collision_dec_evt !=
6054 obss_color_info->evt_type) {
6055 pe_debug("%d: Wrong event: %d, skiping",
6056 obss_color_info->vdev_id,
6057 obss_color_info->evt_type);
6058 return;
6059 }
6060 obss_color_collision_process_color_change(mac_ctx, session,
6061 obss_color_info);
6062 break;
6063 default:
6064 pe_err("%d: Invalid event type %d",
6065 obss_color_info->vdev_id, obss_color_info->evt_type);
6066 return;
6067 }
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006068}
6069#endif