blob: 83d21c5198e2fe00eb9c49fe414fb0e7eaf166d6 [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};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203 struct sir_dual_mac_config *req_msg;
204 uint32_t len;
205 struct sir_set_dual_mac_cfg *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700206 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800207 struct sir_dual_mac_config_resp *param;
208
209 buf = (struct sir_set_dual_mac_cfg *) msg;
210 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700211 pe_err("Set Dual mac config is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800212 /* To free the active command list */
213 goto fail;
214 }
215
216 len = sizeof(*req_msg);
217
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530218 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800219 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700220 pe_err("qdf_mem_malloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800221 /* Free the active command list
222 * Probably the malloc is going to fail there as well?!
223 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530224 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225 }
226
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 req_msg->scan_config = buf->set_dual_mac.scan_config;
228 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
229 /* Other parameters are not needed for WMA */
230
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800231 message.bodyptr = req_msg;
232 message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800233
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700234 pe_debug("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235 req_msg->scan_config, req_msg->fw_mode_config);
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800236 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530237 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700238 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800239 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530240 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800241 goto fail;
242 }
243 return status;
244fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530245 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800246 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700247 pe_err("Dual mac config resp failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530248 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249 }
250 param->status = SET_HW_MODE_STATUS_ECANCELED;
251 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
252 resp_msg.bodyptr = param;
253 resp_msg.bodyval = 0;
254 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530255 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800256}
257
258/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800259 * lim_process_set_antenna_mode_req() - Set antenna mode command
260 * to WMA
261 * @mac: Global MAC pointer
262 * @msg: Message containing the antenna mode parameter
263 *
264 * Send the set antenna mode command to WMA
265 *
266 * Return: QDF_STATUS_SUCCESS if message posting is successful
267 */
268static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
269 uint32_t *msg)
270{
271 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700272 struct scheduler_msg message = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800273 struct sir_antenna_mode_param *req_msg;
274 struct sir_set_antenna_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700275 struct scheduler_msg resp_msg = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800276 struct sir_antenna_mode_resp *param;
277
278 buf = (struct sir_set_antenna_mode *) msg;
279 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700280 pe_err("Set antenna mode is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800281 /* To free the active command list */
282 goto fail;
283 }
284
285 req_msg = qdf_mem_malloc(sizeof(*req_msg));
286 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700287 pe_err("qdf_mem_malloc failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800288 return QDF_STATUS_E_NOMEM;
289 }
290
291 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
292 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
293
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800294 message.bodyptr = req_msg;
295 message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800296
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700297 pe_debug("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800298 req_msg->num_rx_chains,
299 req_msg->num_tx_chains);
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800300 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800301 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700302 pe_err("scheduler_post_msg failed!(err=%d)",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800303 status);
304 qdf_mem_free(req_msg);
305 goto fail;
306 }
307 return status;
308fail:
309 param = qdf_mem_malloc(sizeof(*param));
310 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700311 pe_err("antenna mode resp failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800312 return QDF_STATUS_E_NOMEM;
313 }
314 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
315 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
316 resp_msg.bodyptr = param;
317 resp_msg.bodyval = 0;
318 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
319 return QDF_STATUS_SUCCESS;
320}
321
322/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800323 * __lim_is_sme_assoc_cnf_valid()
324 *
325 ***FUNCTION:
326 * This function is called by __lim_process_sme_assoc_cnf_new() upon
327 * receiving SME_ASSOC_CNF.
328 *
329 ***LOGIC:
330 * Message validity checks are performed in this function
331 *
332 ***ASSUMPTIONS:
333 *
334 ***NOTE:
335 *
336 * @param pMeasReq Pointer to Received ASSOC_CNF message
337 * @return true When received SME_ASSOC_CNF is formatted
338 * correctly
339 * false otherwise
340 */
341
342static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
343{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530344 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800345 return false;
346 else
347 return true;
348} /*** end __lim_is_sme_assoc_cnf_valid() ***/
349
350/**
351 * __lim_get_sme_join_req_size_for_alloc()
352 *
353 ***FUNCTION:
354 * This function is called in various places to get IE length
355 * from tSirBssDescription structure
356 * number being scanned.
357 *
358 ***PARAMS:
359 *
360 ***LOGIC:
361 *
362 ***ASSUMPTIONS:
363 * NA
364 *
365 ***NOTE:
366 * NA
367 *
368 * @param pBssDescr
369 * @return Total IE length
370 */
371
372static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
373{
374 uint16_t len = 0;
375
376 if (!pBuf)
377 return len;
378
379 pBuf += sizeof(uint16_t);
380 len = lim_get_u16(pBuf);
Arif Hussainc9651922017-04-16 14:08:23 -0700381 return len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800382}
383
384/**
385 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
386 * @pMac: Global MAC context
387 * @pMsg: Pointer to message posted from SME to LIM.
388 *
389 * Has role only if 11h is enabled. Not used on STA side.
390 * Defers the message if SME is in learn state and brings
391 * the LIM back to normal mode.
392 *
393 * Return: true - If defered false - Otherwise
394 */
395
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800396static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac,
397 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800398{
399 if (lim_is_system_in_scan_state(pMac)) {
400 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700401 pe_err("Could not defer Msg: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800402 return false;
403 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700404 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800405 pMsg->type);
406 return true;
407 }
408 return false;
409}
410
411/**
412 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
413 * @mac_ctx: Pointer to Global MAC structure
414 * @message: Pointer to message posted from SME to LIM.
415 *
416 * Has role only if 11h is enabled. Not used on STA side.
417 * Defers the message if radar is detected.
418 *
419 * Return: true, if defered otherwise return false.
420 */
421static bool
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800422__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx,
423 struct scheduler_msg *message)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800424{
425 /*
426 * fRadarDetCurOperChan will be set only if we
427 * detect radar in current operating channel and
428 * System Role == AP ROLE
429 *
430 * TODO: Need to take care radar detection.
431 *
432 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
433 */
434 if (0) {
435 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700436 pe_err("Could not defer Msg: %d", message->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437 return false;
438 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700439 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800440 message->type);
441 return true;
442 }
443 return false;
444}
445
446/**
447 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
448 * @pMac: Global MAC context
449 * @pMsgBuf: Message from WMA
450 *
451 * handles the notification from HDD. PE just forwards this message to HAL.
452 *
453 * Return: true-Posting to HAL failed, so PE will consume the buffer.
454 * false-Posting to HAL successful, so HAL will consume the buffer.
455 */
456
457static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
458{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700459 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800460 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
461
462 msg.type = WMA_SYS_READY_IND;
463 msg.reserved = 0;
464 msg.bodyptr = pMsgBuf;
465 msg.bodyval = 0;
466
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700467 if (ANI_DRIVER_TYPE(pMac) != QDF_DRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800468 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +0530469 pe_register_mgmt_rx_frm_callback(pMac);
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700470 pe_register_callbacks_with_wma(pMac, ready_req);
Sandeep Puligilla1426d612017-04-12 18:22:06 -0700471 pMac->lim.sme_msg_callback = ready_req->sme_msg_cb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800472 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700473
474 pe_debug("sending WMA_SYS_READY_IND msg to HAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800475 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
476
477 if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700478 pe_err("wma_post_ctrl_msg failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800479 return true;
480 }
481 return false;
482}
483
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800484/**
485 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
486 *@mac_ctx: Pointer to Global MAC structure
487 *@session: A pointer to session entry
488 *@sme_start_bss_req: Start BSS Request from upper layers.
489 *
490 * This function is used to configure the start bss parameters
491 * in to the session.
492 *
493 * Return: None.
494 */
495static void
496lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
497 tpSirSmeStartBssReq sme_start_bss_req)
498{
499 session->limSystemRole = eLIM_AP_ROLE;
500 session->privacy = sme_start_bss_req->privacy;
501 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
502 session->authType = sme_start_bss_req->authType;
503 /* Store the DTIM period */
504 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
505 /* Enable/disable UAPSD */
506 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530507 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800508 session->proxyProbeRspEn = 0;
509 } else {
510 /*
511 * To detect PBC overlap in SAP WPS mode,
512 * Host handles Probe Requests.
513 */
514 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
515 session->proxyProbeRspEn = 1;
516 else
517 session->proxyProbeRspEn = 0;
518 }
519 session->ssidHidden = sme_start_bss_req->ssidHidden;
520 session->wps_state = sme_start_bss_req->wps_state;
521 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530522 session->vendor_vht_sap =
523 sme_start_bss_req->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800524 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
525 &session->shortSlotTimeSupported);
526 session->isCoalesingInIBSSAllowed =
527 sme_start_bss_req->isCoalesingInIBSSAllowed;
528
Jiachao Wu712d4fd2017-08-23 16:52:34 +0800529 session->beacon_tx_rate = sme_start_bss_req->beacon_tx_rate;
530
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800531}
532
533/**
Arif Hussain53cf5692018-04-05 16:35:54 -0700534 * lim_clear_he_tx_stbc() - Clear tx stbc for a given session
535 * @session: Session
536 *
537 * Clear tx stbc for a given session
538 *
539 * Return: None
540 */
541#ifdef WLAN_FEATURE_11AX
542static void lim_clear_he_tx_stbc(tpPESession session)
543{
544 if (session) {
545 session->he_config.tx_stbc_lt_80mhz = 0;
546 session->he_config.tx_stbc_gt_80mhz = 0;
547 }
548}
549#else
550static void lim_clear_he_tx_stbc(tpPESession session)
551{}
552#endif
553
554/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800555 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
556 *@mac_ctx: Pointer to Global MAC structure
557 *@msg_buf: A pointer to the SME message buffer
558 *
559 * This function is called to process SME_START_BSS_REQ message
560 * from HDD or upper layer application.
561 *
562 * Return: None
563 */
564static void
565__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
566{
567 uint16_t size;
568 uint32_t val = 0;
569 tSirRetStatus ret_status;
570 tSirMacChanNum channel_number;
571 tLimMlmStartReq *mlm_start_req = NULL;
572 tpSirSmeStartBssReq sme_start_bss_req = NULL;
573 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
574 /* Flag Used in case of IBSS to Auto generate BSSID. */
575 uint32_t auto_gen_bssid = false;
576 uint8_t session_id;
577 tpPESession session = NULL;
Krunal Sonib37bb352016-12-20 14:12:21 -0800578 uint8_t sme_session_id = 0xFF;
579 uint16_t sme_transaction_id = 0xFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800580 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700581 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800582 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
583
584/* FEATURE_WLAN_DIAG_SUPPORT */
585#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
586 /*
587 * Since the session is not created yet, sending NULL.
588 * The response should have the correct state.
589 */
590 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
591 NULL, 0, 0);
592#endif /* FEATURE_WLAN_DIAG_SUPPORT */
593
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700594 pe_debug("Received START_BSS_REQ");
Krunal Sonib37bb352016-12-20 14:12:21 -0800595 size = sizeof(tSirSmeStartBssReq);
596 sme_start_bss_req = qdf_mem_malloc(size);
597 if (NULL == sme_start_bss_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700598 pe_err("Allocate Memory fail for LimStartBssReq");
Krunal Sonib37bb352016-12-20 14:12:21 -0800599 /* Send failure response to host */
600 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
601 goto free;
602 }
603 qdf_mem_copy(sme_start_bss_req, msg_buf, sizeof(tSirSmeStartBssReq));
604 sme_session_id = sme_start_bss_req->sessionId;
605 sme_transaction_id = sme_start_bss_req->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800606
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800607 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
608 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800609 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
610 sme_start_bss_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700611 pe_warn("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800612 ret_code = eSIR_SME_INVALID_PARAMETERS;
613 goto free;
614 }
615
616 /*
617 * This is the place where PE is going to create a session.
618 * If session is not existed, then create a new session
619 */
620 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800621 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800622 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700623 pe_warn("Session Already exists for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800624 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
625 session = NULL;
626 goto free;
627 } else {
628 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800629 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800630 &session_id, mac_ctx->lim.maxStation,
631 sme_start_bss_req->bssType);
632 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700633 pe_warn("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800634 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
635 goto free;
636 }
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +0530637
638 /* Update the beacon/probe filter in mac_ctx */
639 lim_set_bcn_probe_filter(mac_ctx, session,
640 &sme_start_bss_req->ssId,
641 sme_start_bss_req->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800642 }
643
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700644 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
645 /* Probe resp add ie */
646 lim_start_bss_update_add_ie_buffer(mac_ctx,
647 &session->addIeParams.probeRespData_buff,
648 &session->addIeParams.probeRespDataLen,
649 sme_start_bss_req->addIeParams.
650 probeRespData_buff,
651 sme_start_bss_req->addIeParams.
652 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800653
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700654 /* Probe Beacon add ie */
655 lim_start_bss_update_add_ie_buffer(mac_ctx,
656 &session->addIeParams.probeRespBCNData_buff,
657 &session->addIeParams.probeRespBCNDataLen,
658 sme_start_bss_req->addIeParams.
659 probeRespBCNData_buff,
660 sme_start_bss_req->addIeParams.
661 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800662
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700663 /* Assoc resp IE */
664 lim_start_bss_update_add_ie_buffer(mac_ctx,
665 &session->addIeParams.assocRespData_buff,
666 &session->addIeParams.assocRespDataLen,
667 sme_start_bss_req->addIeParams.
668 assocRespData_buff,
669 sme_start_bss_req->addIeParams.
670 assocRespDataLen);
671 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800672 /* Store the session related params in newly created session */
673 session->pLimStartBssReq = sme_start_bss_req;
674
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800675 /* Store SME session Id in sessionTable */
676 session->smeSessionId = sme_start_bss_req->sessionId;
677
678 session->transactionId = sme_start_bss_req->transactionId;
679
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530680 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800681 &(sme_start_bss_req->htConfig),
682 sizeof(session->htConfig));
683
Sandeep Puligilla98917432016-06-10 13:50:28 -0700684 qdf_mem_copy(&(session->vht_config),
685 &(sme_start_bss_req->vht_config),
686 sizeof(session->vht_config));
687
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800688 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800689 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800690
691 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530692 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800693 (uint8_t *) &sme_start_bss_req->ssId,
694 (sme_start_bss_req->ssId.length + 1));
695
696 session->bssType = sme_start_bss_req->bssType;
697
698 session->nwType = sme_start_bss_req->nwType;
699
700 session->beaconParams.beaconInterval =
701 sme_start_bss_req->beaconInterval;
702
703 /* Store the channel number in session Table */
704 session->currentOperChannel =
705 sme_start_bss_req->channelId;
706
707 /* Store Persona */
708 session->pePersona = sme_start_bss_req->bssPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +0530709 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800710 FL("PE PERSONA=%d"), session->pePersona);
711
712 /* Update the phymode */
713 session->gLimPhyMode = sme_start_bss_req->nwType;
714
715 session->maxTxPower =
716 cfg_get_regulatory_max_transmit_power(mac_ctx,
717 session->currentOperChannel);
718 /* Store the dot 11 mode in to the session Table */
719 session->dot11mode = sme_start_bss_req->dot11mode;
720#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
721 session->cc_switch_mode =
722 sme_start_bss_req->cc_switch_mode;
723#endif
724 session->htCapability =
725 IS_DOT11_MODE_HT(session->dot11mode);
726 session->vhtCapability =
727 IS_DOT11_MODE_VHT(session->dot11mode);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800728
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700729 pe_debug("HT[%d], VHT[%d]",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800730 session->htCapability, session->vhtCapability);
731
732 if (IS_DOT11_MODE_HE(session->dot11mode)) {
733 lim_update_session_he_capable(mac_ctx, session);
734 lim_copy_bss_he_cap(session, sme_start_bss_req);
735 }
736
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800737 session->txLdpcIniFeatureEnabled =
738 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739#ifdef WLAN_FEATURE_11W
740 session->limRmfEnabled =
741 sme_start_bss_req->pmfCapable ? 1 : 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700742 pe_debug("Session RMF enabled: %d", session->limRmfEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743#endif
744
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530745 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800746 (void *)&sme_start_bss_req->operationalRateSet,
747 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530748 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800749 (void *)&sme_start_bss_req->extendedRateSet,
750 sizeof(tSirMacRateSet));
751
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700752 if (IS_5G_CH(session->currentOperChannel))
753 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
754 else
755 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
756
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800757 switch (sme_start_bss_req->bssType) {
758 case eSIR_INFRA_AP_MODE:
759 lim_configure_ap_start_bss_session(mac_ctx, session,
760 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700761 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700762 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700763 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700764 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800765 break;
766 case eSIR_IBSS_MODE:
767 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
768 lim_get_short_slot_from_phy_mode(mac_ctx, session,
769 session->gLimPhyMode,
770 &session->shortSlotTimeSupported);
771
772 /*
773 * initialize to "OPEN".
774 * will be updated upon key installation
775 */
776 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700777 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800778
779 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700780 case eSIR_NDI_MODE:
781 session->limSystemRole = eLIM_NDI_ROLE;
782 break;
783
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800784
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800785 /*
786 * There is one more mode called auto mode.
787 * which is used no where
788 */
789
790 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
791
792 default:
793 /* not used anywhere...used in scan function */
794 break;
795 }
796
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700797 pe_debug("persona - %d, nss - %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700798 session->pePersona, session->vdev_nss);
799 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800800 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700801 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800802 * parsed (Re)Assoc request structure
803 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700804 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800805 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530806 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700807 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800808 if (NULL == session->parsedAssocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700809 pe_warn("AllocateMemory() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800810 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
811 goto free;
812 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813 }
814
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700815 if (!sme_start_bss_req->channelId &&
816 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700817 pe_err("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800818 ret_code = eSIR_SME_INVALID_PARAMETERS;
819 goto free;
820 }
821 channel_number = sme_start_bss_req->channelId;
822#ifdef QCA_HT_2040_COEX
823 if (sme_start_bss_req->obssEnabled)
824 session->htSupportedChannelWidthSet =
825 session->htCapability;
826 else
827#endif
828 session->htSupportedChannelWidthSet =
829 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
830 session->htSecondaryChannelOffset =
831 sme_start_bss_req->sec_ch_offset;
832 session->htRecommendedTxWidthSet =
833 (session->htSecondaryChannelOffset) ? 1 : 0;
Abhishek Singh4294f802017-08-10 16:37:07 +0530834 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835 FL("cbMode %u"), sme_start_bss_req->cbMode);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800836 if (lim_is_session_he_capable(session) ||
837 session->vhtCapability || session->htCapability) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838 chanwidth = sme_start_bss_req->vht_channel_width;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700839 pe_debug("vht_channel_width %u htSupportedChannelWidthSet %d",
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800840 sme_start_bss_req->vht_channel_width,
841 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800842 session->ch_width = chanwidth;
843 if (session->htSupportedChannelWidthSet) {
844 session->ch_center_freq_seg0 =
845 sme_start_bss_req->center_freq_seg0;
846 session->ch_center_freq_seg1 =
847 sme_start_bss_req->center_freq_seg1;
848 } else {
849 session->ch_center_freq_seg0 = 0;
850 session->ch_center_freq_seg1 = 0;
851 }
852 }
853
854 if (session->vhtCapability &&
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800855 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800856 session->nss = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700857 pe_debug("nss set to [%d]", session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700859 pe_debug("vht su tx bformer %d",
Krunal Soni53993f72016-07-08 18:20:03 -0700860 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800861
862 /* Delete pre-auth list if any */
863 lim_delete_pre_auth_list(mac_ctx);
864
Krunal Soni53993f72016-07-08 18:20:03 -0700865 if (session->nss == 1) {
866 session->vht_config.su_beam_former = 0;
867 session->vht_config.tx_stbc = 0;
868 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530869 session->htConfig.ht_tx_stbc = 0;
Arif Hussain53cf5692018-04-05 16:35:54 -0700870 lim_clear_he_tx_stbc(session);
Krunal Soni53993f72016-07-08 18:20:03 -0700871 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800872 /*
873 * keep the RSN/WPA IE information in PE Session Entry
874 * later will be using this to check when received (Re)Assoc req
875 */
876 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
877 &sme_start_bss_req->rsnIE, session);
878
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700879 if (LIM_IS_AP_ROLE(session) ||
880 LIM_IS_IBSS_ROLE(session) ||
881 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800882 session->gLimProtectionControl =
883 sme_start_bss_req->protEnabled;
884 /*
885 * each byte will have the following info
886 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
887 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
888 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530889 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800890 (void *)&sme_start_bss_req->ht_capab,
891 sizeof(uint16_t));
892 /* Initialize WPS PBC session link list */
893 session->pAPWPSPBCSession = NULL;
894 }
895 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530896 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800897 if (NULL == mlm_start_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700898 pe_err("Allocate Memory failed for mlmStartReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800899 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
900 goto free;
901 }
902
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800903 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530904 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800905 (uint8_t *) &sme_start_bss_req->ssId,
906 sme_start_bss_req->ssId.length + 1);
907 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
908 mlm_start_req->obssProtEnabled =
909 sme_start_bss_req->obssProtEnabled;
910
911 mlm_start_req->bssType = session->bssType;
912
913 /* Fill PE session Id from the session Table */
914 mlm_start_req->sessionId = session->peSessionId;
915
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700916 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
917 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800918 /*
919 * Copy the BSSId from sessionTable to
920 * mlmStartReq struct
921 */
922 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
923 } else {
924 /* ibss mode */
925 mac_ctx->lim.gLimIbssCoalescingHappened = false;
926
927 ret_status = wlan_cfg_get_int(mac_ctx,
928 WNI_CFG_IBSS_AUTO_BSSID,
929 &auto_gen_bssid);
930 if (ret_status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700931 pe_err("Get Auto Gen BSSID fail,Status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800932 ret_status);
Abhishek Singh4294f802017-08-10 16:37:07 +0530933 ret_code = eSIR_LOGE_EXCEPTION;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800934 goto free;
935 }
936
937 if (!auto_gen_bssid) {
938 /*
939 * We're not auto generating BSSID.
940 * Instead, get it from session entry
941 */
942 sir_copy_mac_addr(mlm_start_req->bssId,
943 session->bssId);
944 /*
945 * Start IBSS group BSSID
946 * Auto Generating BSSID.
947 */
948 auto_gen_bssid = ((mlm_start_req->bssId[0] &
949 0x01) ? true : false);
950 }
951
952 if (auto_gen_bssid) {
953 /*
954 * if BSSID is not any uc id.
955 * then use locally generated BSSID.
956 * Autogenerate the BSSID
957 */
958 lim_get_random_bssid(mac_ctx,
959 mlm_start_req->bssId);
960 mlm_start_req->bssId[0] = 0x02;
961
962 /*
963 * Copy randomly generated BSSID
964 * to the session Table
965 */
966 sir_copy_mac_addr(session->bssId,
967 mlm_start_req->bssId);
968 }
969 }
970 /* store the channel num in mlmstart req structure */
971 mlm_start_req->channelNumber = session->currentOperChannel;
972 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
973 mlm_start_req->beaconPeriod =
974 session->beaconParams.beaconInterval;
Arif Hussain671a1902017-03-17 09:08:32 -0700975 mlm_start_req->cac_duration_ms =
976 sme_start_bss_req->cac_duration_ms;
977 mlm_start_req->dfs_regdomain =
978 sme_start_bss_req->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800979 if (LIM_IS_AP_ROLE(session)) {
980 mlm_start_req->dtimPeriod = session->dtimPeriod;
981 mlm_start_req->wps_state = session->wps_state;
982
983 } else {
984 if (wlan_cfg_get_int(mac_ctx,
985 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700986 pe_err("could not retrieve DTIM Period");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800987 mlm_start_req->dtimPeriod = (uint8_t) val;
988 }
989
990 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
991 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700992 pe_err("could not retrieve Beacon interval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800993 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
994
995 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
996 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700997 pe_err("could not retrieve CFPMaxDuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800998 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
999
1000 /*
1001 * this may not be needed anymore now,
1002 * as rateSet is now included in the
1003 * session entry and MLM has session context.
1004 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301005 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001006 (void *)&session->rateSet,
1007 sizeof(tSirMacRateSet));
1008
1009 /* Now populate the 11n related parameters */
1010 mlm_start_req->nwType = session->nwType;
1011 mlm_start_req->htCapable = session->htCapability;
1012
1013 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1014 /* Unused */
1015 mlm_start_req->dualCTSProtection =
1016 mac_ctx->lim.gHTDualCTSProtection;
1017 mlm_start_req->txChannelWidthSet =
1018 session->htRecommendedTxWidthSet;
1019
1020 session->limRFBand = lim_get_rf_band(channel_number);
1021
1022 /* Initialize 11h Enable Flag */
1023 session->lim11hEnable = 0;
gaolez76d2a162017-03-21 19:23:58 +08001024 if (mlm_start_req->bssType != eSIR_IBSS_MODE &&
1025 (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001026 BAND_5G == session->limRFBand)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001027 if (wlan_cfg_get_int(mac_ctx,
1028 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001029 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001030 else
1031 session->lim11hEnable = val;
1032
1033 if (session->lim11hEnable &&
1034 (eSIR_INFRA_AP_MODE ==
1035 mlm_start_req->bssType)) {
1036 cfg_get_wmi_dfs_master_param =
1037 wlan_cfg_get_int(mac_ctx,
1038 WNI_CFG_DFS_MASTER_ENABLED,
1039 &val);
1040 session->lim11hEnable = val;
1041 }
1042 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1043 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001044 pe_err("Get Fail, CFG DFS ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001045 }
1046
1047 if (!session->lim11hEnable) {
1048 if (cfg_set_int(mac_ctx,
1049 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1050 eSIR_SUCCESS)
1051 /*
1052 * Failed to set the CFG param
1053 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1054 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001055 pe_err("Set LOCAL_POWER_CONSTRAINT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001056 }
1057
Jiachao Wu712d4fd2017-08-23 16:52:34 +08001058 mlm_start_req->beacon_tx_rate = session->beacon_tx_rate;
1059
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001060 session->limPrevSmeState = session->limSmeState;
1061 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1062 MTRACE(mac_trace
1063 (mac_ctx, TRACE_CODE_SME_STATE,
1064 session->peSessionId,
1065 session->limSmeState));
1066
1067 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1068 (uint32_t *) mlm_start_req);
1069 return;
1070 } else {
1071
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001072 pe_err("Received unexpected START_BSS_REQ, in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001073 mac_ctx->lim.gLimSmeState);
1074 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001075 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001076 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1077
1078free:
1079 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001080 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001081 session->pLimStartBssReq = NULL;
1082 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001083 if (NULL != sme_start_bss_req)
1084 qdf_mem_free(sme_start_bss_req);
1085 if (NULL != mlm_start_req)
1086 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001087 if (NULL != session) {
1088 pe_delete_session(mac_ctx, session);
1089 session = NULL;
1090 }
1091 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1092 session, sme_session_id, sme_transaction_id);
1093}
1094
1095/**
1096 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1097 *
1098 * @pMac: Global MAC context
1099 * @pMsg: Message pointer
1100 *
1101 * Wrapper for the function __lim_handle_sme_start_bss_request
1102 * This message will be defered until softmac come out of
1103 * scan mode or if we have detected radar on the current
1104 * operating channel.
1105 *
1106 * return true - If we consumed the buffer
1107 * false - If have defered the message.
1108 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001109static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1110 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001111{
1112 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1113 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1114 /**
1115 * If message defered, buffer is not consumed yet.
1116 * So return false
1117 */
1118 return false;
1119 }
1120
1121 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1122 return true;
1123}
1124
1125/**
1126 * lim_get_random_bssid()
1127 *
1128 * FUNCTION:This function is called to process generate the random number for bssid
1129 * This function is called to process SME_SCAN_REQ message
1130 * from HDD or upper layer application.
1131 *
1132 * LOGIC:
1133 *
1134 * ASSUMPTIONS:
1135 *
1136 * NOTE:
1137 * 1. geneartes the unique random number for bssid in ibss
1138 *
1139 * @param pMac Pointer to Global MAC structure
1140 * @param *data Pointer to bssid buffer
1141 * @return None
1142 */
1143void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1144{
1145 uint32_t random[2];
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001146
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001147 random[0] = tx_time_get();
1148 random[0] |= (random[0] << 15);
1149 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301150 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001151}
1152
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001153/**
1154 * __lim_process_clear_dfs_channel_list()
1155 *
1156 ***FUNCTION:
1157 ***Clear DFS channel list when country is changed/aquired.
1158 .*This message is sent from SME.
1159 *
1160 ***LOGIC:
1161 *
1162 ***ASSUMPTIONS:
1163 *
1164 ***NOTE:
1165 *
1166 * @param pMac Pointer to Global MAC structure
1167 * @param *pMsgBuf A pointer to the SME message buffer
1168 * @return None
1169 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001170static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1171 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001172{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301173 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001174}
1175
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301176#ifdef WLAN_FEATURE_SAE
1177
1178/**
1179 * lim_update_sae_config()- This API update SAE session info to csr config
1180 * from join request.
1181 * @session: PE session
1182 * @sme_join_req: pointer to join request
1183 *
1184 * Return: None
1185 */
1186static void lim_update_sae_config(tpPESession session,
1187 tpSirSmeJoinReq sme_join_req)
1188{
1189 session->sae_pmk_cached = sme_join_req->sae_pmk_cached;
1190
1191 pe_debug("pmk_cached %d for BSSID=" MAC_ADDRESS_STR,
1192 session->sae_pmk_cached,
1193 MAC_ADDR_ARRAY(sme_join_req->bssDescription.bssId));
1194}
1195#else
1196static inline void lim_update_sae_config(tpPESession session,
1197 tpSirSmeJoinReq sme_join_req)
1198{}
1199#endif
1200
1201
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001202/**
1203 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1204 * @mac_ctx: Pointer to Global MAC structure
1205 * @msg_buf: A pointer to the SME message buffer
1206 *
1207 * This function is called to process SME_JOIN_REQ message
1208 * from HDD or upper layer application.
1209 *
1210 * Return: None
1211 */
1212static void
1213__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1214{
1215 tpSirSmeJoinReq sme_join_req = NULL;
1216 tLimMlmJoinReq *mlm_join_req;
1217 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1218 uint32_t val = 0;
1219 uint16_t n_size;
1220 uint8_t session_id;
1221 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301222 uint8_t sme_session_id = 0;
1223 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001224 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001225 uint16_t ie_len;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001226 const uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001227 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001228 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229
Arif Hussain995fcaf2016-07-18 11:28:22 -07001230 if (!mac_ctx || !msg_buf) {
1231 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1232 FL("JOIN REQ with invalid data"));
1233 return;
1234 }
1235
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001236/* FEATURE_WLAN_DIAG_SUPPORT */
1237#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1238 /*
1239 * Not sending any session, since it is not created yet.
1240 * The response whould have correct state.
1241 */
1242 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1243#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1244
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001245 /*
1246 * Expect Join request in idle state.
1247 * Reassociate request is expected in link established state.
1248 */
1249
1250 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1251 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1252 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1253 msg_buf);
1254
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301255 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001256 if (NULL == sme_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001257 pe_err("AllocateMemory failed for sme_join_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001258 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301259 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001260 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301261 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001262 n_size);
1263
1264 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1265 /* Received invalid eWNI_SME_JOIN_REQ */
1266 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001267 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001268 sme_join_req->sessionId);
1269 ret_code = eSIR_SME_INVALID_PARAMETERS;
1270 goto end;
1271 }
1272
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001273 /*
1274 * Update the capability here itself as this is used in
1275 * lim_extract_ap_capability() below. If not updated issues
1276 * like not honoring power constraint on 1st association after
1277 * driver loading might occur.
1278 */
1279 lim_update_rrm_capability(mac_ctx, sme_join_req);
1280
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001281 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001282 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001283 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001284 &session_id);
1285
1286 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001287 pe_err("Session(%d) Already exists for BSSID: "
1288 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001289 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001290 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001291 session->limSmeState);
1292
1293 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1294 session->smeSessionId == sme_join_req->sessionId) {
1295 /*
1296 * Received eWNI_SME_JOIN_REQ for same
1297 * BSS as currently associated.
1298 * Log the event and send success
1299 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001300 pe_warn("SessionId: %d", session_id);
1301 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001302 /* Send Join success response to host */
1303 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1304 session = NULL;
1305 goto end;
1306 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001307 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 ret_code = eSIR_SME_REFUSED;
1309 session = NULL;
1310 goto end;
1311 }
1312 } else {
1313 /*
1314 * Session Entry does not exist for given BSSId
1315 * Try to Create a new session
1316 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001317 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001318 &session_id, mac_ctx->lim.maxStation,
1319 eSIR_INFRASTRUCTURE_MODE);
1320 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001321 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001322 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1323 goto end;
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301324 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001325 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001326 session_id);
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301327 }
1328
1329 /* Update the beacon/probe filter in mac_ctx */
1330 lim_set_bcn_probe_filter(mac_ctx, session,
1331 &sme_join_req->ssId,
1332 bss_desc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001333 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001334 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001335
1336 /*
1337 * Store Session related parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001338 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339
1340 /* store the smejoin req handle in session table */
1341 session->pLimJoinReq = sme_join_req;
1342
1343 /* Store SME session Id in sessionTable */
1344 session->smeSessionId = sme_join_req->sessionId;
1345
1346 /* Store SME transaction Id in session Table */
1347 session->transactionId = sme_join_req->transactionId;
1348
1349 /* Store beaconInterval */
1350 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001351 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001352
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301353 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001354 sizeof(session->htConfig));
1355
Sandeep Puligilla98917432016-06-10 13:50:28 -07001356 qdf_mem_copy(&(session->vht_config),
1357 &(sme_join_req->vht_config),
1358 sizeof(session->vht_config));
1359
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001360 /* Copying of bssId is already done, while creating session */
1361 sir_copy_mac_addr(session->selfMacAddr,
1362 sme_join_req->selfMacAddr);
1363 session->bssType = sme_join_req->bsstype;
1364
1365 session->statypeForBss = STA_ENTRY_PEER;
1366 session->limWmeEnabled = sme_join_req->isWMEenabled;
1367 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301368 session->wps_registration = sme_join_req->wps_registration;
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001369 session->he_with_wep_tkip = sme_join_req->he_with_wep_tkip;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001370
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301371 session->enable_bcast_probe_rsp =
1372 sme_join_req->enable_bcast_probe_rsp;
1373
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001374 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001375 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001376 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1377
Naveen Rawat08db88f2017-09-08 15:07:48 -07001378 vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001379 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001380 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381
1382 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001383 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001384 session->isCiscoVendorAP = true;
1385 } else {
1386 session->isCiscoVendorAP = false;
1387 }
1388
1389 /* Copy the dot 11 mode in to the session table */
1390
1391 session->dot11mode = sme_join_req->dot11mode;
1392#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1393 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1394#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001395 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001396 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1397 session->enableHtSmps = sme_join_req->enableHtSmps;
1398 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001399 session->send_smps_action =
1400 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001401 /*
1402 * By default supported NSS 1x1 is set to true
1403 * and later on updated while determining session
1404 * supported rates which is the intersection of
1405 * self and peer rates
1406 */
1407 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301408 /*Store Persona */
1409 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001410 pe_debug("enable Smps: %d mode: %d send action: %d supported nss 1x1: %d pePersona %d cbMode %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001411 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001412 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001413 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301414 session->supported_nss_1x1,
1415 session->pePersona,
1416 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001417
1418 /*Store Persona */
1419 session->pePersona = sme_join_req->staPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +05301420 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301421 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d force_24ghz_in_ht20 %d"),
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001422 session->pePersona, sme_join_req->cbMode,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301423 session->nwType, session->dot11mode,
1424 sme_join_req->force_24ghz_in_ht20);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001425
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001426 /* Copy The channel Id to the session Table */
1427 session->currentOperChannel = bss_desc->channelId;
1428 if (IS_5G_CH(session->currentOperChannel))
1429 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001430 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001431 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1432 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1433 session->vdev_nss = vdev_type_nss->p2p_cli;
1434 else
1435 session->vdev_nss = vdev_type_nss->sta;
1436 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001437 session->vhtCapability =
1438 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001439 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301440 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001441 session->vht_config.su_beam_formee =
1442 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001443 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001444 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001445 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001446 session->enableVhtpAid =
1447 sme_join_req->enableVhtpAid;
1448 session->enableVhtGid =
1449 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001450 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001451 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001452 }
Krunal Soni53993f72016-07-08 18:20:03 -07001453
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001454 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301455 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001456 session->vht_config.su_beam_formee,
1457 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001458 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001459 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001460 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001461 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301462 session->force_24ghz_in_ht20 =
1463 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001464 /* cbMode is already merged value of peer and self -
1465 * done by csr in csr_get_cb_mode_from_ies */
1466 session->htSupportedChannelWidthSet =
1467 (sme_join_req->cbMode) ? 1 : 0;
1468 session->htRecommendedTxWidthSet =
1469 session->htSupportedChannelWidthSet;
1470 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1471
1472 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1473 session->ch_center_freq_seg0 =
1474 session->currentOperChannel - 2;
1475 session->ch_width = CH_WIDTH_40MHZ;
1476 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1477 sme_join_req->cbMode) {
1478 session->ch_center_freq_seg0 =
1479 session->currentOperChannel + 2;
1480 session->ch_width = CH_WIDTH_40MHZ;
1481 } else {
1482 session->ch_center_freq_seg0 = 0;
1483 session->ch_width = CH_WIDTH_20MHZ;
1484 }
1485
Naveen Rawataeca1b92017-10-16 16:55:31 -07001486 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1487 lim_update_session_he_capable(mac_ctx, session);
1488 lim_copy_join_req_he_cap(session, sme_join_req);
1489 }
1490
1491
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001492 /* Record if management frames need to be protected */
1493#ifdef WLAN_FEATURE_11W
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +05301494 if ((eSIR_ED_AES_128_CMAC ==
1495 sme_join_req->MgmtEncryptionType) ||
1496 (eSIR_ED_AES_GMAC_128 == sme_join_req->MgmtEncryptionType) ||
1497 (eSIR_ED_AES_GMAC_256 == sme_join_req->MgmtEncryptionType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001498 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001499 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001500 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001501#endif
1502
1503#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001504 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001505#endif
1506
1507 /* Copy the SSID from smejoinreq to session entry */
1508 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301509 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001510 session->ssId.length);
1511
1512 /*
1513 * Determin 11r or ESE connection based on input from SME
1514 * which inturn is dependent on the profile the user wants
1515 * to connect to, So input is coming from supplicant
1516 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001517 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001518#ifdef FEATURE_WLAN_ESE
1519 session->isESEconnection = sme_join_req->isESEconnection;
1520#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521 session->isFastTransitionEnabled =
1522 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001523
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001524 session->isFastRoamIniFeatureEnabled =
1525 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526 session->txLdpcIniFeatureEnabled =
1527 sme_join_req->txLdpcIniFeatureEnabled;
1528
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301529 lim_update_fils_config(session, sme_join_req);
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301530 lim_update_sae_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1532 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001533 } else {
1534 /*
1535 * Throw an error and return and make
1536 * sure to delete the session.
1537 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001538 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001539 session->bssType);
1540 ret_code = eSIR_SME_INVALID_PARAMETERS;
1541 goto end;
1542 }
1543
1544 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301545 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001546 &sme_join_req->addIEScan, sizeof(tSirAddie));
1547
1548 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301549 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001550 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1551
1552 val = sizeof(tLimMlmJoinReq) +
1553 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301554 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001555 if (NULL == mlm_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001556 pe_err("AllocateMemory failed for mlmJoinReq");
Nitesh Shah0102cac2016-07-13 14:38:30 +05301557 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1558 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001559 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001560
1561 /* PE SessionId is stored as a part of JoinReq */
1562 mlm_join_req->sessionId = session->peSessionId;
1563
1564 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1565 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1566 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001567 pe_err("couldn't retrieve JoinFailureTimer value"
1568 " setting to default value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001569 mlm_join_req->joinFailureTimeout =
1570 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1571 }
1572
1573 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301574 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001575 (void *)&sme_join_req->operationalRateSet,
1576 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301577 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001578 (void *)&sme_join_req->extendedRateSet,
1579 sizeof(tSirMacRateSet));
1580 /*
1581 * this may not be needed anymore now, as rateSet is now
1582 * included in the session entry and MLM has session context.
1583 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301584 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001585 (void *)&session->rateSet,
1586 sizeof(tSirMacRateSet));
1587
1588 session->encryptType = sme_join_req->UCEncryptionType;
1589
1590 mlm_join_req->bssDescription.length =
1591 session->pLimJoinReq->bssDescription.length;
1592
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301593 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001594 (uint8_t *)
1595 &session->pLimJoinReq->bssDescription.bssId,
1596 session->pLimJoinReq->bssDescription.length + 2);
1597
1598 session->limCurrentBssCaps =
1599 session->pLimJoinReq->bssDescription.capabilityInfo;
1600
1601 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1602 session->currentOperChannel);
1603 local_power_constraint = reg_max;
1604
1605 lim_extract_ap_capability(mac_ctx,
1606 (uint8_t *)
1607 session->pLimJoinReq->bssDescription.ieFields,
1608 lim_get_ielen_from_bss_description(
1609 &session->pLimJoinReq->bssDescription),
1610 &session->limCurrentBssQosCaps,
1611 &session->limCurrentBssPropCap,
1612 &session->gLimCurrentBssUapsd,
1613 &local_power_constraint, session);
1614
Krunal Soni53993f72016-07-08 18:20:03 -07001615 /*
1616 * Once the AP capabilities are available then set the
1617 * beam forming capabilities accordingly.
1618 */
1619 if (session->nss == 1) {
1620 session->vht_config.su_beam_former = 0;
1621 session->vht_config.tx_stbc = 0;
1622 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301623 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001624 }
1625
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001626 session->maxTxPower = lim_get_max_tx_power(reg_max,
1627 local_power_constraint,
1628 mac_ctx->roam.configParam.nTxPowerCap);
Abhinav Kumard528d192018-03-09 17:31:12 +05301629 session->def_max_tx_pwr = session->maxTxPower;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301630
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001631 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301632 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001633
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301634 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1635 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1636 pe_debug("Update MaxTxPower in join Req to %d",
1637 sme_join_req->powerCap.maxTxPower);
1638 }
1639
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001640 if (session->gLimCurrentBssUapsd) {
1641 session->gUapsdPerAcBitmask =
1642 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001643 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001644 session->gUapsdPerAcBitmask);
1645
1646 /* resetting the dynamic uapsd mask */
1647 session->gUapsdPerAcDeliveryEnableMask = 0;
1648 session->gUapsdPerAcTriggerEnableMask = 0;
1649 }
1650
1651 session->limRFBand =
1652 lim_get_rf_band(session->currentOperChannel);
1653
1654 /* Initialize 11h Enable Flag */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001655 if (BAND_5G == session->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001656 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1657 &val) != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001658 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001659 session->lim11hEnable =
1660 WNI_CFG_11H_ENABLED_STADEF;
1661 } else {
1662 session->lim11hEnable = val;
1663 }
1664 } else {
1665 session->lim11hEnable = 0;
1666 }
1667
1668 /*
1669 * To care of the scenario when STA transitions from
1670 * IBSS to Infrastructure mode.
1671 */
1672 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1673
1674 session->limPrevSmeState = session->limSmeState;
1675 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1676 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1677 session->peSessionId,
1678 session->limSmeState));
1679
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001680 /* Indicate whether spectrum management is enabled */
1681 session->spectrumMgtEnabled =
1682 sme_join_req->spectrumMgtIndicator;
1683
1684 /* Enable the spectrum management if this is a DFS channel */
1685 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001686 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001687 session->currentOperChannel))
1688 session->spectrumMgtEnabled = true;
1689
1690 session->isOSENConnection = sme_join_req->isOSENConnection;
1691
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692 /* Issue LIM_MLM_JOIN_REQ to MLM */
1693 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1694 (uint32_t *) mlm_join_req);
1695 return;
1696
1697 } else {
1698 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001699 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001700 mac_ctx->lim.gLimSmeState);
1701 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1702 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1703 session = NULL;
1704 goto end;
1705 }
1706
1707end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301708 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1709 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001710
1711 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301712 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001713 sme_join_req = NULL;
1714 if (NULL != session)
1715 session->pLimJoinReq = NULL;
1716 }
1717 if (ret_code != eSIR_SME_SUCCESS) {
1718 if (NULL != session) {
1719 pe_delete_session(mac_ctx, session);
1720 session = NULL;
1721 }
1722 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001723 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001724 sme_session_id, ret_code);
1725 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1726 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1727 sme_transaction_id);
1728}
1729
Amar Singhala297bfa2015-10-15 15:07:29 -07001730uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001731 uint8_t iniTxPower)
1732{
1733 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301734 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001735
Anurag Chouhan6d760662016-02-20 16:05:43 +05301736 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001737 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1738 maxTxPower = txPower;
1739 else if (txPower < MIN_TX_PWR_CAP)
1740 maxTxPower = MIN_TX_PWR_CAP;
1741 else
1742 maxTxPower = MAX_TX_PWR_CAP;
1743
1744 return maxTxPower;
1745}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001746
1747/**
1748 * __lim_process_sme_reassoc_req() - process reassoc req
1749 *
1750 * @mac_ctx: Pointer to Global MAC structure
1751 * @msg_buf: pointer to the SME message buffer
1752 *
1753 * This function is called to process SME_REASSOC_REQ message
1754 * from HDD or upper layer application.
1755 *
1756 * Return: None
1757 */
1758
1759static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
1760 uint32_t *msg_buf)
1761{
1762 uint16_t caps;
1763 uint32_t val;
1764 tpSirSmeJoinReq reassoc_req = NULL;
1765 tLimMlmReassocReq *mlm_reassoc_req;
1766 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1767 tpPESession session_entry = NULL;
1768 uint8_t session_id;
1769 uint8_t sme_session_id;
1770 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001771 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001772 uint32_t tele_bcn_en = 0;
1773 uint16_t size;
1774
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001775 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301776 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001777 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001778 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001779
1780 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1781 goto end;
1782 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301783 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784
1785 if (!lim_is_sme_join_req_valid(mac_ctx,
1786 (tpSirSmeJoinReq)reassoc_req)) {
1787 /*
1788 * Received invalid eWNI_SME_REASSOC_REQ
1789 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001790 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001791
1792 ret_code = eSIR_SME_INVALID_PARAMETERS;
1793 goto end;
1794 }
1795
1796 session_entry = pe_find_session_by_bssid(mac_ctx,
1797 reassoc_req->bssDescription.bssId,
1798 &session_id);
1799 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001800 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001801 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
1802 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001803 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001804 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
1805 &sme_session_id, &transaction_id);
1806 session_entry =
1807 pe_find_session_by_sme_session_id(mac_ctx,
1808 sme_session_id);
1809 if (session_entry != NULL)
1810 lim_handle_sme_join_result(mac_ctx,
1811 eSIR_SME_INVALID_PARAMETERS,
1812 eSIR_MAC_UNSPEC_FAILURE_STATUS,
1813 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001814 goto end;
1815 }
1816#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
1817 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
1818 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
1819#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1820 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
1821
1822 /* Store the reassoc handle in the session Table */
1823 session_entry->pLimReAssocReq = reassoc_req;
1824
1825 session_entry->dot11mode = reassoc_req->dot11mode;
1826 session_entry->vhtCapability =
1827 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001828
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301829 if (session_entry->vhtCapability) {
1830 if (session_entry->pePersona == QDF_STA_MODE) {
1831 session_entry->vht_config.su_beam_formee =
1832 reassoc_req->vht_config.su_beam_formee;
1833 } else {
1834 reassoc_req->vht_config.su_beam_formee = 0;
1835 }
1836 session_entry->enableVhtpAid =
1837 reassoc_req->enableVhtpAid;
1838 session_entry->enableVhtGid =
1839 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001840 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301841 }
1842
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001843 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301844 session_entry->vhtCapability,
1845 session_entry->vht_config.su_beam_formee,
1846 session_entry->vht_config.su_beam_former);
1847
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001848 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
1849 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001850 session_entry->send_smps_action =
1851 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001852 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001853 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001854 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001855 session_entry->send_smps_action,
1856 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001857 /*
1858 * Reassociate request is expected
1859 * in link established state only.
1860 */
1861
1862 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001863 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
1864 /*
1865 * May be from 11r FT pre-auth. So lets check it
1866 * before we bail out
1867 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001868 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001869 session_entry->peSessionId);
1870
1871 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301872 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001873 session_entry->limReAssocbssId,
1874 6)) {
1875 lim_print_mac_addr(mac_ctx,
1876 reassoc_req->bssDescription.
1877 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001878 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001879 ret_code = eSIR_SME_INVALID_PARAMETERS;
1880 goto end;
1881 }
1882
1883 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
1884 session_entry);
1885 return;
1886 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001887 /*
1888 * Should not have received eWNI_SME_REASSOC_REQ
1889 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001890 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891 session_entry->limSmeState);
1892 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
1893
1894 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1895 goto end;
1896 }
1897
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301898 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001899 session_entry->pLimReAssocReq->bssDescription.bssId,
1900 sizeof(tSirMacAddr));
1901
1902 session_entry->limReassocChannelId =
1903 session_entry->pLimReAssocReq->bssDescription.channelId;
1904
1905 session_entry->reAssocHtSupportedChannelWidthSet =
1906 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
1907 session_entry->reAssocHtRecommendedTxWidthSet =
1908 session_entry->reAssocHtSupportedChannelWidthSet;
1909 session_entry->reAssocHtSecondaryChannelOffset =
1910 session_entry->pLimReAssocReq->cbMode;
1911
1912 session_entry->limReassocBssCaps =
1913 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
1914 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1915 session_entry->currentOperChannel);
1916 local_pwr_constraint = reg_max;
1917
1918 lim_extract_ap_capability(mac_ctx,
1919 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
1920 lim_get_ielen_from_bss_description(
1921 &session_entry->pLimReAssocReq->bssDescription),
1922 &session_entry->limReassocBssQosCaps,
1923 &session_entry->limReassocBssPropCap,
1924 &session_entry->gLimCurrentBssUapsd,
1925 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05301926 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001927 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301928 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001929 /* Copy the SSID from session entry to local variable */
1930 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301931 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001932 reassoc_req->ssId.ssId,
1933 session_entry->limReassocSSID.length);
1934 if (session_entry->gLimCurrentBssUapsd) {
1935 session_entry->gUapsdPerAcBitmask =
1936 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001937 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001938 session_entry->gUapsdPerAcBitmask);
1939 }
1940
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301941 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001942 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001943 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944
1945 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1946 goto end;
1947 }
1948
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301949 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001950 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
1951
1952 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
1953 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001954 eSIR_SUCCESS)
1955 pe_err("could not retrieve ReassocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001956
1957 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001958 eSIR_SUCCESS)
1959 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301960
1961 lim_update_caps_info_for_bss(mac_ctx, &caps,
1962 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001963 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301964
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001965 mlm_reassoc_req->capabilityInfo = caps;
1966
1967 /* Update PE session_id */
1968 mlm_reassoc_req->sessionId = session_id;
1969
1970 /*
1971 * If telescopic beaconing is enabled, set listen interval to
1972 * WNI_CFG_TELE_BCN_MAX_LI
1973 */
1974 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
1975 &tele_bcn_en) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001976 pe_err("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001977
1978 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
1979
1980 if (tele_bcn_en) {
1981 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
1982 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001983 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001984 } else {
1985 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
1986 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001987 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001988 }
1989
1990 mlm_reassoc_req->listenInterval = (uint16_t) val;
1991
1992 /* Indicate whether spectrum management is enabled */
1993 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
1994
1995 /* Enable the spectrum management if this is a DFS channel */
1996 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001997 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 session_entry->currentOperChannel))
1999 session_entry->spectrumMgtEnabled = true;
2000
2001 session_entry->limPrevSmeState = session_entry->limSmeState;
2002 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2003
2004 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2005 session_entry->peSessionId,
2006 session_entry->limSmeState));
2007
2008 lim_post_mlm_message(mac_ctx,
2009 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2010 return;
2011end:
2012 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302013 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002014 if (session_entry)
2015 session_entry->pLimReAssocReq = NULL;
2016 }
2017
2018 if (session_entry) {
2019 /*
2020 * error occurred after we determined the session so extract
2021 * session and transaction info from there
2022 */
2023 sme_session_id = session_entry->smeSessionId;
2024 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002025 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002026 /*
2027 * error occurred before or during the time we determined
2028 * the session so extract the session and transaction info
2029 * from the message
2030 */
2031 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2032 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002033 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002034 /*
2035 * Send Reassoc failure response to host
2036 * (note session_entry may be NULL, but that's OK)
2037 */
2038 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2039 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2040 session_entry, sme_session_id,
2041 transaction_id);
2042}
2043
2044bool send_disassoc_frame = 1;
2045/**
2046 * __lim_process_sme_disassoc_req()
2047 *
2048 ***FUNCTION:
2049 * This function is called to process SME_DISASSOC_REQ message
2050 * from HDD or upper layer application.
2051 *
2052 ***LOGIC:
2053 *
2054 ***ASSUMPTIONS:
2055 *
2056 ***NOTE:
2057 *
2058 * @param pMac Pointer to Global MAC structure
2059 * @param *pMsgBuf A pointer to the SME message buffer
2060 * @return None
2061 */
2062
2063static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2064{
2065 uint16_t disassocTrigger, reasonCode;
2066 tLimMlmDisassocReq *pMlmDisassocReq;
2067 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2068 tSirSmeDisassocReq smeDisassocReq;
2069 tpPESession psessionEntry = NULL;
2070 uint8_t sessionId;
2071 uint8_t smesessionId;
2072 uint16_t smetransactionId;
2073
2074 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002075 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002076 return;
2077 }
2078
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302079 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002080 smesessionId = smeDisassocReq.sessionId;
2081 smetransactionId = smeDisassocReq.transactionId;
2082 if (!lim_is_sme_disassoc_req_valid(pMac,
2083 &smeDisassocReq,
2084 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002085 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002086 if (pMac->lim.gLimRspReqd) {
2087 pMac->lim.gLimRspReqd = false;
2088
2089 retCode = eSIR_SME_INVALID_PARAMETERS;
2090 disassocTrigger = eLIM_HOST_DISASSOC;
2091 goto sendDisassoc;
2092 }
2093
2094 return;
2095 }
2096
2097 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002098 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002099 &sessionId);
2100 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002101 pe_err("session does not exist for given bssId "
2102 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002103 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002104 retCode = eSIR_SME_INVALID_PARAMETERS;
2105 disassocTrigger = eLIM_HOST_DISASSOC;
2106 goto sendDisassoc;
2107 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002108 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2109 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002110 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2111 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002112 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002113
2114#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2115 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2116 0, smeDisassocReq.reasonCode);
2117#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2118
2119 /* Update SME session Id and SME transaction ID */
2120
2121 psessionEntry->smeSessionId = smesessionId;
2122 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002123 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002124 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002125
2126 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2127 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002128 switch (psessionEntry->limSmeState) {
2129 case eLIM_SME_ASSOCIATED_STATE:
2130 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002131 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002132 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002133 psessionEntry->limPrevSmeState =
2134 psessionEntry->limSmeState;
2135 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002136 /* Delete all TDLS peers connected before leaving BSS */
2137 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002138 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2139 psessionEntry->peSessionId,
2140 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002141 break;
2142
2143 case eLIM_SME_WT_DEAUTH_STATE:
2144 /* PE shall still process the DISASSOC_REQ and proceed with
2145 * link tear down even if it had already sent a DEAUTH_IND to
2146 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2147 * its been set when PE entered WT_DEAUTH_STATE.
2148 */
2149 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2150 MTRACE(mac_trace
2151 (pMac, TRACE_CODE_SME_STATE,
2152 psessionEntry->peSessionId,
2153 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002154 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002155 break;
2156
2157 case eLIM_SME_WT_DISASSOC_STATE:
2158 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2159 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2160 * PE can continue processing DISASSOC_REQ and send the response instead
2161 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2162 * for disassoc frame.
2163 *
2164 * It will send a disassoc, which is ok. However, we can use the global flag
2165 * sendDisassoc to not send disassoc frame.
2166 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002167 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002168 break;
2169
2170 case eLIM_SME_JOIN_FAILURE_STATE: {
2171 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002172 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002173 if (pMac->lim.gLimRspReqd) {
2174 retCode = eSIR_SME_SUCCESS;
2175 disassocTrigger = eLIM_HOST_DISASSOC;
2176 goto sendDisassoc;
2177 }
2178 }
2179 break;
2180 default:
2181 /**
2182 * STA is not currently associated.
2183 * Log error and send response to host
2184 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002185 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002186 psessionEntry->limSmeState);
2187 lim_print_sme_state(pMac, LOGE,
2188 psessionEntry->limSmeState);
2189
2190 if (pMac->lim.gLimRspReqd) {
2191 if (psessionEntry->limSmeState !=
2192 eLIM_SME_WT_ASSOC_STATE)
2193 pMac->lim.gLimRspReqd = false;
2194
2195 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2196 disassocTrigger = eLIM_HOST_DISASSOC;
2197 goto sendDisassoc;
2198 }
2199
2200 return;
2201 }
2202
2203 break;
2204
2205 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002206 /* Fall through */
2207 break;
2208
2209 case eLIM_STA_IN_IBSS_ROLE:
2210 default:
2211 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002212 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002213 GET_LIM_SYSTEM_ROLE(psessionEntry));
2214
2215 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2216 disassocTrigger = eLIM_HOST_DISASSOC;
2217 goto sendDisassoc;
2218 } /* end switch (pMac->lim.gLimSystemRole) */
2219
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302220 disassocTrigger = eLIM_HOST_DISASSOC;
2221 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002222
2223 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002224 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002225 send_disassoc_frame = 0;
2226 }
2227 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002228 pe_debug("Sending Disasscoc with disassoc Trigger"
2229 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002230 disassocTrigger, reasonCode);
2231
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302232 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002233 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002234 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002235 return;
2236 }
2237
Anurag Chouhanc5548422016-02-24 18:33:27 +05302238 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002239 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002240
2241 pMlmDisassocReq->reasonCode = reasonCode;
2242 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2243
2244 /* Update PE session ID */
2245 pMlmDisassocReq->sessionId = sessionId;
2246
2247 lim_post_mlm_message(pMac,
2248 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2249 return;
2250
2251sendDisassoc:
2252 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002253 lim_send_sme_disassoc_ntf(pMac,
2254 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002255 retCode,
2256 disassocTrigger,
2257 1, smesessionId, smetransactionId,
2258 psessionEntry);
2259 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002260 lim_send_sme_disassoc_ntf(pMac,
2261 smeDisassocReq.peer_macaddr.bytes,
2262 retCode, disassocTrigger, 1,
2263 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002264
2265} /*** end __lim_process_sme_disassoc_req() ***/
2266
2267/** -----------------------------------------------------------------
2268 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2269
2270 This function is called to process SME_DISASSOC_CNF message
2271 from HDD or upper layer application.
2272
2273 \param pMac - global mac structure
2274 \param pStaDs - station dph hash node
2275 \return none
2276 \sa
2277 ----------------------------------------------------------------- */
2278static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2279{
2280 tSirSmeDisassocCnf smeDisassocCnf;
2281 uint16_t aid;
2282 tpDphHashNode pStaDs;
2283 tpPESession psessionEntry;
2284 uint8_t sessionId;
2285
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302286 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002287 sizeof(struct sSirSmeDisassocCnf));
2288
2289 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002290 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002291 &sessionId);
2292 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002293 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002294 return;
2295 }
2296
2297 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002298 pe_err("received invalid SME_DISASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002299 return;
2300 }
2301#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2302 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2303 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2304 psessionEntry,
2305 (uint16_t) smeDisassocCnf.statusCode, 0);
2306 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2307 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2308 psessionEntry,
2309 (uint16_t) smeDisassocCnf.statusCode, 0);
2310#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2311
2312 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2313 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002314 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2315 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2316 && (psessionEntry->limSmeState !=
2317 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002318 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002319 psessionEntry->limSmeState);
2320 lim_print_sme_state(pMac, LOGE,
2321 psessionEntry->limSmeState);
2322 return;
2323 }
2324 break;
2325
2326 case eLIM_AP_ROLE:
2327 /* Fall through */
2328 break;
2329
2330 case eLIM_STA_IN_IBSS_ROLE:
2331 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002332 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002333 GET_LIM_SYSTEM_ROLE(psessionEntry));
2334
2335 return;
2336 }
2337
2338 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2339 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2340 LIM_IS_AP_ROLE(psessionEntry)) {
2341 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002342 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002343 &psessionEntry->dph.dphHashTable);
2344 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002345 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2346 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002347 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002348 return;
2349 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302350
2351 if ((pStaDs->mlmStaContext.mlmState ==
2352 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2353 (pStaDs->mlmStaContext.mlmState ==
2354 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002355 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002356 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302357 pStaDs->mlmStaContext.mlmState);
2358 return;
2359 }
2360
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002361 /* Delete FT session if there exists one */
2362 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002363 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2364
2365 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002366 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002367 }
2368
2369 return;
2370}
2371
2372/**
2373 * __lim_process_sme_deauth_req() - process sme deauth req
2374 * @mac_ctx: Pointer to Global MAC structure
2375 * @msg_buf: pointer to the SME message buffer
2376 *
2377 * This function is called to process SME_DEAUTH_REQ message
2378 * from HDD or upper layer application.
2379 *
2380 * Return: None
2381 */
2382
2383static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2384 uint32_t *msg_buf)
2385{
2386 uint16_t deauth_trigger, reason_code;
2387 tLimMlmDeauthReq *mlm_deauth_req;
2388 tSirSmeDeauthReq sme_deauth_req;
2389 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2390 tpPESession session_entry;
2391 uint8_t session_id; /* PE sessionId */
2392 uint8_t sme_session_id;
2393 uint16_t sme_transaction_id;
2394
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302395 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002396 sme_session_id = sme_deauth_req.sessionId;
2397 sme_transaction_id = sme_deauth_req.transactionId;
2398
2399 /*
2400 * We need to get a session first but we don't even know
2401 * if the message is correct.
2402 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002403 session_entry = pe_find_session_by_bssid(mac_ctx,
2404 sme_deauth_req.bssid.bytes,
2405 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002406 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002407 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 ret_code = eSIR_SME_INVALID_PARAMETERS;
2409 deauth_trigger = eLIM_HOST_DEAUTH;
2410 goto send_deauth;
2411 }
2412
2413 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2414 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002415 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002416 mac_ctx->lim.gLimRspReqd = false;
2417
2418 ret_code = eSIR_SME_INVALID_PARAMETERS;
2419 deauth_trigger = eLIM_HOST_DEAUTH;
2420 goto send_deauth;
2421 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002422 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2423 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002424 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2425 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002426 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002427#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2428 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2429 session_entry, 0, sme_deauth_req.reasonCode);
2430#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2431
2432 /* Update SME session ID and Transaction ID */
2433 session_entry->smeSessionId = sme_session_id;
2434 session_entry->transactionId = sme_transaction_id;
2435
2436 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2437 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002438 switch (session_entry->limSmeState) {
2439 case eLIM_SME_ASSOCIATED_STATE:
2440 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302441 /* Delete all TDLS peers connected before leaving BSS */
2442 lim_delete_tdls_peers(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002443 case eLIM_SME_WT_ASSOC_STATE:
2444 case eLIM_SME_JOIN_FAILURE_STATE:
2445 case eLIM_SME_IDLE_STATE:
2446 session_entry->limPrevSmeState =
2447 session_entry->limSmeState;
2448 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2449 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2450 session_entry->peSessionId,
2451 session_entry->limSmeState));
2452 /* Send Deauthentication request to MLM below */
2453 break;
2454 case eLIM_SME_WT_DEAUTH_STATE:
2455 case eLIM_SME_WT_DISASSOC_STATE:
2456 /*
2457 * PE Recieved a Deauth/Disassoc frame. Normally it get
2458 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2459 * Which means host is also trying to disconnect.
2460 * PE can continue processing DEAUTH_REQ and send
2461 * the response instead of failing the request.
2462 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2463 * was sent for deauth/disassoc frame.
2464 */
2465 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002466 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002467 break;
2468 default:
2469 /*
2470 * STA is not in a state to deauthenticate with
2471 * peer. Log error and send response to host.
2472 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002473 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002474 session_entry->limSmeState);
2475 lim_print_sme_state(mac_ctx, LOGE,
2476 session_entry->limSmeState);
2477
2478 if (mac_ctx->lim.gLimRspReqd) {
2479 mac_ctx->lim.gLimRspReqd = false;
2480
2481 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2482 deauth_trigger = eLIM_HOST_DEAUTH;
2483
wadesong42968e92017-06-08 14:11:21 +08002484 /*
2485 * here we received deauth request from AP so
2486 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2487 * have ISSUED delSta then mlm state should be
2488 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2489 * delBSS rsp then mlm state should be
2490 * eLIM_MLM_IDLE_STATE so the below condition
2491 * captures the state where delSta not done
2492 * and firmware still in connected state.
2493 */
2494 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002495 eLIM_SME_WT_DEAUTH_STATE &&
2496 session_entry->limMlmState !=
2497 eLIM_MLM_IDLE_STATE &&
2498 session_entry->limMlmState !=
2499 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002500 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002501 goto send_deauth;
2502 }
2503 return;
2504 }
2505 break;
2506
2507 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002508 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002509 if (mac_ctx->lim.gLimRspReqd) {
2510 mac_ctx->lim.gLimRspReqd = false;
2511 ret_code = eSIR_SME_INVALID_PARAMETERS;
2512 deauth_trigger = eLIM_HOST_DEAUTH;
2513 goto send_deauth;
2514 }
2515 return;
2516 case eLIM_AP_ROLE:
2517 break;
2518 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002519 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002520 GET_LIM_SYSTEM_ROLE(session_entry));
2521 if (mac_ctx->lim.gLimRspReqd) {
2522 mac_ctx->lim.gLimRspReqd = false;
2523 ret_code = eSIR_SME_INVALID_PARAMETERS;
2524 deauth_trigger = eLIM_HOST_DEAUTH;
2525 goto send_deauth;
2526 }
2527 return;
2528 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2529
2530 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2531 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002532 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002533 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2534 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2535 } else {
2536 deauth_trigger = eLIM_HOST_DEAUTH;
2537 reason_code = sme_deauth_req.reasonCode;
2538 }
2539
2540 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302541 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002542 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002543 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002544 if (mac_ctx->lim.gLimRspReqd) {
2545 mac_ctx->lim.gLimRspReqd = false;
2546 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2547 deauth_trigger = eLIM_HOST_DEAUTH;
2548 goto send_deauth;
2549 }
2550 return;
2551 }
2552
Anurag Chouhanc5548422016-02-24 18:33:27 +05302553 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002554 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002555
2556 mlm_deauth_req->reasonCode = reason_code;
2557 mlm_deauth_req->deauthTrigger = deauth_trigger;
2558
2559 /* Update PE session Id */
2560 mlm_deauth_req->sessionId = session_id;
2561
2562 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2563 (uint32_t *)mlm_deauth_req);
2564 return;
2565
2566send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002567 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2568 ret_code, deauth_trigger, 1,
2569 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002570}
2571
2572/**
2573 * __lim_process_sme_set_context_req()
2574 *
2575 * @mac_ctx: Pointer to Global MAC structure
2576 * @msg_buf: pointer to the SME message buffer
2577 *
2578 * This function is called to process SME_SETCONTEXT_REQ message
2579 * from HDD or upper layer application.
2580 *
2581 * Return: None
2582 */
2583
2584static void
2585__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2586{
2587 tpSirSmeSetContextReq set_context_req;
2588 tLimMlmSetKeysReq *mlm_set_key_req;
2589 tpPESession session_entry;
2590 uint8_t session_id; /* PE sessionID */
2591 uint8_t sme_session_id;
2592 uint16_t sme_transaction_id;
2593
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002594 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002595 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002596 return;
2597 }
2598
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302599 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002600 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002601 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002602 return;
2603 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302604 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002605 sizeof(struct sSirSmeSetContextReq));
2606 sme_session_id = set_context_req->sessionId;
2607 sme_transaction_id = set_context_req->transactionId;
2608
2609 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002610 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002611 goto end;
2612 }
2613
2614 if (set_context_req->keyMaterial.numKeys >
2615 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002616 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002617 set_context_req->keyMaterial.numKeys);
2618 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002619 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002620 eSIR_SME_INVALID_PARAMETERS, NULL,
2621 sme_session_id, sme_transaction_id);
2622 goto end;
2623 }
2624
2625 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002626 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002627 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002628 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002629 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002630 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002631 eSIR_SME_INVALID_PARAMETERS, NULL,
2632 sme_session_id, sme_transaction_id);
2633 goto end;
2634 }
2635#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2636 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2637 session_entry, 0, 0);
2638#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2639
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002640 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002641 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2642 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002643 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002644 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2645 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302646 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002647 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002648 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002649 goto end;
2650 }
2651 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2652 mlm_set_key_req->numKeys =
2653 set_context_req->keyMaterial.numKeys;
2654 if (mlm_set_key_req->numKeys >
2655 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002656 pe_err("no.of keys exceeded max num of default keys limit");
Jingxiang Ge4168a232018-01-03 18:47:15 +08002657 qdf_mem_free(mlm_set_key_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002658 goto end;
2659 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302660 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002661 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002662
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302663 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002664 (uint8_t *) &set_context_req->keyMaterial.key,
2665 sizeof(tSirKeys) *
2666 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2667 numKeys : 1));
2668
2669 mlm_set_key_req->sessionId = session_id;
2670 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002671 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002672 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002673
2674 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2675 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2676 LIM_IS_AP_ROLE(session_entry)) {
2677 if (set_context_req->keyMaterial.key[0].keyLength) {
2678 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002679
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002680 key_id =
2681 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302682 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002683 &session_entry->WEPKeyMaterial[key_id],
2684 (uint8_t *) &set_context_req->keyMaterial,
2685 sizeof(tSirKeyMaterial));
2686 } else {
2687 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002688
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002689 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2690 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302691 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002692 &mlm_set_key_req->key[i],
2693 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2694 sizeof(tSirKeys));
2695 }
2696 }
2697 }
2698 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2699 (uint32_t *) mlm_set_key_req);
2700 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002701 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002702 GET_LIM_SYSTEM_ROLE(session_entry),
2703 session_entry->limSmeState);
2704 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2705
2706 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002707 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002708 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2709 session_entry, sme_session_id,
2710 sme_transaction_id);
2711 }
2712end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302713 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002714 return;
2715}
2716
2717/**
2718 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2719 *
2720 * @mac_ctx: Pointer to Global MAC structure
2721 * @msg_buf: pointer to the SME message buffer
2722 *
2723 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2724 * from HDD or upper layer application.
2725 *
2726 * Return: None
2727 */
2728
Jeff Johnson801f1532016-10-07 07:54:50 -07002729static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2730 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002731{
2732 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2733 tpDphHashNode sta_ds = NULL;
2734 tpPESession session_entry = NULL;
2735 tSap_Event sap_event;
2736 tpWLAN_SAPEventCB sap_event_cb = NULL;
2737 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2738 uint8_t session_id = CSR_SESSION_ID_INVALID;
2739 uint8_t assoc_id = 0;
2740 uint8_t sta_cnt = 0;
2741
2742 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002743 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002744 return;
2745 }
2746
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302747 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002748 sizeof(struct sSirSmeGetAssocSTAsReq));
2749 /*
2750 * Get Associated stations from PE.
2751 * Find PE session Entry
2752 */
2753 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08002754 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002755 &session_id);
2756 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002757 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002758 goto lim_assoc_sta_end;
2759 }
2760
2761 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002762 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002763 session_entry->limSmeState,
2764 GET_LIM_SYSTEM_ROLE(session_entry));
2765 goto lim_assoc_sta_end;
2766 }
2767 /* Retrieve values obtained in the request message */
2768 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
2769 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2770
2771 if (NULL == assoc_sta_tmp)
2772 goto lim_assoc_sta_end;
2773 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
2774 assoc_id++) {
2775 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
2776 &session_entry->dph.dphHashTable);
2777 if (NULL == sta_ds)
2778 continue;
2779 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302780 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002781 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302782 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002783 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
2784 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
2785
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302786 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002787 (uint8_t *)&sta_ds->supportedRates,
2788 sizeof(tSirSupportedRates));
2789 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
2790 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
2791 assoc_sta_tmp->Support40Mhz =
2792 sta_ds->htDsssCckRate40MHzSupport;
2793
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002794 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002795 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002796 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002797 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002798 pe_debug("Association Id: %d Station Index: %d",
2799 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002800 assoc_sta_tmp++;
2801 sta_cnt++;
2802 }
2803 }
2804lim_assoc_sta_end:
2805 /*
2806 * Call hdd callback with sap event to send the list of
2807 * associated stations from PE
2808 */
2809 if (sap_event_cb != NULL) {
2810 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
2811 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302812 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002813 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
2814 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
2815 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2816 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
2817 }
2818}
2819
2820/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002821 * __lim_counter_measures()
2822 *
2823 * FUNCTION:
2824 * This function is called to "implement" MIC counter measure
2825 * and is *temporary* only
2826 *
2827 * LOGIC: on AP, disassoc all STA associated thru TKIP,
2828 * we don't do the proper STA disassoc sequence since the
2829 * BSS will be stoped anyway
2830 *
2831 ***ASSUMPTIONS:
2832 *
2833 ***NOTE:
2834 *
2835 * @param pMac Pointer to Global MAC structure
2836 * @return None
2837 */
2838
2839static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
2840{
2841 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002842
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002843 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002844 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
2845 mac, psessionEntry, false);
2846};
2847
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002848static void
2849__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2850{
2851 tSirSmeStopBssReq stopBssReq;
2852 tSirRetStatus status;
2853 tLimSmeStates prevState;
2854 tpPESession psessionEntry;
2855 uint8_t smesessionId;
2856 uint8_t sessionId;
2857 uint16_t smetransactionId;
2858 uint8_t i = 0;
2859 tpDphHashNode pStaDs = NULL;
2860
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302861 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002862 smesessionId = stopBssReq.sessionId;
2863 smetransactionId = stopBssReq.transactionId;
2864
2865 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002866 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002867 /* Send Stop BSS response to host */
2868 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2869 eSIR_SME_INVALID_PARAMETERS, smesessionId,
2870 smetransactionId);
2871 return;
2872 }
2873
2874 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08002875 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002876 &sessionId);
2877 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002878 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002879 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2880 eSIR_SME_INVALID_PARAMETERS, smesessionId,
2881 smetransactionId);
2882 return;
2883 }
2884#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2885 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
2886 0, 0);
2887#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2888
2889 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
2890 LIM_IS_STA_ROLE(psessionEntry)) {
2891 /**
2892 * Should not have received STOP_BSS_REQ in states
2893 * other than 'normal' state or on STA in Infrastructure
2894 * mode. Log error and return response to host.
2895 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002896 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002897 psessionEntry->limSmeState,
2898 GET_LIM_SYSTEM_ROLE(psessionEntry));
2899 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
2900 /* / Send Stop BSS response to host */
2901 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2902 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
2903 smetransactionId);
2904 return;
2905 }
2906
2907 if (LIM_IS_AP_ROLE(psessionEntry))
2908 lim_wpspbc_close(pMac, psessionEntry);
2909
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002910 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002911 stopBssReq.reasonCode);
2912
2913 prevState = psessionEntry->limSmeState;
2914
2915 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
2916 MTRACE(mac_trace
2917 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
2918 psessionEntry->limSmeState));
2919
2920 /* Update SME session Id and Transaction Id */
2921 psessionEntry->smeSessionId = smesessionId;
2922 psessionEntry->transactionId = smetransactionId;
2923
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002924 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
2925 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
2926 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002927 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002928
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
2930 /* Send disassoc all stations associated thru TKIP */
2931 __lim_counter_measures(pMac, psessionEntry);
2932 else
2933 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002934 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
2935 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002936 }
2937
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002938 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
2939 /* Free the buffer allocated in START_BSS_REQ */
2940 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
2941 psessionEntry->addIeParams.probeRespDataLen = 0;
2942 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002943
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002944 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
2945 psessionEntry->addIeParams.assocRespDataLen = 0;
2946 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002947
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002948 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
2949 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
2950 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002951
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002952 /*
2953 * lim_del_bss is also called as part of coalescing,
2954 * when we send DEL BSS followed by Add Bss msg.
2955 */
2956 pMac->lim.gLimIbssCoalescingHappened = false;
2957 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002958 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
2959 pStaDs =
2960 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
2961 if (NULL == pStaDs)
2962 continue;
2963 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
2964 if (eSIR_SUCCESS == status) {
2965 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
2966 pStaDs->assocId, psessionEntry);
2967 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
2968 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002969 pe_err("lim_del_sta failed with Status: %d", status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302970 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002971 }
2972 }
2973 /* send a delBss to HAL and wait for a response */
2974 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
2975
2976 if (status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002977 pe_err("delBss failed for bss %d", psessionEntry->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002978 psessionEntry->limSmeState = prevState;
2979
2980 MTRACE(mac_trace
2981 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
2982 psessionEntry->limSmeState));
2983
2984 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2985 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
2986 smetransactionId);
2987 }
2988}
2989
2990/**
2991 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
2992 * @pMac: Global MAC context
2993 * @pMsg: Message from SME
2994 *
2995 * Wrapper for the function __lim_handle_sme_stop_bss_request
2996 * This message will be defered until softmac come out of
2997 * scan mode. Message should be handled even if we have
2998 * detected radar in the current operating channel.
2999 *
3000 * Return: true - If we consumed the buffer
3001 * false - If have defered the message.
3002 */
3003
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003004static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3005 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003006{
3007 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3008 /**
3009 * If message defered, buffer is not consumed yet.
3010 * So return false
3011 */
3012 return false;
3013 }
3014 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3015 return true;
3016} /*** end __lim_process_sme_stop_bss_req() ***/
3017
3018void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3019 uint32_t body, tpPESession psessionEntry)
3020{
3021
3022 (void)body;
3023 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3024 lim_ibss_delete(pMac, psessionEntry);
3025 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3026 lim_delete_pre_auth_list(pMac);
3027 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3028 psessionEntry->smeSessionId,
3029 psessionEntry->transactionId);
3030 return;
3031}
3032
3033/**
3034 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3035 *
3036 * @mac_ctx: pointer to mac context
3037 * @msg_type: message type
3038 * @msg_buf: pointer to the SME message buffer
3039 *
3040 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3041 * in BTAMP AP.
3042 *
3043 * Return: None
3044 */
3045
3046void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3047 uint32_t *msg_buf)
3048{
3049 tSirSmeAssocCnf assoc_cnf;
3050 tpDphHashNode sta_ds = NULL;
3051 tpPESession session_entry = NULL;
3052 uint8_t session_id;
3053 tpSirAssocReq assoc_req;
3054
3055 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003056 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003057 goto end;
3058 }
3059
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303060 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003061 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003062 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003063 goto end;
3064 }
3065
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003066 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003067 &session_id);
3068 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003069 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003070 goto end;
3071 }
3072
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003073 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003074 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3075 (session_entry->limSmeState !=
3076 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003077 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003078 msg_type, session_entry->limSmeState,
3079 GET_LIM_SYSTEM_ROLE(session_entry));
3080 goto end;
3081 }
3082 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3083 &session_entry->dph.dphHashTable);
3084 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003085 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003086 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303087 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003088
3089 /*
3090 * send a DISASSOC_IND message to WSM to make sure
3091 * the state in WSM and LIM is the same
3092 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003093 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003094 eSIR_SME_STA_NOT_ASSOCIATED,
3095 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3096 session_entry->smeSessionId,
3097 session_entry->transactionId,
3098 session_entry);
3099 goto end;
3100 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303101 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003102 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303103 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003104 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003105 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303106 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003107 goto end;
3108 }
3109
3110 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3111 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3112 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3113 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3114 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003115 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3116 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003117 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303118 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003119 goto end;
3120 }
3121 /*
3122 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3123 * has been received
3124 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003125 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003126 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3127 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3128
3129 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3130 /*
3131 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3132 * when it had received Assoc Request frame. Now, PE just needs
3133 * to send association rsp frame to the requesting BTAMP-STA.
3134 */
3135 sta_ds->mlmStaContext.mlmState =
3136 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003137 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003138 sta_ds->assocId);
3139 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3140 sta_ds->assocId, sta_ds->staAddr,
3141 sta_ds->mlmStaContext.subType, sta_ds,
3142 session_entry);
3143 goto end;
3144 } else {
3145 /*
3146 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3147 * to be associated since the HAL sta entry is created for
3148 * denied STA we need to remove this HAL entry.
3149 * So to do that set updateContext to 1
3150 */
3151 if (!sta_ds->mlmStaContext.updateContext)
3152 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003153 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003154 assoc_cnf.statusCode, sta_ds->assocId);
3155 lim_reject_association(mac_ctx, sta_ds->staAddr,
3156 sta_ds->mlmStaContext.subType,
3157 true, sta_ds->mlmStaContext.authType,
3158 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003159 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003160 session_entry);
3161 }
3162end:
3163 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3164 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3165 assoc_req = (tpSirAssocReq)
3166 session_entry->parsedAssocReq[sta_ds->assocId];
3167 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303168 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003169 assoc_req->assocReqFrame = NULL;
3170 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303171 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003172 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3173 }
3174}
3175
3176static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3177{
3178 tpDphHashNode pStaDs;
3179 tSirMacAddr peerMac;
3180 tpSirAddtsReq pSirAddts;
3181 uint32_t timeout;
3182 tpPESession psessionEntry;
3183 uint8_t sessionId; /* PE sessionId */
3184 uint8_t smesessionId;
3185 uint16_t smetransactionId;
3186
3187 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003188 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003189 return;
3190 }
3191
3192 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3193 &smetransactionId);
3194
3195 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3196
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003197 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3198 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003199 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003200 pe_err("Session Does not exist for given bssId");
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303201 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3202 NULL, pSirAddts->req.tspec,
3203 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003204 return;
3205 }
3206#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3207 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3208 0);
3209#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3210
3211 /* if sta
3212 * - verify assoc state
3213 * - send addts request to ap
3214 * - wait for addts response from ap
3215 * if ap, just ignore with error log
3216 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003217 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3218 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3219 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003220
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003221 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003222 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303223 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003224 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003225
3226 pStaDs =
3227 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3228 &psessionEntry->dph.dphHashTable);
3229
3230 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003231 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303232 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003233 }
3234
3235 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3236 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003237 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303238 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003239 }
3240
3241 pSirAddts->req.wsmTspecPresent = 0;
3242 pSirAddts->req.wmeTspecPresent = 0;
3243 pSirAddts->req.lleTspecPresent = 0;
3244
3245 if ((pStaDs->wsmEnabled) &&
3246 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3247 SIR_MAC_ACCESSPOLICY_EDCA))
3248 pSirAddts->req.wsmTspecPresent = 1;
3249 else if (pStaDs->wmeEnabled)
3250 pSirAddts->req.wmeTspecPresent = 1;
3251 else if (pStaDs->lleEnabled)
3252 pSirAddts->req.lleTspecPresent = 1;
3253 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003254 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303255 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003256 }
3257
3258 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3259 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003260 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003261 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303262 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003263 }
3264
3265 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003266 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003267 pMac->lim.gLimAddtsReq.req.dialogToken,
3268 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3269 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3270 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303271 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003272 }
3273
3274 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3275
3276 /* save the addts request */
3277 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303278 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3280
3281 /* ship out the message now */
3282 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3283 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303284 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003285 /* start a timer to wait for the response */
3286 if (pSirAddts->timeout)
3287 timeout = pSirAddts->timeout;
3288 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3289 eSIR_SUCCESS) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303290 pe_debug("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003291 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303292 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003293 }
3294
3295 timeout = SYS_MS_TO_TICKS(timeout);
3296 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3297 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003298 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303299 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003300 }
3301 pMac->lim.gLimAddtsRspTimerCount++;
3302 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3303 pMac->lim.gLimAddtsRspTimerCount) !=
3304 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003305 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303306 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003307 }
3308 MTRACE(mac_trace
3309 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3310 eLIM_ADDTS_RSP_TIMER));
3311
3312 /* add the sessionId to the timer object */
3313 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3314 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3315 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003316 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303317 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003318 }
3319 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303320
3321send_failure_addts_rsp:
3322 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3323 psessionEntry, pSirAddts->req.tspec,
3324 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003325}
3326
3327static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3328{
3329 tSirMacAddr peerMacAddr;
3330 uint8_t ac;
3331 tSirMacTSInfo *pTsinfo;
3332 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3333 tpDphHashNode pStaDs = NULL;
3334 tpPESession psessionEntry;
3335 uint8_t sessionId;
3336 uint32_t status = eSIR_SUCCESS;
3337 uint8_t smesessionId;
3338 uint16_t smetransactionId;
3339
3340 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3341 &smetransactionId);
3342
3343 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003344 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003345 &sessionId);
3346 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003347 pe_err("Session Does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003348 status = eSIR_FAILURE;
3349 goto end;
3350 }
3351#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3352 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3353 0);
3354#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3355
3356 if (eSIR_SUCCESS !=
3357 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003358 pe_err("lim_validate_delts_req failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003359 status = eSIR_FAILURE;
3360 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3361 smesessionId, smetransactionId);
3362 return;
3363 }
3364
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003365 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3366 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003367 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3368
3369 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3370 pDeltsReq->req.wmeTspecPresent,
3371 &pDeltsReq->req.tsinfo,
3372 &pDeltsReq->req.tspec, psessionEntry);
3373
3374 pTsinfo =
3375 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3376 tsinfo : &pDeltsReq->req.tsinfo;
3377
3378 /* We've successfully send DELTS frame to AP. Update the
3379 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3380 * is no longer trigger enabled or delivery enabled
3381 */
3382 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3383 pTsinfo, CLEAR_UAPSD_MASK);
3384
3385 /* We're deleting the TSPEC, so this particular AC is no longer
3386 * admitted. PE needs to downgrade the EDCA
3387 * parameters(for the AC for which TS is being deleted) to the
3388 * next best AC for which ACM is not enabled, and send the
3389 * updated values to HAL.
3390 */
3391 ac = upToAc(pTsinfo->traffic.userPrio);
3392
3393 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3394 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3395 ~(1 << ac);
3396 } else if (pTsinfo->traffic.direction ==
3397 SIR_MAC_DIRECTION_DNLINK) {
3398 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3399 ~(1 << ac);
3400 } else if (pTsinfo->traffic.direction ==
3401 SIR_MAC_DIRECTION_BIDIR) {
3402 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3403 ~(1 << ac);
3404 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3405 ~(1 << ac);
3406 }
3407
3408 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3409 psessionEntry);
3410
3411 pStaDs =
3412 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3413 &psessionEntry->dph.dphHashTable);
3414 if (pStaDs != NULL) {
3415 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003416 pStaDs->bssId, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003417 status = eSIR_SUCCESS;
3418 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003419 pe_err("Self entry missing in Hash Table");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003420 status = eSIR_FAILURE;
3421 }
3422#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003423 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003424#endif
3425
3426 /* send an sme response back */
3427end:
3428 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3429 smesessionId, smetransactionId);
3430}
3431
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303432void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003433{
3434 /* fetch the sessionEntry based on the sessionId */
3435 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003436
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003437 psessionEntry = pe_find_session_by_session_id(pMac,
3438 pMac->lim.limTimers.gLimAddtsRspTimer.
3439 sessionId);
3440 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003441 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003442 return;
3443 }
3444
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003445 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003446 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003447 GET_LIM_SYSTEM_ROLE(psessionEntry));
3448 pMac->lim.gLimAddtsSent = false;
3449 return;
3450 }
3451
3452 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003453 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003454 return;
3455 }
3456
3457 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003458 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003459 pMac->lim.gLimAddtsRspTimerCount);
3460 return;
3461 }
3462 /* this a real response timeout */
3463 pMac->lim.gLimAddtsSent = false;
3464 pMac->lim.gLimAddtsRspTimerCount++;
3465
3466 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3467 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3468 psessionEntry->smeSessionId,
3469 psessionEntry->transactionId);
3470}
3471
3472/**
3473 * __lim_process_sme_get_statistics_request()
3474 *
3475 ***FUNCTION:
3476 *
3477 *
3478 ***NOTE:
3479 *
3480 * @param pMac Pointer to Global MAC structure
3481 * @param *pMsgBuf A pointer to the SME message buffer
3482 * @return None
3483 */
3484static void
3485__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3486{
3487 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003488 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003489
3490 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3491
3492 msgQ.type = WMA_GET_STATISTICS_REQ;
3493
3494 msgQ.reserved = 0;
3495 msgQ.bodyptr = pMsgBuf;
3496 msgQ.bodyval = 0;
3497 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3498
3499 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303500 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003501 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003502 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003503 return;
3504 }
3505
3506 return;
3507}
3508
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003509#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003510/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003511 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003512 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003513 * @pMac: Pointer to Global MAC structure
3514 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003515 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003516 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003517 */
3518static void
3519__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3520{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003521 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003522
3523 msgQ.type = WMA_TSM_STATS_REQ;
3524 msgQ.reserved = 0;
3525 msgQ.bodyptr = pMsgBuf;
3526 msgQ.bodyval = 0;
3527 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3528
3529 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303530 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003531 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003532 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003533 return;
3534 }
3535}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003536#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003537
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08003538static void lim_process_sme_set_addba_accept(tpAniSirGlobal mac_ctx,
3539 struct sme_addba_accept *msg)
3540{
3541 if (!msg) {
3542 pe_err("Msg Buffer is NULL");
3543 return;
3544 }
3545 if (!msg->addba_accept)
3546 mac_ctx->reject_addba_req = 1;
3547 else
3548 mac_ctx->reject_addba_req = 0;
3549}
3550
Arif Hussaineb8ba362018-03-07 19:15:13 -08003551static void lim_process_sme_update_edca_params(tpAniSirGlobal mac_ctx,
3552 uint32_t sme_session_id)
3553{
3554 tpPESession pe_session;
3555 tpDphHashNode sta_ds_ptr;
3556
3557 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3558 if (!pe_session) {
3559 pe_err("Session does not exist: sme_id %d", sme_session_id);
3560 return;
3561 }
3562 pe_session->gLimEdcaParamsActive[EDCA_AC_BE].no_ack =
3563 mac_ctx->no_ack_policy_cfg[EDCA_AC_BE];
3564 pe_session->gLimEdcaParamsActive[EDCA_AC_BK].no_ack =
3565 mac_ctx->no_ack_policy_cfg[EDCA_AC_BK];
3566 pe_session->gLimEdcaParamsActive[EDCA_AC_VI].no_ack =
3567 mac_ctx->no_ack_policy_cfg[EDCA_AC_VI];
3568 pe_session->gLimEdcaParamsActive[EDCA_AC_VO].no_ack =
3569 mac_ctx->no_ack_policy_cfg[EDCA_AC_VO];
3570 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3571 &pe_session->dph.dphHashTable);
3572 if (sta_ds_ptr)
3573 lim_send_edca_params(mac_ctx,
3574 pe_session->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003575 sta_ds_ptr->bssId, false);
Arif Hussaineb8ba362018-03-07 19:15:13 -08003576 else
3577 pe_err("Self entry missing in Hash Table");
3578}
3579
Naveen Rawat8029a402017-06-01 10:54:19 -07003580static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3581 struct update_config *msg)
3582{
3583 tpPESession pe_session;
3584
3585 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3586 if (msg == NULL) {
3587 pe_err("Buffer is Pointing to NULL");
3588 return;
3589 }
3590
3591 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3592 msg->sme_session_id);
3593 if (pe_session == NULL) {
3594 pe_warn("Session does not exist for given BSSID");
3595 return;
3596 }
3597
3598 switch (msg->capab) {
3599 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3600 pe_session->htConfig.ht_rx_ldpc = msg->value;
3601 break;
3602 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3603 pe_session->htConfig.ht_tx_stbc = msg->value;
3604 break;
3605 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3606 pe_session->htConfig.ht_rx_stbc = msg->value;
3607 break;
3608 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3609 pe_session->htConfig.ht_sgi20 = msg->value;
3610 break;
3611 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3612 pe_session->htConfig.ht_sgi40 = msg->value;
3613 break;
3614 }
3615
3616 if (LIM_IS_AP_ROLE(pe_session)) {
3617 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3618 lim_send_beacon_ind(mac_ctx, pe_session);
3619 }
3620}
3621
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003622void
3623lim_send_vdev_restart(tpAniSirGlobal pMac,
3624 tpPESession psessionEntry, uint8_t sessionId)
3625{
3626 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003627 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003628 tSirRetStatus retCode = eSIR_SUCCESS;
3629
3630 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003631 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003632 return;
3633 }
3634
3635 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303636 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003637 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003638 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003639 return;
3640 }
3641
3642 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3643 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003644 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003645
3646 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3647 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3648 msgQ.bodyval = 0;
3649
3650 retCode = wma_post_ctrl_msg(pMac, &msgQ);
3651 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003652 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303653 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003654 }
3655}
3656
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303657/**
3658 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3659 * @mac_ctx: Pointer to Global MAC structure
3660 * @msg_buf: Pointer to SME message buffer
3661 *
3662 * Return: None
3663 */
3664static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3665 uint32_t *msg_buf)
3666{
3667 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003668 struct scheduler_msg wma_msg = {0};
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303669 tSirRetStatus status;
3670 tSirRoamOffloadScanReq *req_buffer;
3671 uint16_t local_ie_len;
3672 uint8_t *local_ie_buf;
3673
3674 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3675 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3676 req_buffer->sessionId);
3677
3678 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3679 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003680 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303681 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303682 return;
3683 }
3684
3685 local_ie_len = req_buffer->assoc_ie.length;
3686 /* Update ext cap IE if present */
3687 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003688 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3689 local_ie_buf, &local_ie_len)) {
3690 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003691 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3692 req_buffer->assoc_ie.length = local_ie_len;
3693 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3694 local_ie_buf, local_ie_len);
3695 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303696 }
3697 qdf_mem_free(local_ie_buf);
3698
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303699 if (pe_session)
3700 lim_update_fils_rik(pe_session, req_buffer);
3701
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303702 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3703 wma_msg.bodyptr = req_buffer;
3704
3705 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
3706 if (eSIR_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003707 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303708 qdf_mem_free(req_buffer);
3709 }
3710}
3711
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303712/*
3713 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3714 * @mac_ctx: Pointer to global mac context
3715 * @session: Pointer to PE session
3716 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3717 * 1 - Disable broadcast SSID
3718 *
3719 * Return: None
3720 */
3721static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3722 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003723{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003724 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003725 session->ssidHidden, ssid_hidden);
3726
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003727 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303728 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003729 } else {
3730 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05303731 return;
3732 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003733
3734 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303735 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003736
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003737 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303738}
3739
3740/**
3741 * __lim_process_sme_session_update - process SME session update msg
3742 *
3743 * @mac_ctx: Pointer to global mac context
3744 * @msg_buf: Pointer to the received message buffer
3745 *
3746 * Return: None
3747 */
3748static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
3749 uint32_t *msg_buf)
3750{
3751 struct sir_update_session_param *msg;
3752 tpPESession session;
3753
3754 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003755 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303756 return;
3757 }
3758
3759 msg = (struct sir_update_session_param *) msg_buf;
3760
3761 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
3762 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003763 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303764 msg->session_id);
3765 return;
3766 }
3767
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003768 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303769 msg->param_type, msg->param_val);
3770 switch (msg->param_type) {
3771 case SIR_PARAM_SSID_HIDDEN:
3772 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
3773 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303774 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
3775 session->ignore_assoc_disallowed = msg->param_val;
3776 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303777 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003778 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303779 break;
3780 }
3781}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003782
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003783/*
3784 Update the beacon Interval dynamically if beaconInterval is different in MCC
3785 */
3786static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3787{
3788 tpSirChangeBIParams pChangeBIParams;
3789 tpPESession psessionEntry;
3790 uint8_t sessionId = 0;
3791 tUpdateBeaconParams beaconParams;
3792
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003793 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003794
3795 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003796 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003797 return;
3798 }
3799
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303800 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003801 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
3802
3803 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08003804 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003805 &sessionId);
3806 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003807 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003808 return;
3809 }
3810
3811 /*Update sessionEntry Beacon Interval */
3812 if (psessionEntry->beaconParams.beaconInterval !=
3813 pChangeBIParams->beaconInterval) {
3814 psessionEntry->beaconParams.beaconInterval =
3815 pChangeBIParams->beaconInterval;
3816 }
3817
3818 /*Update sch beaconInterval */
3819 if (pMac->sch.schObject.gSchBeaconInterval !=
3820 pChangeBIParams->beaconInterval) {
3821 pMac->sch.schObject.gSchBeaconInterval =
3822 pChangeBIParams->beaconInterval;
3823
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003824 pe_debug("LIM send update BeaconInterval Indication: %d",
3825 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003826
3827 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
3828 /* Update beacon */
3829 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3830
3831 beaconParams.bssIdx = psessionEntry->bssIdx;
3832 /* Set change in beacon Interval */
3833 beaconParams.beaconInterval =
3834 pChangeBIParams->beaconInterval;
3835 beaconParams.paramChangeBitmap =
3836 PARAM_BCN_INTERVAL_CHANGED;
3837 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
3838 }
3839 }
3840
3841 return;
3842} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
3843
3844#ifdef QCA_HT_2040_COEX
3845static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
3846 uint32_t *pMsgBuf)
3847{
3848 tpSirSetHT2040Mode pSetHT2040Mode;
3849 tpPESession psessionEntry;
3850 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003851 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003852 tUpdateVHTOpMode *pHtOpMode = NULL;
3853 uint16_t staId = 0;
3854 tpDphHashNode pStaDs = NULL;
3855
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003856 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003857 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003858 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003859 return;
3860 }
3861
3862 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
3863
3864 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08003865 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003866 &sessionId);
3867 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003868 pe_debug("Session does not exist for given BSSID");
3869 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003870 return;
3871 }
3872
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003873 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003874 pSetHT2040Mode->cbMode);
3875 /*Update sessionEntry HT related fields */
3876 switch (pSetHT2040Mode->cbMode) {
3877 case PHY_SINGLE_CHANNEL_CENTERED:
3878 psessionEntry->htSecondaryChannelOffset =
3879 PHY_SINGLE_CHANNEL_CENTERED;
3880 psessionEntry->htRecommendedTxWidthSet = 0;
3881 if (pSetHT2040Mode->obssEnabled)
3882 psessionEntry->htSupportedChannelWidthSet
3883 = eHT_CHANNEL_WIDTH_40MHZ;
3884 else
3885 psessionEntry->htSupportedChannelWidthSet
3886 = eHT_CHANNEL_WIDTH_20MHZ;
3887 break;
3888 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
3889 psessionEntry->htSecondaryChannelOffset =
3890 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3891 psessionEntry->htRecommendedTxWidthSet = 1;
3892 break;
3893 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
3894 psessionEntry->htSecondaryChannelOffset =
3895 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3896 psessionEntry->htRecommendedTxWidthSet = 1;
3897 break;
3898 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003899 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003900 return;
3901 }
3902
3903 /* Update beacon */
3904 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3905 lim_send_beacon_ind(pMac, psessionEntry);
3906
3907 /* update OP Mode for each associated peer */
3908 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
3909 pStaDs = dph_get_hash_entry(pMac, staId,
3910 &psessionEntry->dph.dphHashTable);
3911 if (NULL == pStaDs)
3912 continue;
3913
3914 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303915 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003916 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003917 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003918 return;
3919 }
3920 pHtOpMode->opMode =
3921 (psessionEntry->htSecondaryChannelOffset ==
3922 PHY_SINGLE_CHANNEL_CENTERED) ?
3923 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
3924 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303925 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003926 sizeof(tSirMacAddr));
3927 pHtOpMode->smesessionId = sessionId;
3928
3929 msg.type = WMA_UPDATE_OP_MODE;
3930 msg.reserved = 0;
3931 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003932 if (!QDF_IS_STATUS_SUCCESS
3933 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
3934 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303935 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003936 return;
3937 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003938 pe_debug("Notifed FW about OP mode: %d for staId=%d",
3939 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003940
3941 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003942 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003943 }
3944
3945 return;
3946}
3947#endif
3948
3949/* -------------------------------------------------------------------- */
3950/**
3951 * __lim_process_report_message
3952 *
3953 * FUNCTION: Processes the next received Radio Resource Management message
3954 *
3955 * LOGIC:
3956 *
3957 * ASSUMPTIONS:
3958 *
3959 * NOTE:
3960 *
3961 * @param None
3962 * @return None
3963 */
3964
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003965static void __lim_process_report_message(tpAniSirGlobal pMac,
3966 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003967{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003968 switch (pMsg->type) {
3969 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
3970 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
3971 break;
3972 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003973 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08003974 break;
3975 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003976 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003977 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003978}
3979
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003980/* -------------------------------------------------------------------- */
3981/**
3982 * lim_send_set_max_tx_power_req
3983 *
3984 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
3985 *
3986 * LOGIC:
3987 *
3988 * ASSUMPTIONS:
3989 *
3990 * NOTE:
3991 *
3992 * @param txPower txPower to be set.
3993 * @param pSessionEntry session entry.
3994 * @return None
3995 */
3996tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07003997lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003998 tpPESession pSessionEntry)
3999{
4000 tpMaxTxPowerParams pMaxTxParams = NULL;
4001 tSirRetStatus retCode = eSIR_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004002 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004003
4004 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004005 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004006 return eSIR_FAILURE;
4007 }
4008
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304009 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004010 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004011 pe_err("Unable to allocate memory for pMaxTxParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004012 return eSIR_MEM_ALLOC_FAILED;
4013
4014 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004015 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304016 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304017 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304018 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004019 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304020 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004021
4022 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4023 msgQ.bodyptr = pMaxTxParams;
4024 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004025 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004026 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4027 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4028 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004029 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304030 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004031 }
4032 return retCode;
4033}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004034
4035/**
4036 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4037 *
4038 * @mac_ctx: Pointer to Global MAC structure
4039 * @msg_buf: pointer to the SME message buffer
4040 *
4041 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4042 * from SME. It Register this information within PE.
4043 *
4044 * Return: None
4045 */
4046static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4047 uint32_t *msg_buf)
4048{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304049 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004050 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4051 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4052 struct mgmt_frm_reg_info *next = NULL;
4053 bool match = false;
4054
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004055 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004056 sme_req->registerFrame, sme_req->frameType,
4057 sme_req->matchLen);
4058 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304059 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304060 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4061 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304062 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004063
4064 while (lim_mgmt_regn != NULL) {
4065 if (lim_mgmt_regn->frameType != sme_req->frameType)
4066 goto skip_match;
4067 if (sme_req->matchLen) {
4068 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304069 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004070 sme_req->matchData,
4071 lim_mgmt_regn->matchLen))) {
4072 /* found match! */
4073 match = true;
4074 break;
4075 }
4076 } else {
4077 /* found match! */
4078 match = true;
4079 break;
4080 }
4081skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304082 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304083 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004084 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304085 (qdf_list_node_t *)lim_mgmt_regn,
4086 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304087 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004088 lim_mgmt_regn = next;
4089 next = NULL;
4090 }
4091 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304092 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004093 if (QDF_STATUS_SUCCESS ==
4094 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004095 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004096 (qdf_list_node_t *)lim_mgmt_regn))
4097 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304098 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004099 }
4100
4101 if (sme_req->registerFrame) {
4102 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304103 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004104 sme_req->matchLen);
4105 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004106 lim_mgmt_regn->frameType = sme_req->frameType;
4107 lim_mgmt_regn->matchLen = sme_req->matchLen;
4108 lim_mgmt_regn->sessionId = sme_req->sessionId;
4109 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304110 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004111 sme_req->matchData,
4112 sme_req->matchLen);
4113 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304114 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004115 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304116 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004117 gLimMgmtFrameRegistratinQueue,
4118 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304119 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004120 &mac_ctx->lim.lim_frame_register_lock);
4121 }
4122 }
4123 return;
4124}
4125
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004126static void
4127__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4128{
4129 tpSirResetAPCapsChange pResetCapsChange;
4130 tpPESession psessionEntry;
4131 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004132
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004133 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004134 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004135 return;
4136 }
4137
4138 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4139 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004140 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4141 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004142 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004143 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004144 return;
4145 }
4146
4147 psessionEntry->limSentCapsChangeNtf = false;
4148 return;
4149}
4150
4151/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304152 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4153 * indication callback in PE.
4154 * @mac_ptr: Mac pointer
4155 * @msg_buf: Msg pointer containing the callback
4156 *
4157 * This function is used save the Management frame
4158 * indication callback in PE.
4159 *
4160 * Return: None
4161 */
4162static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4163 uint32_t *msg_buf)
4164{
4165 struct sir_sme_mgmt_frame_cb_req *sme_req =
4166 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4167
4168 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004169 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304170 return;
4171 }
4172 if (sme_req->callback)
4173 mac_ctx->mgmt_frame_ind_cb =
4174 (sir_mgmt_frame_ind_callback)sme_req->callback;
4175 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004176 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304177}
4178
4179/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304180 *__lim_process_send_disassoc_frame: function processes disassoc frame
4181 * @mac_ctx: pointer to mac context
4182 * @msg_buf: message buffer
4183 *
4184 * function processes disassoc request received from SME
4185 *
4186 * return: none
4187 */
4188static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4189 uint32_t *msg_buf)
4190{
4191 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4192 tSirRetStatus status;
4193 tpPESession session_entry = NULL;
4194 uint8_t sme_session_id;
4195 uint16_t sme_trans_id;
4196
4197 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004198 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304199 return;
4200 }
4201
4202 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4203 &sme_trans_id);
4204
4205 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4206 &sme_send_disassoc_frame_req,
4207 (uint8_t *)msg_buf);
4208
4209 if ((eSIR_FAILURE == status) ||
4210 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4211 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004212 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304213 return;
4214 }
4215
4216 session_entry = pe_find_session_by_sme_session_id(
4217 mac_ctx, sme_session_id);
4218 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004219 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304220 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4221 return;
4222 }
4223
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004224 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 +05304225 sme_send_disassoc_frame_req.msg_type,
4226 sme_send_disassoc_frame_req.length,
4227 sme_send_disassoc_frame_req.session_id,
4228 sme_send_disassoc_frame_req.trans_id,
4229 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4230 sme_send_disassoc_frame_req.reason,
4231 sme_send_disassoc_frame_req.wait_for_ack);
4232
4233 lim_send_disassoc_mgmt_frame(mac_ctx,
4234 sme_send_disassoc_frame_req.reason,
4235 sme_send_disassoc_frame_req.peer_mac,
4236 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4237}
4238
4239/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004240 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4241 * @mac_ctx: Pointer to Global MAC structure
4242 * @pdev_id: pdev id to set the IE.
4243 * @nss: Nss values to prepare the HT IE.
4244 *
4245 * Prepares the HT IE with self capabilities for different
4246 * Nss values and sends the set HT IE req to FW.
4247 *
4248 * Return: None
4249 */
4250static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4251 uint8_t nss)
4252{
4253 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004254 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004255 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004256 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004257 tHtCaps *p_ht_cap;
4258 int i;
4259
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004260 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004261 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4262 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004263 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004264 return;
4265 }
4266 ie_params->nss = i;
4267 ie_params->pdev_id = pdev_id;
4268 ie_params->ie_type = DOT11_HT_IE;
4269 /* 2 for IE len and EID */
4270 ie_params->ie_len = 2 + sizeof(tHtCaps);
4271 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4272 if (NULL == ie_params->ie_ptr) {
4273 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004274 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004275 return;
4276 }
4277 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4278 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4279 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4280 ie_params->ie_len);
4281
4282 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004283 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4284 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004285 if (NULL == p_ie) {
4286 qdf_mem_free(ie_params->ie_ptr);
4287 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004288 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004289 return;
4290 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004291 p_ht_cap = (tHtCaps *)&p_ie[2];
4292 p_ht_cap->supportedMCSSet[1] = 0;
4293 p_ht_cap->txSTBC = 0;
4294 }
4295
4296 msg.type = WMA_SET_PDEV_IE_REQ;
4297 msg.bodyptr = ie_params;
4298 msg.bodyval = 0;
4299
4300 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4301 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004302 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004303 qdf_mem_free(ie_params->ie_ptr);
4304 qdf_mem_free(ie_params);
4305 return;
4306 }
4307 }
4308}
4309
4310/**
4311 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4312 * @mac_ctx: Pointer to Global MAC structure
4313 * @pdev_id: pdev id to set the IE.
4314 * @nss: Nss values to prepare the VHT IE.
4315 *
4316 * Prepares the VHT IE with self capabilities for different
4317 * Nss values and sends the set VHT IE req to FW.
4318 *
4319 * Return: None
4320 */
4321static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4322 uint8_t nss)
4323{
4324 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004325 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004326 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004327 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004328 tSirMacVHTCapabilityInfo *vht_cap;
4329 int i;
4330 tSirVhtMcsInfo *vht_mcs;
4331
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004332 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004333 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4334 if (NULL == 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->nss = i;
4339 ie_params->pdev_id = pdev_id;
4340 ie_params->ie_type = DOT11_VHT_IE;
4341 /* 2 for IE len and EID */
4342 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4343 sizeof(tSirVhtMcsInfo);
4344 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4345 if (NULL == ie_params->ie_ptr) {
4346 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004347 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004348 return;
4349 }
4350 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4351 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4352 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4353 ie_params->ie_len);
4354
4355 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004356 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4357 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004358 if (NULL == p_ie) {
4359 qdf_mem_free(ie_params->ie_ptr);
4360 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004361 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004362 return;
4363 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004364 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4365 vht_cap->txSTBC = 0;
4366 vht_mcs =
4367 (tSirVhtMcsInfo *)&p_ie[2 +
4368 sizeof(tSirMacVHTCapabilityInfo)];
4369 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4370 vht_mcs->rxHighest =
4371 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4372 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4373 vht_mcs->txHighest =
4374 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4375 }
4376 msg.type = WMA_SET_PDEV_IE_REQ;
4377 msg.bodyptr = ie_params;
4378 msg.bodyval = 0;
4379
4380 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4381 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004382 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004383 qdf_mem_free(ie_params->ie_ptr);
4384 qdf_mem_free(ie_params);
4385 return;
4386 }
4387 }
4388}
4389
4390/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004391 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4392 * @mac_ctx: Pointer to Global MAC structure
4393 * @msg_buf: Pointer to the SME message buffer
4394 *
4395 * This function is called by limProcessMessageQueue(). This function sets the
4396 * VDEV IEs to the FW.
4397 *
4398 * Return: None
4399 */
4400static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4401 uint32_t *msg_buf)
4402{
4403 struct sir_set_vdev_ies_per_band *p_msg =
4404 (struct sir_set_vdev_ies_per_band *)msg_buf;
4405
4406 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004407 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004408 return;
4409 }
4410
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004411 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004412 p_msg->vdev_id);
4413 /* intentionally using NULL here so that self capabilty are sent */
4414 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4415 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004416 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004417}
4418
4419/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004420 * lim_process_set_pdev_IEs() - process the set pdev IE req
4421 * @mac_ctx: Pointer to Global MAC structure
4422 * @msg_buf: Pointer to the SME message buffer
4423 *
4424 * This function is called by limProcessMessageQueue(). This
4425 * function sets the PDEV IEs to the FW.
4426 *
4427 * Return: None
4428 */
4429static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4430{
4431 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4432
4433 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4434
4435 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004436 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004437 return;
4438 }
4439
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004440 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004441 ht_vht_cfg->nss);
4442 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4443
4444 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4445 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4446 ht_vht_cfg->nss);
4447}
4448
4449/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304450 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4451 *
4452 * access policy
4453 * @mac_ctx: pointer to mac context
4454 * @msg: message buffer
4455 *
4456 * function processes vendor IE and access policy from SME and updates PE
4457 *
4458 * session entry
4459 *
4460 * return: none
4461*/
4462static void lim_process_sme_update_access_policy_vendor_ie(
4463 tpAniSirGlobal mac_ctx,
4464 uint32_t *msg)
4465{
4466 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4467 struct sPESession *pe_session_entry;
4468 uint8_t num_bytes;
4469
4470 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004471 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304472 return;
4473 }
4474 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4475 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4476 update_vendor_ie->sme_session_id);
4477
4478 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004479 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304480 update_vendor_ie->sme_session_id);
4481 return;
4482 }
4483 if (pe_session_entry->access_policy_vendor_ie)
4484 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4485
4486 num_bytes = update_vendor_ie->ie[1] + 2;
4487 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4488
4489 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004490 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304491 return;
4492 }
4493 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4494 &update_vendor_ie->ie[0], num_bytes);
4495
4496 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4497}
4498
4499/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004500 * lim_process_sme_req_messages()
4501 *
4502 ***FUNCTION:
4503 * This function is called by limProcessMessageQueue(). This
4504 * function processes SME request messages from HDD or upper layer
4505 * application.
4506 *
4507 ***LOGIC:
4508 *
4509 ***ASSUMPTIONS:
4510 *
4511 ***NOTE:
4512 *
4513 * @param pMac Pointer to Global MAC structure
4514 * @param msgType Indicates the SME message type
4515 * @param *pMsgBuf A pointer to the SME message buffer
4516 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4517 * false - if pMsgBuf is not to be freed.
4518 */
4519
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004520bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4521 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004522{
4523 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
4524 uint32_t *pMsgBuf = pMsg->bodyptr;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004525
4526 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004527 lim_msg_str(pMsg->type), pMsg->type,
4528 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4529 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004530
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004531 /* If no insert NOA required then execute the code below */
4532
4533 switch (pMsg->type) {
4534 case eWNI_SME_SYS_READY_IND:
4535 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4536 break;
4537
4538 case eWNI_SME_START_BSS_REQ:
4539 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4540 break;
4541
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004542 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4543 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4544 break;
4545 case eWNI_SME_JOIN_REQ:
4546 __lim_process_sme_join_req(pMac, pMsgBuf);
4547 break;
4548
4549 case eWNI_SME_REASSOC_REQ:
4550 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4551 break;
4552
4553 case eWNI_SME_DISASSOC_REQ:
4554 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4555 break;
4556
4557 case eWNI_SME_DISASSOC_CNF:
4558 case eWNI_SME_DEAUTH_CNF:
4559 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4560 break;
4561
4562 case eWNI_SME_DEAUTH_REQ:
4563 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4564 break;
4565
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304566 case eWNI_SME_SEND_DISASSOC_FRAME:
4567 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4568 break;
4569
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004570 case eWNI_SME_SETCONTEXT_REQ:
4571 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4572 break;
4573
4574 case eWNI_SME_STOP_BSS_REQ:
4575 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4576 break;
4577
4578 case eWNI_SME_ASSOC_CNF:
4579 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004580 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004581 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4582 pMsgBuf);
4583 break;
4584
4585 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004586 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004587 __lim_process_sme_addts_req(pMac, pMsgBuf);
4588 break;
4589
4590 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004591 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004592 __lim_process_sme_delts_req(pMac, pMsgBuf);
4593 break;
4594
4595 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004596 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004597 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4598 break;
4599
4600 case eWNI_SME_GET_STATISTICS_REQ:
4601 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4602 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4603 bufConsumed = false;
4604 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004605#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004606 case eWNI_SME_GET_TSM_STATS_REQ:
4607 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4608 bufConsumed = false;
4609 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004610#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004611 case eWNI_SME_GET_ASSOC_STAS_REQ:
4612 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4613 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304614 case eWNI_SME_SESSION_UPDATE_PARAM:
4615 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004616 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304617 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4618 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4619 bufConsumed = false;
4620 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004621 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4622 /* Update the beaconInterval */
4623 __lim_process_sme_change_bi(pMac, pMsgBuf);
4624 break;
4625
4626#ifdef QCA_HT_2040_COEX
4627 case eWNI_SME_SET_HT_2040_MODE:
4628 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4629 break;
4630#endif
4631
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004632 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4633 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4634 __lim_process_report_message(pMac, pMsg);
4635 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004636
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004637 case eWNI_SME_FT_PRE_AUTH_REQ:
4638 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4639 break;
4640 case eWNI_SME_FT_UPDATE_KEY:
4641 lim_process_ft_update_key(pMac, pMsgBuf);
4642 break;
4643
4644 case eWNI_SME_FT_AGGR_QOS_REQ:
4645 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4646 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004647
4648 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4649 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4650 break;
4651#ifdef FEATURE_WLAN_TDLS
4652 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4653 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4654 break;
4655 case eWNI_SME_TDLS_ADD_STA_REQ:
4656 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4657 break;
4658 case eWNI_SME_TDLS_DEL_STA_REQ:
4659 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4660 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004661#endif
4662 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4663 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4664 break;
4665
4666 case eWNI_SME_CHANNEL_CHANGE_REQ:
4667 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4668 break;
4669
4670 case eWNI_SME_START_BEACON_REQ:
4671 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4672 break;
4673
4674 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4675 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4676 break;
4677
4678 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4679 lim_process_update_add_ies(pMac, pMsgBuf);
4680 break;
4681
4682 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4683 lim_process_modify_add_ies(pMac, pMsgBuf);
4684 break;
4685 case eWNI_SME_SET_HW_MODE_REQ:
4686 lim_process_set_hw_mode(pMac, pMsgBuf);
4687 break;
4688 case eWNI_SME_NSS_UPDATE_REQ:
4689 lim_process_nss_update_request(pMac, pMsgBuf);
4690 break;
4691 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4692 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4693 break;
4694 case eWNI_SME_SET_IE_REQ:
4695 lim_process_set_ie_req(pMac, pMsgBuf);
4696 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304697 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4698 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
4699 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304700 case eWNI_SME_EXT_CHANGE_CHANNEL:
4701 lim_process_ext_change_channel(pMac, pMsgBuf);
4702 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08004703 case eWNI_SME_SET_ANTENNA_MODE_REQ:
4704 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
4705 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004706 case eWNI_SME_PDEV_SET_HT_VHT_IE:
4707 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07004708 break;
4709 case eWNI_SME_SET_VDEV_IES_PER_BAND:
4710 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
4711 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304712 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
4713 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
4714 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07004715 case eWNI_SME_UPDATE_CONFIG:
4716 lim_process_sme_update_config(pMac,
4717 (struct update_config *)pMsgBuf);
4718 break;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004719 case eWNI_SME_SET_ADDBA_ACCEPT:
4720 lim_process_sme_set_addba_accept(pMac,
4721 (struct sme_addba_accept *)pMsgBuf);
4722 break;
Arif Hussaineb8ba362018-03-07 19:15:13 -08004723 case eWNI_SME_UPDATE_EDCA_PROFILE:
4724 lim_process_sme_update_edca_params(pMac, pMsg->bodyval);
4725 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004726 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304727 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004728 pMsg->bodyptr = NULL;
4729 break;
4730 } /* switch (msgType) */
4731
4732 return bufConsumed;
4733} /*** end lim_process_sme_req_messages() ***/
4734
4735/**
4736 * lim_process_sme_start_beacon_req()
4737 *
4738 ***FUNCTION:
4739 * This function is called by limProcessMessageQueue(). This
4740 * function processes SME request messages from HDD or upper layer
4741 * application.
4742 *
4743 ***LOGIC:
4744 *
4745 ***ASSUMPTIONS:
4746 *
4747 ***NOTE:
4748 *
4749 * @param pMac Pointer to Global MAC structure
4750 * @param msgType Indicates the SME message type
4751 * @param *pMsgBuf A pointer to the SME message buffer
4752 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4753 * false - if pMsgBuf is not to be freed.
4754 */
4755static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
4756{
4757 tpSirStartBeaconIndication pBeaconStartInd;
4758 tpPESession psessionEntry;
4759 uint8_t sessionId; /* PE sessionID */
4760
4761 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004762 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004763 return;
4764 }
4765
4766 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
4767 psessionEntry = pe_find_session_by_bssid(pMac,
4768 pBeaconStartInd->bssid,
4769 &sessionId);
4770 if (psessionEntry == NULL) {
4771 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004772 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004773 return;
4774 }
4775
4776 if (pBeaconStartInd->beaconStartStatus == true) {
4777 /*
4778 * Currently this Indication comes from SAP
4779 * to start Beacon Tx on a DFS channel
4780 * since beaconing has to be done on DFS
4781 * channel only after CAC WAIT is completed.
4782 * On a DFS Channel LIM does not start beacon
4783 * Tx right after the WMA_ADD_BSS_RSP.
4784 */
4785 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05304786 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004787 FL("Start Beacon with ssid %s Ch %d"),
4788 psessionEntry->ssId.ssId,
4789 psessionEntry->currentOperChannel);
4790 lim_send_beacon_ind(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08004791 lim_enable_obss_detection_config(pMac, psessionEntry);
Arif Hussain05fb4872018-01-03 16:02:55 -08004792 lim_send_obss_color_collision_cfg(pMac, psessionEntry,
4793 OBSS_COLOR_COLLISION_DETECTION);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004794 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004795 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004796 return;
4797 }
4798}
4799
4800/**
4801 * lim_process_sme_channel_change_request() - process sme ch change req
4802 *
4803 * @mac_ctx: Pointer to Global MAC structure
4804 * @msg_buf: pointer to the SME message buffer
4805 *
4806 * This function is called to process SME_CHANNEL_CHANGE_REQ message
4807 *
4808 * Return: None
4809 */
4810static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
4811 uint32_t *msg_buf)
4812{
4813 tpSirChanChangeRequest ch_change_req;
4814 tpPESession session_entry;
4815 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07004816 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004817 uint32_t val = 0;
4818
4819 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004820 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004821 return;
4822 }
4823 ch_change_req = (tpSirChanChangeRequest)msg_buf;
4824
4825 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
4826 ch_change_req->targetChannel);
4827
4828 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
4829 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004830 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004831 return;
4832 }
4833
4834 session_entry = pe_find_session_by_bssid(mac_ctx,
4835 ch_change_req->bssid, &session_id);
4836 if (session_entry == NULL) {
4837 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004838 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004839 return;
4840 }
4841
Manjunathappa Prakash34fda792018-02-07 18:23:42 -08004842 if ((session_entry->currentOperChannel ==
4843 ch_change_req->targetChannel) &&
4844 (session_entry->ch_width == ch_change_req->ch_width)) {
4845 pe_err("Target channel and mode is same as current channel and mode channel %d and mode %d",
4846 session_entry->currentOperChannel, session_entry->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004847 return;
4848 }
4849
4850 if (LIM_IS_AP_ROLE(session_entry))
4851 session_entry->channelChangeReasonCode =
4852 LIM_SWITCH_CHANNEL_SAP_DFS;
4853 else
4854 session_entry->channelChangeReasonCode =
4855 LIM_SWITCH_CHANNEL_OPERATION;
4856
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004857 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004858 session_entry->currentOperChannel,
4859 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004860 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004861
4862 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004863 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004864 session_entry->ch_center_freq_seg0 =
4865 ch_change_req->center_freq_seg_0;
4866 session_entry->ch_center_freq_seg1 =
4867 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004868 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004869 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004870 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004871 session_entry->htRecommendedTxWidthSet =
4872 session_entry->htSupportedChannelWidthSet;
4873 session_entry->currentOperChannel =
4874 ch_change_req->targetChannel;
4875 session_entry->limRFBand =
4876 lim_get_rf_band(session_entry->currentOperChannel);
4877 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08004878 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004879 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004880 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
4881 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004882 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004883 }
4884
4885 session_entry->lim11hEnable = val;
4886 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304887 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004888 &ch_change_req->operational_rateset,
4889 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304890 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004891 &ch_change_req->extended_rateset,
4892 sizeof(session_entry->extRateSet));
4893 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
4894 session_entry->ch_center_freq_seg0,
4895 session_entry->ch_center_freq_seg1,
4896 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07004897 max_tx_pwr, session_entry->peSessionId,
4898 ch_change_req->cac_duration_ms,
4899 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004900}
4901
4902/******************************************************************************
4903* lim_start_bss_update_add_ie_buffer()
4904*
4905***FUNCTION:
4906* This function checks the src buffer and its length and then malloc for
4907* dst buffer update the same
4908*
4909***LOGIC:
4910*
4911***ASSUMPTIONS:
4912*
4913***NOTE:
4914*
4915* @param pMac Pointer to Global MAC structure
4916* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
4917* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
4918* @param *pSrcData_buff A pointer of uint8_t src buffer
4919* @param srcDataLen src buffer length
4920******************************************************************************/
4921
4922static void
4923lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
4924 uint8_t **pDstData_buff,
4925 uint16_t *pDstDataLen,
4926 uint8_t *pSrcData_buff, uint16_t srcDataLen)
4927{
4928
4929 if (srcDataLen > 0 && pSrcData_buff != NULL) {
4930 *pDstDataLen = srcDataLen;
4931
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304932 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004933
4934 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004935 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004936 return;
4937 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304938 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004939 } else {
4940 *pDstData_buff = NULL;
4941 *pDstDataLen = 0;
4942 }
4943}
4944
4945/******************************************************************************
4946* lim_update_add_ie_buffer()
4947*
4948***FUNCTION:
4949* This function checks the src buffer and length if src buffer length more
4950* than dst buffer length then free the dst buffer and malloc for the new src
4951* length, and update the dst buffer and length. But if dst buffer is bigger
4952* than src buffer length then it just update the dst buffer and length
4953*
4954***LOGIC:
4955*
4956***ASSUMPTIONS:
4957*
4958***NOTE:
4959*
4960* @param pMac Pointer to Global MAC structure
4961* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
4962* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
4963* @param *pSrcData_buff A pointer of uint8_t src buffer
4964* @param srcDataLen src buffer length
4965******************************************************************************/
4966
4967static void
4968lim_update_add_ie_buffer(tpAniSirGlobal pMac,
4969 uint8_t **pDstData_buff,
4970 uint16_t *pDstDataLen,
4971 uint8_t *pSrcData_buff, uint16_t srcDataLen)
4972{
4973
4974 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004975 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004976 return;
4977 }
4978
4979 if (srcDataLen > *pDstDataLen) {
4980 *pDstDataLen = srcDataLen;
4981 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304982 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004983 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304984 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004985
4986 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004987 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004988 *pDstDataLen = 0;
4989 return;
4990 }
4991 }
4992
4993 /* copy the content of buffer into dst buffer
4994 */
4995 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304996 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004997
4998}
4999
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005000/**
5001 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5002 * @pMac : Pointer to Global MAC structure
5003 * @pDstData_buff : A pointer to pointer of dst buffer
5004 * @pDstDataLen : A pointer to pointer of dst buffer length
5005 * @pModifyIE : A pointer to tSirModifyIE
5006 *
5007 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5008 *
5009 * Return:
5010 * True or false depending upon whether IE is updated or not
5011 */
5012static bool
5013lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5014 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5015{
Hong Shi1553d692016-09-28 12:16:19 +08005016 int32_t oui_length;
5017 uint8_t *ibss_ie = NULL;
5018 uint8_t *vendor_ie;
5019#define MAC_VENDOR_OUI "\x00\x16\x32"
5020#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005021
5022 ibss_ie = pModifyIE->pIEBuffer;
5023 oui_length = pModifyIE->oui_length;
5024
5025 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005026 pe_err("Invalid set IBSS vendor IE command length %d",
5027 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005028 return false;
5029 }
5030
Hong Shi1553d692016-09-28 12:16:19 +08005031 /*
5032 * Why replace only beacon OUI data here:
5033 * 1. other ie (such as wpa) shall not be overwritten here.
5034 * 2. per spec, beacon oui ie might be set twice and original one
5035 * shall be updated.
5036 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005037 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005038 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5039 if (vendor_ie) {
5040 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5041 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5042 pModifyIE->ieBufferlength);
5043 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005044 uint16_t new_length;
5045 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005046
Naveen Rawat668dee32017-09-29 14:39:40 -07005047 /*
5048 * check for uint16 overflow before using sum of two numbers as
5049 * length of size to malloc
5050 */
5051 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5052 pe_err("U16 overflow due to %d + %d",
5053 pModifyIE->ieBufferlength, *pDstDataLen);
5054 return false;
5055 }
5056
5057 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5058 new_ptr = qdf_mem_malloc(new_length);
Hong Shi1553d692016-09-28 12:16:19 +08005059 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005060 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005061 return false;
5062 }
5063 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5064 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5065 pModifyIE->ieBufferlength);
5066 qdf_mem_free(*pDstData_buff);
5067 *pDstDataLen = new_length;
5068 *pDstData_buff = new_ptr;
5069 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005070 return true;
5071}
5072
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005073/*
5074* lim_process_modify_add_ies() - process modify additional IE req.
5075*
5076* @mac_ctx: Pointer to Global MAC structure
5077* @msg_buf: pointer to the SME message buffer
5078*
5079* This function update the PE buffers for additional IEs.
5080*
5081* Return: None
5082*/
5083static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5084 uint32_t *msg_buf)
5085{
5086 tpSirModifyIEsInd modify_add_ies;
5087 tpPESession session_entry;
5088 uint8_t session_id;
5089 bool ret = false;
5090 tSirAddIeParams *add_ie_params;
5091
5092 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005093 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005094 return;
5095 }
5096
5097 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5098 /* Incoming message has smeSession, use BSSID to find PE session */
5099 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005100 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005101
5102 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005103 pe_err("Session not found for given bssid"
5104 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005105 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005106 goto end;
5107 }
5108 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5109 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5110 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005111 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005112 modify_add_ies->modifyIE.pIEBuffer,
5113 modify_add_ies->modifyIE.ieBufferlength,
5114 modify_add_ies->modifyIE.ieID,
5115 modify_add_ies->modifyIE.ieIDLen,
5116 modify_add_ies->updateType);
5117 goto end;
5118 }
5119 add_ie_params = &session_entry->addIeParams;
5120 switch (modify_add_ies->updateType) {
5121 case eUPDATE_IE_PROBE_RESP:
5122 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005123 if (LIM_IS_IBSS_ROLE(session_entry)) {
5124 lim_update_ibss_prop_add_ies(mac_ctx,
5125 &add_ie_params->probeRespData_buff,
5126 &add_ie_params->probeRespDataLen,
5127 &modify_add_ies->modifyIE);
5128 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005129 break;
5130 case eUPDATE_IE_ASSOC_RESP:
5131 /* assoc resp IE */
5132 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305133 QDF_TRACE(QDF_MODULE_ID_PE,
5134 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005135 "assoc resp add ie not present %d"),
5136 add_ie_params->assocRespDataLen);
5137 }
5138 /* search through the buffer and modify the IE */
5139 break;
5140 case eUPDATE_IE_PROBE_BCN:
5141 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005142 if (LIM_IS_IBSS_ROLE(session_entry)) {
5143 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5144 &add_ie_params->probeRespBCNData_buff,
5145 &add_ie_params->probeRespBCNDataLen,
5146 &modify_add_ies->modifyIE);
5147 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005148 if (ret == true && modify_add_ies->modifyIE.notify) {
5149 lim_handle_param_update(mac_ctx,
5150 modify_add_ies->updateType);
5151 }
5152 break;
5153 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005154 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005155 modify_add_ies->updateType);
5156 break;
5157 }
5158end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305159 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005160 modify_add_ies->modifyIE.pIEBuffer = NULL;
5161}
5162
5163/*
5164* lim_process_update_add_ies() - process additional IE update req
5165*
5166* @mac_ctx: Pointer to Global MAC structure
5167* @msg_buf: pointer to the SME message buffer
5168*
5169* This function update the PE buffers for additional IEs.
5170*
5171* Return: None
5172*/
5173static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5174 uint32_t *msg_buf)
5175{
5176 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5177 uint8_t session_id;
5178 tpPESession session_entry;
5179 tSirAddIeParams *addn_ie;
5180 uint16_t new_length = 0;
5181 uint8_t *new_ptr = NULL;
5182 tSirUpdateIE *update_ie;
5183
5184 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005185 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005186 return;
5187 }
5188 update_ie = &update_add_ies->updateIE;
5189 /* incoming message has smeSession, use BSSID to find PE session */
5190 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005191 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005192
5193 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005194 pe_err("Session not found for given bssid"
5195 MAC_ADDRESS_STR,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005196 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005197 goto end;
5198 }
5199 addn_ie = &session_entry->addIeParams;
5200 /* if len is 0, upper layer requested freeing of buffer */
5201 if (0 == update_ie->ieBufferlength) {
5202 switch (update_add_ies->updateType) {
5203 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305204 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005205 addn_ie->probeRespData_buff = NULL;
5206 addn_ie->probeRespDataLen = 0;
5207 break;
5208 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305209 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005210 addn_ie->assocRespData_buff = NULL;
5211 addn_ie->assocRespDataLen = 0;
5212 break;
5213 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305214 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005215 addn_ie->probeRespBCNData_buff = NULL;
5216 addn_ie->probeRespBCNDataLen = 0;
5217
5218 if (update_ie->notify)
5219 lim_handle_param_update(mac_ctx,
5220 update_add_ies->updateType);
5221 break;
5222 default:
5223 break;
5224 }
5225 return;
5226 }
5227 switch (update_add_ies->updateType) {
5228 case eUPDATE_IE_PROBE_RESP:
5229 if (update_ie->append) {
5230 /*
5231 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005232 * with combined length.
5233 * Multiple back to back append commands
5234 * can lead to a huge length.So, check
5235 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005236 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005237 if (addn_ie->probeRespDataLen >
5238 (USHRT_MAX - update_ie->ieBufferlength)) {
5239 pe_err("IE Length overflow, curr:%d, new:%d",
5240 addn_ie->probeRespDataLen,
5241 update_ie->ieBufferlength);
5242 goto end;
5243 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005244 new_length = update_ie->ieBufferlength +
5245 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305246 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005247 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005248 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005249 goto end;
5250 }
5251 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305252 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005253 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305254 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005255 update_ie->pAdditionIEBuffer,
5256 update_ie->ieBufferlength);
5257 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305258 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005259 /* adjust length accordingly */
5260 addn_ie->probeRespDataLen = new_length;
5261 /* save refernece of local buffer in PE session */
5262 addn_ie->probeRespData_buff = new_ptr;
5263 goto end;
5264 }
5265 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5266 &addn_ie->probeRespDataLen,
5267 update_ie->pAdditionIEBuffer,
5268 update_ie->ieBufferlength);
5269 break;
5270 case eUPDATE_IE_ASSOC_RESP:
5271 /* assoc resp IE */
5272 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5273 &addn_ie->assocRespDataLen,
5274 update_ie->pAdditionIEBuffer,
5275 update_ie->ieBufferlength);
5276 break;
5277 case eUPDATE_IE_PROBE_BCN:
5278 /* probe resp Bcn IE */
5279 lim_update_add_ie_buffer(mac_ctx,
5280 &addn_ie->probeRespBCNData_buff,
5281 &addn_ie->probeRespBCNDataLen,
5282 update_ie->pAdditionIEBuffer,
5283 update_ie->ieBufferlength);
5284 if (update_ie->notify)
5285 lim_handle_param_update(mac_ctx,
5286 update_add_ies->updateType);
5287 break;
5288 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005289 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005290 break;
5291 }
5292end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305293 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005294 update_ie->pAdditionIEBuffer = NULL;
5295}
5296
5297/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305298 * send_extended_chan_switch_action_frame()- function to send ECSA
5299 * action frame for each sta connected to SAP/GO and AP in case of
5300 * STA .
5301 * @mac_ctx: pointer to global mac structure
5302 * @new_channel: new channel to switch to.
5303 * @ch_bandwidth: BW of channel to calculate op_class
5304 * @session_entry: pe session
5305 *
5306 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5307 *
5308 * Return: void
5309 */
5310
5311static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5312 uint16_t new_channel, uint8_t ch_bandwidth,
5313 tpPESession session_entry)
5314{
5315 uint16_t op_class;
5316 uint8_t switch_mode = 0, i;
5317 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005318 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305319
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005320 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305321 mac_ctx->scan.countryCodeCurrent,
5322 new_channel,
5323 ch_bandwidth);
5324
5325 if (LIM_IS_AP_ROLE(session_entry) &&
5326 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005327 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305328
gaoleze2920bd2017-03-21 17:38:42 +08005329 switch_count = session_entry->gLimChannelSwitch.switchCount;
5330
Abhishek Singh518323d2015-10-19 17:42:01 +05305331 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005332 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305333 psta =
5334 session_entry->dph.dphHashTable.pDphNodeArray + i;
5335 if (psta && psta->added)
5336 lim_send_extended_chan_switch_action_frame(
5337 mac_ctx,
5338 psta->staAddr,
5339 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005340 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305341 }
5342 } else if (LIM_IS_STA_ROLE(session_entry)) {
5343 lim_send_extended_chan_switch_action_frame(mac_ctx,
5344 session_entry->bssId,
5345 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005346 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305347 }
5348
5349}
5350
gaolez76d2a162017-03-21 19:23:58 +08005351void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5352 uint16_t new_channel,
5353 uint8_t ch_bandwidth,
5354 tpPESession session_entry)
5355{
5356 uint16_t op_class;
5357 uint8_t switch_mode = 0, i;
5358 uint8_t switch_count;
5359 tpDphHashNode psta;
5360 tpDphHashNode dph_node_array_ptr;
5361
5362 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5363
5364 op_class = wlan_reg_dmn_get_opclass_from_channel(
5365 mac_ctx->scan.countryCodeCurrent,
5366 new_channel, ch_bandwidth);
5367
5368 if (LIM_IS_AP_ROLE(session_entry) &&
5369 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5370 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5371
5372 switch_count = session_entry->gLimChannelSwitch.switchCount;
5373
5374 if (LIM_IS_AP_ROLE(session_entry)) {
5375 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5376 psta = dph_node_array_ptr + i;
5377 if (!(psta && psta->added))
5378 continue;
5379 if (session_entry->lim_non_ecsa_cap_num == 0)
5380 lim_send_extended_chan_switch_action_frame
5381 (mac_ctx, psta->staAddr, switch_mode,
5382 op_class, new_channel, switch_count,
5383 session_entry);
5384 else
5385 lim_send_channel_switch_mgmt_frame
5386 (mac_ctx, psta->staAddr, switch_mode,
5387 new_channel, switch_count,
5388 session_entry);
5389 }
5390 } else if (LIM_IS_STA_ROLE(session_entry)) {
5391 lim_send_extended_chan_switch_action_frame
5392 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5393 new_channel, switch_count, session_entry);
5394 }
5395}
5396
5397/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005398 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5399 *
5400 * @mac_ctx: Pointer to Global MAC structure
5401 * @msg_buf: pointer to the SME message buffer
5402 *
5403 * This function processes SME request messages from HDD or upper layer
5404 * application.
5405 *
5406 * Return: None
5407 */
5408static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5409 uint32_t *msg_buf)
5410{
5411 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5412 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005413 uint8_t session_id;
5414 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005415 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005416
5417 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005418 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005419 return;
5420 }
5421
5422 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5423 session_entry = pe_find_session_by_bssid(mac_ctx,
5424 dfs_csa_ie_req->bssid, &session_id);
5425 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005426 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005427 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5428 return;
5429 }
5430
5431 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005432 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005433 GET_LIM_SYSTEM_ROLE(session_entry));
5434 return;
5435 }
5436
5437 /* target channel */
5438 session_entry->gLimChannelSwitch.primaryChannel =
5439 dfs_csa_ie_req->targetChannel;
5440
5441 /* Channel switch announcement needs to be included in beacon */
5442 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005443 session_entry->gLimChannelSwitch.switchCount =
5444 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005445 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005446 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305447 session_entry->gLimChannelSwitch.sec_ch_offset =
5448 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005449 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005450 session_entry->gLimChannelSwitch.switchMode =
5451 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005452
5453 /*
5454 * Validate if SAP is operating HT or VHT mode and set the Channel
5455 * Switch Wrapper element with the Wide Band Switch subelement.
5456 */
5457 if (true != session_entry->vhtCapability)
5458 goto skip_vht;
5459
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005460 /* Now encode the Wider Ch BW element depending on the ch width */
5461 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005462 switch (dfs_csa_ie_req->ch_params.ch_width) {
5463 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005464 /*
5465 * Wide channel BW sublement in channel wrapper element is not
5466 * required in case of 20 Mhz operation. Currently It is set
5467 * only set in case of 40/80 Mhz Operation.
5468 */
5469 session_entry->dfsIncludeChanWrapperIe = false;
5470 wider_bw_ch_switch->newChanWidth =
5471 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5472 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005473 case CH_WIDTH_40MHZ:
5474 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005475 wider_bw_ch_switch->newChanWidth =
5476 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5477 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005478 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005479 session_entry->dfsIncludeChanWrapperIe = true;
5480 wider_bw_ch_switch->newChanWidth =
5481 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5482 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005483 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005484 session_entry->dfsIncludeChanWrapperIe = true;
5485 wider_bw_ch_switch->newChanWidth =
5486 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5487 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005488 case CH_WIDTH_80P80MHZ:
5489 session_entry->dfsIncludeChanWrapperIe = true;
5490 wider_bw_ch_switch->newChanWidth =
5491 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005492 /*
5493 * This is not applicable for 20/40/80 Mhz.
5494 * Only used when we support 80+80 Mhz operation.
5495 * In case of 80+80 Mhz, this parameter indicates
5496 * center channel frequency index of 80 Mhz channel of
5497 * frequency segment 1.
5498 */
5499 wider_bw_ch_switch->newCenterChanFreq1 =
5500 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005501 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005502 default:
5503 session_entry->dfsIncludeChanWrapperIe = false;
5504 /*
5505 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5506 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5507 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005508 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005509 break;
5510 }
5511 /* Fetch the center channel based on the channel width */
5512 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005513 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005514skip_vht:
5515 /* Send CSA IE request from here */
5516 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5517 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005518 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005519 return;
5520 }
5521
5522 /*
5523 * First beacon update request is sent here, the remaining updates are
5524 * done when the FW responds back after sending the first beacon after
5525 * the template update
5526 */
5527 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305528
5529 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5530 ch_offset = BW80;
5531 else
5532 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5533
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005534 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305535 session_entry->gLimChannelSwitch.switchCount,
5536 session_entry->gLimChannelSwitch.primaryChannel,
5537 session_entry->gLimChannelSwitch.ch_width,
5538 session_entry->dfsIncludeChanWrapperIe,
5539 ch_offset);
5540
gaolez76d2a162017-03-21 19:23:58 +08005541 /* Send ECSA/CSA Action frame after updating the beacon */
5542 if (CHAN_HOP_ALL_BANDS_ENABLE)
5543 lim_send_chan_switch_action_frame(mac_ctx,
5544 session_entry->gLimChannelSwitch.primaryChannel,
5545 ch_offset, session_entry);
5546 else
5547 send_extended_chan_switch_action_frame(mac_ctx,
5548 session_entry->gLimChannelSwitch.primaryChannel,
5549 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005550}
5551
5552/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305553 * lim_process_ext_change_channel()- function to send ECSA
5554 * action frame for STA/CLI .
5555 * @mac_ctx: pointer to global mac structure
5556 * @msg: params from sme for new channel.
5557 *
5558 * This function is called to send ECSA frame for STA/CLI.
5559 *
5560 * Return: void
5561 */
5562
5563static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5564 uint32_t *msg)
5565{
5566 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5567 (struct sir_sme_ext_cng_chan_req *) msg;
5568 tpPESession session_entry = NULL;
5569
5570 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005571 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305572 return;
5573 }
5574 session_entry =
5575 pe_find_session_by_sme_session_id(mac_ctx,
5576 ext_chng_channel->session_id);
5577 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005578 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305579 ext_chng_channel->session_id);
5580 return;
5581 }
5582 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005583 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305584 return;
5585 }
5586 send_extended_chan_switch_action_frame(mac_ctx,
5587 ext_chng_channel->new_channel,
5588 0, session_entry);
5589}
5590
5591/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005592 * lim_process_nss_update_request() - process sme nss update req
5593 *
5594 * @mac_ctx: Pointer to Global MAC structure
5595 * @msg_buf: pointer to the SME message buffer
5596 *
5597 * This function processes SME request messages from HDD or upper layer
5598 * application.
5599 *
5600 * Return: None
5601 */
5602static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5603 uint32_t *msg_buf)
5604{
5605 struct sir_nss_update_request *nss_update_req_ptr;
5606 tpPESession session_entry = NULL;
5607
5608 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005609 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005610 return;
5611 }
5612
5613 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305614 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005615 nss_update_req_ptr->vdev_id);
5616 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005617 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005618 nss_update_req_ptr->vdev_id);
5619 return;
5620 }
5621
5622 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005623 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005624 GET_LIM_SYSTEM_ROLE(session_entry));
5625 return;
5626 }
5627
5628 /* populate nss field in the beacon */
5629 session_entry->gLimOperatingMode.present = 1;
5630 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05305631 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
5632
5633 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
5634 (session_entry->ch_width > CH_WIDTH_80MHZ))
5635 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
5636
5637 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
5638
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005639 /* Send nss update request from here */
5640 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5641 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005642 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005643 return;
5644 }
5645
5646 lim_send_beacon_ind(mac_ctx, session_entry);
5647}
5648
5649/**
5650 * lim_process_set_ie_req() - process sme set IE request
5651 *
5652 * @mac_ctx: Pointer to Global MAC structure
5653 * @msg_buf: pointer to the SME message buffer
5654 *
5655 * This function processes SME request messages from HDD or upper layer
5656 * application.
5657 *
5658 * Return: None
5659 */
5660static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5661{
5662 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305663 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005664
5665 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005666 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005667 return;
5668 }
5669
5670 msg = (struct send_extcap_ie *)msg_buf;
5671 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305672 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005673 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005674
5675}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005676
5677#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Arif Hussain05fb4872018-01-03 16:02:55 -08005678
5679/**
5680 * obss_color_collision_process_color_disable() - Disable bss color
5681 * @mac_ctx: Pointer to Global MAC structure
5682 * @session: pointer to session
5683 *
5684 * This function will disbale bss color.
5685 *
5686 * Return: None
5687 */
5688static void obss_color_collision_process_color_disable(tpAniSirGlobal mac_ctx,
5689 tpPESession session)
5690{
5691 tUpdateBeaconParams beacon_params;
5692
5693 if (!session) {
5694 pe_err("Invalid session");
5695 return;
5696 }
5697
5698 if (session->valid && !LIM_IS_AP_ROLE(session)) {
5699 pe_err("Invalid SystemRole %d",
5700 GET_LIM_SYSTEM_ROLE(session));
5701 return;
5702 }
5703
5704 if (session->bss_color_changing == 1) {
5705 pe_warn("%d: color change in progress", session->smeSessionId);
5706 /* Continue color collision detection */
5707 lim_send_obss_color_collision_cfg(mac_ctx, session,
5708 OBSS_COLOR_COLLISION_DETECTION);
5709 return;
5710 }
5711
5712 if (session->he_op.bss_col_disabled == 1) {
5713 pe_warn("%d: bss color already disabled",
5714 session->smeSessionId);
5715 /* Continue free color detection */
5716 lim_send_obss_color_collision_cfg(mac_ctx, session,
5717 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5718 return;
5719 }
5720
5721 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5722 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5723 session->he_op.bss_col_disabled = 1;
Arif Hussain05fb4872018-01-03 16:02:55 -08005724 beacon_params.bss_color_disabled = 1;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005725 beacon_params.bss_color = session->he_op.bss_color;
Arif Hussain05fb4872018-01-03 16:02:55 -08005726
5727 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
5728 eSIR_SUCCESS) {
5729 pe_err("Unable to set op mode IE in beacon");
5730 return;
5731 }
5732
5733 lim_send_beacon_params(mac_ctx, &beacon_params, session);
5734 lim_send_obss_color_collision_cfg(mac_ctx, session,
5735 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5736}
5737
5738/**
5739 * obss_color_collision_process_color_change() - Process bss color change
5740 * @mac_ctx: Pointer to Global MAC structure
5741 * @session: pointer to session
5742 * @obss_color_info: obss color collision/free slot indication info
5743 *
5744 * This function selects new color ib case of bss color collision.
5745 *
5746 * Return: None
5747 */
5748static void obss_color_collision_process_color_change(tpAniSirGlobal mac_ctx,
5749 tpPESession session,
5750 struct wmi_obss_color_collision_info *obss_color_info)
5751{
5752 int i, num_bss_color = 0;
5753 uint32_t bss_color_bitmap;
5754 uint8_t bss_color_index_array[MAX_BSS_COLOR_VALUE];
5755 uint32_t rand_byte = 0;
5756 struct sir_set_he_bss_color he_bss_color;
5757 bool is_color_collision = false;
5758
5759
5760 if (session->bss_color_changing == 1) {
5761 pe_err("%d: color change in progress", session->smeSessionId);
5762 return;
5763 }
5764
5765 if (!session->he_op.bss_col_disabled) {
5766 if (session->he_op.bss_color < 32)
5767 is_color_collision = (obss_color_info->
5768 obss_color_bitmap_bit0to31 >>
5769 session->he_op.bss_color) & 0x01;
5770 else
5771 is_color_collision = (obss_color_info->
5772 obss_color_bitmap_bit32to63 >>
5773 (session->he_op.bss_color -
Arif Hussain9e8c5612018-04-12 16:35:48 -07005774 32)) & 0x01;
Arif Hussain05fb4872018-01-03 16:02:55 -08005775 if (!is_color_collision) {
5776 pe_err("%d: color collision not found, curr_color: %d",
5777 session->smeSessionId,
5778 session->he_op.bss_color);
5779 return;
5780 }
5781 }
5782
5783 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit0to31;
5784
5785 /* Skip color zero */
5786 bss_color_bitmap = bss_color_bitmap >> 1;
5787 for (i = 0; (i < 31) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5788 if (!(bss_color_bitmap & 0x01)) {
5789 bss_color_index_array[num_bss_color] = i + 1;
5790 num_bss_color++;
5791 }
5792 bss_color_bitmap = bss_color_bitmap >> 1;
5793 }
5794
5795 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit32to63;
5796 for (i = 0; (i < 32) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5797 if (!(bss_color_bitmap & 0x01)) {
5798 bss_color_index_array[num_bss_color] = i + 32;
5799 num_bss_color++;
5800 }
5801 bss_color_bitmap = bss_color_bitmap >> 1;
5802 }
5803
5804 if (num_bss_color) {
5805 qdf_get_random_bytes((void *) &rand_byte, 1);
5806 i = (rand_byte + qdf_mc_timer_get_system_ticks()) %
5807 num_bss_color;
5808 pe_debug("New bss color = %d", bss_color_index_array[i]);
5809 he_bss_color.session_id = obss_color_info->vdev_id;
5810 he_bss_color.bss_color = bss_color_index_array[i];
5811 lim_process_set_he_bss_color(mac_ctx,
5812 (uint32_t *)&he_bss_color);
5813 } else {
5814 pe_err("Unable to find bss color from bitmasp");
5815 if (obss_color_info->evt_type ==
5816 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY &&
5817 session->obss_color_collision_dec_evt ==
5818 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
5819 /* In dot11BSSColorCollisionAPPeriod and
5820 * timer expired, time to disable bss color.
5821 */
5822 obss_color_collision_process_color_disable(mac_ctx,
5823 session);
5824 else
5825 /*
5826 * Enter dot11BSSColorCollisionAPPeriod period.
5827 */
5828 lim_send_obss_color_collision_cfg(mac_ctx, session,
5829 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY);
5830 }
5831}
5832
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005833void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5834{
5835 struct sir_set_he_bss_color *bss_color;
5836 tpPESession session_entry = NULL;
5837 tUpdateBeaconParams beacon_params;
5838
5839 if (!msg_buf) {
5840 pe_err("Buffer is Pointing to NULL");
5841 return;
5842 }
5843
5844 bss_color = (struct sir_set_he_bss_color *)msg_buf;
5845 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5846 bss_color->session_id);
5847 if (!session_entry) {
5848 pe_err("Session not found for given session_id %d",
5849 bss_color->session_id);
5850 return;
5851 }
5852
5853 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5854 pe_err("Invalid SystemRole %d",
5855 GET_LIM_SYSTEM_ROLE(session_entry));
5856 return;
5857 }
5858
5859 if (bss_color->bss_color == session_entry->he_op.bss_color) {
5860 pe_err("No change in BSS color, current BSS color %d",
5861 bss_color->bss_color);
5862 return;
5863 }
5864 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5865 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5866 session_entry->he_op.bss_col_disabled = 1;
5867 session_entry->he_bss_color_change.countdown =
5868 BSS_COLOR_SWITCH_COUNTDOWN;
5869 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005870 beacon_params.bss_color_disabled = 1;
5871 beacon_params.bss_color = session_entry->he_op.bss_color;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005872 session_entry->bss_color_changing = 1;
5873
5874 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5875 eSIR_SUCCESS) {
5876 pe_err("Unable to set op mode IE in beacon");
5877 return;
5878 }
5879
5880 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
Arif Hussain05fb4872018-01-03 16:02:55 -08005881 lim_send_obss_color_collision_cfg(mac_ctx, session_entry,
5882 OBSS_COLOR_COLLISION_DETECTION_DISABLE);
5883}
5884
5885void lim_send_obss_color_collision_cfg(tpAniSirGlobal mac_ctx,
5886 tpPESession session,
5887 enum wmi_obss_color_collision_evt_type
5888 event_type)
5889{
5890 struct wmi_obss_color_collision_cfg_param *cfg_param;
5891 struct scheduler_msg msg = {0};
5892
5893 if (!session) {
5894 pe_err("Invalid session");
5895 return;
5896 }
5897
5898 if (!session->he_capable ||
5899 !session->is_session_obss_color_collision_det_enabled) {
5900 pe_debug("%d: obss color det not enabled, he_cap:%d, sup:%d:%d",
5901 session->smeSessionId, session->he_capable,
5902 session->is_session_obss_color_collision_det_enabled,
5903 mac_ctx->lim.global_obss_color_collision_det_offload);
5904 return;
5905 }
5906
5907 cfg_param = qdf_mem_malloc(sizeof(*cfg_param));
5908 if (!cfg_param) {
5909 pe_err("Failed to allocate memory");
5910 return;
5911 }
5912
5913 pe_debug("%d: sending event:%d", session->smeSessionId, event_type);
5914 qdf_mem_zero(cfg_param, sizeof(*cfg_param));
5915 cfg_param->vdev_id = session->smeSessionId;
5916 cfg_param->evt_type = event_type;
5917 if (LIM_IS_AP_ROLE(session))
5918 cfg_param->detection_period_ms =
5919 OBSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS;
5920 else
5921 cfg_param->detection_period_ms =
5922 OBSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS;
5923
5924 cfg_param->scan_period_ms = OBSS_COLOR_COLLISION_SCAN_PERIOD_MS;
5925 if (event_type == OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
5926 cfg_param->free_slot_expiry_time_ms =
5927 OBSS_COLOR_COLLISION_FREE_SLOT_EXPIRY_MS;
5928
5929 msg.type = WMA_OBSS_COLOR_COLLISION_REQ;
5930 msg.bodyptr = cfg_param;
5931 msg.reserved = 0;
5932
5933 if (QDF_IS_STATUS_ERROR(scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
5934 pe_err("Failed to post WMA_OBSS_COLOR_COLLISION_REQ to WMA");
5935 qdf_mem_free(cfg_param);
5936 } else {
5937 session->obss_color_collision_dec_evt = event_type;
5938 }
5939}
5940
5941void lim_process_obss_color_collision_info(tpAniSirGlobal mac_ctx,
5942 uint32_t *msg_buf)
5943{
5944 struct wmi_obss_color_collision_info *obss_color_info;
5945 tpPESession session;
5946
5947 if (!msg_buf) {
5948 pe_err("Buffer is Pointing to NULL");
5949 return;
5950 }
5951
5952 obss_color_info = (struct wmi_obss_color_collision_info *)msg_buf;
5953 session = pe_find_session_by_sme_session_id(mac_ctx,
5954 obss_color_info->vdev_id);
5955 if (!session) {
5956 pe_err("Session not found for given session_id %d",
5957 obss_color_info->vdev_id);
5958 return;
5959 }
5960
5961 pe_debug("vdev_id:%d, evt:%d:%d, 0to31:0x%x, 32to63:0x%x, cap:%d:%d:%d",
5962 obss_color_info->vdev_id,
5963 obss_color_info->evt_type,
5964 session->obss_color_collision_dec_evt,
5965 obss_color_info->obss_color_bitmap_bit0to31,
5966 obss_color_info->obss_color_bitmap_bit32to63,
5967 session->he_capable,
5968 session->is_session_obss_color_collision_det_enabled,
5969 mac_ctx->lim.global_obss_color_collision_det_offload);
5970
5971 if (!session->he_capable ||
5972 !session->is_session_obss_color_collision_det_enabled) {
5973 return;
5974 }
5975
5976 switch (obss_color_info->evt_type) {
5977 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
5978 pe_err("%d: FW disabled obss color det. he_cap:%d, sup:%d:%d",
5979 session->smeSessionId, session->he_capable,
5980 session->is_session_obss_color_collision_det_enabled,
5981 mac_ctx->lim.global_obss_color_collision_det_offload);
5982 session->is_session_obss_color_collision_det_enabled = false;
5983 return;
5984 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
5985 case OBSS_COLOR_COLLISION_DETECTION:
5986 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
5987 if (session->valid && !LIM_IS_AP_ROLE(session)) {
5988 pe_debug("Invalid System Role %d",
5989 GET_LIM_SYSTEM_ROLE(session));
5990 return;
5991 }
5992
5993 if (session->obss_color_collision_dec_evt !=
5994 obss_color_info->evt_type) {
5995 pe_debug("%d: Wrong event: %d, skiping",
5996 obss_color_info->vdev_id,
5997 obss_color_info->evt_type);
5998 return;
5999 }
6000 obss_color_collision_process_color_change(mac_ctx, session,
6001 obss_color_info);
6002 break;
6003 default:
6004 pe_err("%d: Invalid event type %d",
6005 obss_color_info->vdev_id, obss_color_info->evt_type);
6006 return;
6007 }
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006008}
6009#endif