blob: be20acb6dbb19afb22f45b72f834e1ea66eaaed6 [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");
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530165 status = scheduler_post_message(QDF_MODULE_ID_PE,
166 QDF_MODULE_ID_WMA,
167 QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530168 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700169 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530171 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800172 goto fail;
173 }
174 return status;
175fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530176 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800177 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700178 pe_err("HW mode resp failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530179 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800180 }
181 param->status = SET_HW_MODE_STATUS_ECANCELED;
182 param->cfgd_hw_mode_index = 0;
183 param->num_vdev_mac_entries = 0;
184 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
185 resp_msg.bodyptr = param;
186 resp_msg.bodyval = 0;
187 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530188 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800189}
190
191/**
192 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
193 * @mac: Global MAC pointer
194 * @msg: Message containing the dual mac config parameter
195 *
196 * Send the set dual mac config command to WMA
197 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530198 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800199 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530200static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800201 uint32_t *msg)
202{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530203 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700204 struct scheduler_msg message = {0};
Srinivas Girigowdaeb6ecf32018-02-15 17:04:22 -0800205 struct policy_mgr_dual_mac_config *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800206 uint32_t len;
207 struct sir_set_dual_mac_cfg *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700208 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800209 struct sir_dual_mac_config_resp *param;
210
211 buf = (struct sir_set_dual_mac_cfg *) msg;
212 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700213 pe_err("Set Dual mac config is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800214 /* To free the active command list */
215 goto fail;
216 }
217
218 len = sizeof(*req_msg);
219
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530220 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800221 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700222 pe_err("qdf_mem_malloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800223 /* Free the active command list
224 * Probably the malloc is going to fail there as well?!
225 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530226 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 }
228
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229 req_msg->scan_config = buf->set_dual_mac.scan_config;
230 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
231 /* Other parameters are not needed for WMA */
232
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800233 message.bodyptr = req_msg;
234 message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700236 pe_debug("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800237 req_msg->scan_config, req_msg->fw_mode_config);
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530238 status = scheduler_post_message(QDF_MODULE_ID_PE,
239 QDF_MODULE_ID_WMA,
240 QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530241 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700242 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800243 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530244 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800245 goto fail;
246 }
247 return status;
248fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530249 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800250 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700251 pe_err("Dual mac config resp failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530252 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800253 }
254 param->status = SET_HW_MODE_STATUS_ECANCELED;
255 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
256 resp_msg.bodyptr = param;
257 resp_msg.bodyval = 0;
258 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530259 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800260}
261
262/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800263 * lim_process_set_antenna_mode_req() - Set antenna mode command
264 * to WMA
265 * @mac: Global MAC pointer
266 * @msg: Message containing the antenna mode parameter
267 *
268 * Send the set antenna mode command to WMA
269 *
270 * Return: QDF_STATUS_SUCCESS if message posting is successful
271 */
272static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
273 uint32_t *msg)
274{
275 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700276 struct scheduler_msg message = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800277 struct sir_antenna_mode_param *req_msg;
278 struct sir_set_antenna_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700279 struct scheduler_msg resp_msg = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800280 struct sir_antenna_mode_resp *param;
281
282 buf = (struct sir_set_antenna_mode *) msg;
283 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700284 pe_err("Set antenna mode is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800285 /* To free the active command list */
286 goto fail;
287 }
288
289 req_msg = qdf_mem_malloc(sizeof(*req_msg));
290 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700291 pe_err("qdf_mem_malloc failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800292 return QDF_STATUS_E_NOMEM;
293 }
294
295 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
296 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
297
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800298 message.bodyptr = req_msg;
299 message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800300
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700301 pe_debug("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800302 req_msg->num_rx_chains,
303 req_msg->num_tx_chains);
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530304 status = scheduler_post_message(QDF_MODULE_ID_PE,
305 QDF_MODULE_ID_WMA,
306 QDF_MODULE_ID_WMA, &message);
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800307 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700308 pe_err("scheduler_post_msg failed!(err=%d)",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800309 status);
310 qdf_mem_free(req_msg);
311 goto fail;
312 }
313 return status;
314fail:
315 param = qdf_mem_malloc(sizeof(*param));
316 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700317 pe_err("antenna mode resp failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800318 return QDF_STATUS_E_NOMEM;
319 }
320 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
321 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
322 resp_msg.bodyptr = param;
323 resp_msg.bodyval = 0;
324 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
325 return QDF_STATUS_SUCCESS;
326}
327
328/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800329 * __lim_is_sme_assoc_cnf_valid()
330 *
331 ***FUNCTION:
332 * This function is called by __lim_process_sme_assoc_cnf_new() upon
333 * receiving SME_ASSOC_CNF.
334 *
335 ***LOGIC:
336 * Message validity checks are performed in this function
337 *
338 ***ASSUMPTIONS:
339 *
340 ***NOTE:
341 *
342 * @param pMeasReq Pointer to Received ASSOC_CNF message
343 * @return true When received SME_ASSOC_CNF is formatted
344 * correctly
345 * false otherwise
346 */
347
348static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
349{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530350 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800351 return false;
352 else
353 return true;
354} /*** end __lim_is_sme_assoc_cnf_valid() ***/
355
356/**
357 * __lim_get_sme_join_req_size_for_alloc()
358 *
359 ***FUNCTION:
360 * This function is called in various places to get IE length
361 * from tSirBssDescription structure
362 * number being scanned.
363 *
364 ***PARAMS:
365 *
366 ***LOGIC:
367 *
368 ***ASSUMPTIONS:
369 * NA
370 *
371 ***NOTE:
372 * NA
373 *
374 * @param pBssDescr
375 * @return Total IE length
376 */
377
378static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
379{
380 uint16_t len = 0;
381
382 if (!pBuf)
383 return len;
384
385 pBuf += sizeof(uint16_t);
386 len = lim_get_u16(pBuf);
Arif Hussainc9651922017-04-16 14:08:23 -0700387 return len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800388}
389
390/**
391 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
392 * @pMac: Global MAC context
393 * @pMsg: Pointer to message posted from SME to LIM.
394 *
395 * Has role only if 11h is enabled. Not used on STA side.
396 * Defers the message if SME is in learn state and brings
397 * the LIM back to normal mode.
398 *
399 * Return: true - If defered false - Otherwise
400 */
401
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800402static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac,
403 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800404{
405 if (lim_is_system_in_scan_state(pMac)) {
406 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700407 pe_err("Could not defer Msg: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800408 return false;
409 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700410 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800411 pMsg->type);
412 return true;
413 }
414 return false;
415}
416
417/**
418 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
419 * @mac_ctx: Pointer to Global MAC structure
420 * @message: Pointer to message posted from SME to LIM.
421 *
422 * Has role only if 11h is enabled. Not used on STA side.
423 * Defers the message if radar is detected.
424 *
425 * Return: true, if defered otherwise return false.
426 */
427static bool
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800428__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx,
429 struct scheduler_msg *message)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800430{
431 /*
432 * fRadarDetCurOperChan will be set only if we
433 * detect radar in current operating channel and
434 * System Role == AP ROLE
435 *
436 * TODO: Need to take care radar detection.
437 *
438 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
439 */
440 if (0) {
441 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700442 pe_err("Could not defer Msg: %d", message->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800443 return false;
444 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700445 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800446 message->type);
447 return true;
448 }
449 return false;
450}
451
452/**
453 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
454 * @pMac: Global MAC context
455 * @pMsgBuf: Message from WMA
456 *
457 * handles the notification from HDD. PE just forwards this message to HAL.
458 *
459 * Return: true-Posting to HAL failed, so PE will consume the buffer.
460 * false-Posting to HAL successful, so HAL will consume the buffer.
461 */
462
463static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
464{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700465 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800466 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
467
468 msg.type = WMA_SYS_READY_IND;
469 msg.reserved = 0;
470 msg.bodyptr = pMsgBuf;
471 msg.bodyval = 0;
472
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700473 if (ANI_DRIVER_TYPE(pMac) != QDF_DRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800474 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +0530475 pe_register_mgmt_rx_frm_callback(pMac);
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700476 pe_register_callbacks_with_wma(pMac, ready_req);
Sandeep Puligilla1426d612017-04-12 18:22:06 -0700477 pMac->lim.sme_msg_callback = ready_req->sme_msg_cb;
Vignesh Viswanathan3d478032018-08-02 20:18:53 +0530478 pMac->lim.stop_roaming_callback = ready_req->stop_roaming_cb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800479 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700480
481 pe_debug("sending WMA_SYS_READY_IND msg to HAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800482 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
483
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700484 if (QDF_STATUS_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700485 pe_err("wma_post_ctrl_msg failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800486 return true;
487 }
488 return false;
489}
490
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800491/**
492 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
493 *@mac_ctx: Pointer to Global MAC structure
494 *@session: A pointer to session entry
495 *@sme_start_bss_req: Start BSS Request from upper layers.
496 *
497 * This function is used to configure the start bss parameters
498 * in to the session.
499 *
500 * Return: None.
501 */
502static void
503lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
504 tpSirSmeStartBssReq sme_start_bss_req)
505{
506 session->limSystemRole = eLIM_AP_ROLE;
507 session->privacy = sme_start_bss_req->privacy;
508 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
509 session->authType = sme_start_bss_req->authType;
510 /* Store the DTIM period */
511 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
512 /* Enable/disable UAPSD */
513 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530514 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800515 session->proxyProbeRspEn = 0;
516 } else {
517 /*
518 * To detect PBC overlap in SAP WPS mode,
519 * Host handles Probe Requests.
520 */
521 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
522 session->proxyProbeRspEn = 1;
523 else
524 session->proxyProbeRspEn = 0;
525 }
526 session->ssidHidden = sme_start_bss_req->ssidHidden;
527 session->wps_state = sme_start_bss_req->wps_state;
528 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530529 session->vendor_vht_sap =
530 sme_start_bss_req->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800531 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
532 &session->shortSlotTimeSupported);
533 session->isCoalesingInIBSSAllowed =
534 sme_start_bss_req->isCoalesingInIBSSAllowed;
535
Jiachao Wu712d4fd2017-08-23 16:52:34 +0800536 session->beacon_tx_rate = sme_start_bss_req->beacon_tx_rate;
537
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800538}
539
540/**
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530541 * lim_send_start_vdev_req() - send vdev start request
542 *@session: pe session
543 *@mlm_start_req: vdev start req
544 *
545 * Return: QDF_STATUS
546 */
Abhishek Singh3d30a3b2018-09-12 15:49:18 +0530547#ifdef CONFIG_VDEV_SM
548static QDF_STATUS
549lim_send_start_vdev_req(tpPESession session, tLimMlmStartReq *mlm_start_req)
550{
551 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
552 WLAN_VDEV_SM_EV_START,
553 sizeof(*mlm_start_req),
554 mlm_start_req);
555}
556#else
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530557static QDF_STATUS
558lim_send_start_vdev_req(tpPESession session, tLimMlmStartReq *mlm_start_req)
559{
560 lim_process_mlm_start_req(session->mac_ctx, mlm_start_req);
561
562 return QDF_STATUS_SUCCESS;
563}
Abhishek Singh3d30a3b2018-09-12 15:49:18 +0530564#endif
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530565
566/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800567 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
568 *@mac_ctx: Pointer to Global MAC structure
569 *@msg_buf: A pointer to the SME message buffer
570 *
571 * This function is called to process SME_START_BSS_REQ message
572 * from HDD or upper layer application.
573 *
574 * Return: None
575 */
576static void
577__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
578{
579 uint16_t size;
580 uint32_t val = 0;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700581 QDF_STATUS ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800582 tSirMacChanNum channel_number;
583 tLimMlmStartReq *mlm_start_req = NULL;
584 tpSirSmeStartBssReq sme_start_bss_req = NULL;
585 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
586 /* Flag Used in case of IBSS to Auto generate BSSID. */
587 uint32_t auto_gen_bssid = false;
588 uint8_t session_id;
589 tpPESession session = NULL;
Krunal Sonib37bb352016-12-20 14:12:21 -0800590 uint8_t sme_session_id = 0xFF;
591 uint16_t sme_transaction_id = 0xFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800592 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700593 struct vdev_type_nss *vdev_type_nss;
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530594 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
gaurank kathpaliad88ef882018-08-14 15:20:11 +0530595 struct policy_mgr_hw_mode_params hw_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800596
597/* FEATURE_WLAN_DIAG_SUPPORT */
598#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
599 /*
600 * Since the session is not created yet, sending NULL.
601 * The response should have the correct state.
602 */
603 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
604 NULL, 0, 0);
605#endif /* FEATURE_WLAN_DIAG_SUPPORT */
606
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700607 pe_debug("Received START_BSS_REQ");
Krunal Sonib37bb352016-12-20 14:12:21 -0800608 size = sizeof(tSirSmeStartBssReq);
609 sme_start_bss_req = qdf_mem_malloc(size);
610 if (NULL == sme_start_bss_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700611 pe_err("Allocate Memory fail for LimStartBssReq");
Krunal Sonib37bb352016-12-20 14:12:21 -0800612 /* Send failure response to host */
613 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
614 goto free;
615 }
616 qdf_mem_copy(sme_start_bss_req, msg_buf, sizeof(tSirSmeStartBssReq));
617 sme_session_id = sme_start_bss_req->sessionId;
618 sme_transaction_id = sme_start_bss_req->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800619
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800620 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
621 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800622 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
623 sme_start_bss_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700624 pe_warn("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800625 ret_code = eSIR_SME_INVALID_PARAMETERS;
626 goto free;
627 }
628
629 /*
630 * This is the place where PE is going to create a session.
631 * If session is not existed, then create a new session
632 */
633 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800634 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800635 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700636 pe_warn("Session Already exists for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800637 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
638 session = NULL;
639 goto free;
640 } else {
641 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800642 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800643 &session_id, mac_ctx->lim.maxStation,
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +0530644 sme_start_bss_req->bssType,
645 sme_start_bss_req->sessionId);
646 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700647 pe_warn("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800648 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
649 goto free;
650 }
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +0530651
652 /* Update the beacon/probe filter in mac_ctx */
653 lim_set_bcn_probe_filter(mac_ctx, session,
654 &sme_start_bss_req->ssId,
655 sme_start_bss_req->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800656 }
657
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700658 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
659 /* Probe resp add ie */
660 lim_start_bss_update_add_ie_buffer(mac_ctx,
661 &session->addIeParams.probeRespData_buff,
662 &session->addIeParams.probeRespDataLen,
663 sme_start_bss_req->addIeParams.
664 probeRespData_buff,
665 sme_start_bss_req->addIeParams.
666 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800667
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700668 /* Probe Beacon add ie */
669 lim_start_bss_update_add_ie_buffer(mac_ctx,
670 &session->addIeParams.probeRespBCNData_buff,
671 &session->addIeParams.probeRespBCNDataLen,
672 sme_start_bss_req->addIeParams.
673 probeRespBCNData_buff,
674 sme_start_bss_req->addIeParams.
675 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800676
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700677 /* Assoc resp IE */
678 lim_start_bss_update_add_ie_buffer(mac_ctx,
679 &session->addIeParams.assocRespData_buff,
680 &session->addIeParams.assocRespDataLen,
681 sme_start_bss_req->addIeParams.
682 assocRespData_buff,
683 sme_start_bss_req->addIeParams.
684 assocRespDataLen);
685 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800686 /* Store the session related params in newly created session */
687 session->pLimStartBssReq = sme_start_bss_req;
688
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800689 session->transactionId = sme_start_bss_req->transactionId;
690
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530691 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800692 &(sme_start_bss_req->htConfig),
693 sizeof(session->htConfig));
694
Sandeep Puligilla98917432016-06-10 13:50:28 -0700695 qdf_mem_copy(&(session->vht_config),
696 &(sme_start_bss_req->vht_config),
697 sizeof(session->vht_config));
698
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800699 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800700 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800701
702 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530703 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800704 (uint8_t *) &sme_start_bss_req->ssId,
705 (sme_start_bss_req->ssId.length + 1));
706
707 session->bssType = sme_start_bss_req->bssType;
708
709 session->nwType = sme_start_bss_req->nwType;
710
711 session->beaconParams.beaconInterval =
712 sme_start_bss_req->beaconInterval;
713
714 /* Store the channel number in session Table */
715 session->currentOperChannel =
716 sme_start_bss_req->channelId;
717
718 /* Store Persona */
719 session->pePersona = sme_start_bss_req->bssPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +0530720 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800721 FL("PE PERSONA=%d"), session->pePersona);
722
723 /* Update the phymode */
724 session->gLimPhyMode = sme_start_bss_req->nwType;
725
726 session->maxTxPower =
727 cfg_get_regulatory_max_transmit_power(mac_ctx,
728 session->currentOperChannel);
729 /* Store the dot 11 mode in to the session Table */
730 session->dot11mode = sme_start_bss_req->dot11mode;
731#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
732 session->cc_switch_mode =
733 sme_start_bss_req->cc_switch_mode;
734#endif
735 session->htCapability =
736 IS_DOT11_MODE_HT(session->dot11mode);
737 session->vhtCapability =
738 IS_DOT11_MODE_VHT(session->dot11mode);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800739
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700740 pe_debug("HT[%d], VHT[%d]",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800741 session->htCapability, session->vhtCapability);
742
743 if (IS_DOT11_MODE_HE(session->dot11mode)) {
744 lim_update_session_he_capable(mac_ctx, session);
745 lim_copy_bss_he_cap(session, sme_start_bss_req);
746 }
747
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800748 session->txLdpcIniFeatureEnabled =
749 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800750#ifdef WLAN_FEATURE_11W
751 session->limRmfEnabled =
752 sme_start_bss_req->pmfCapable ? 1 : 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700753 pe_debug("Session RMF enabled: %d", session->limRmfEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800754#endif
755
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530756 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800757 (void *)&sme_start_bss_req->operationalRateSet,
758 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530759 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800760 (void *)&sme_start_bss_req->extendedRateSet,
761 sizeof(tSirMacRateSet));
762
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700763 if (IS_5G_CH(session->currentOperChannel))
764 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
765 else
766 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
767
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800768 switch (sme_start_bss_req->bssType) {
769 case eSIR_INFRA_AP_MODE:
770 lim_configure_ap_start_bss_session(mac_ctx, session,
771 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700772 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700773 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700774 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700775 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800776 break;
777 case eSIR_IBSS_MODE:
778 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
779 lim_get_short_slot_from_phy_mode(mac_ctx, session,
780 session->gLimPhyMode,
781 &session->shortSlotTimeSupported);
782
783 /*
784 * initialize to "OPEN".
785 * will be updated upon key installation
786 */
787 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700788 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800789
790 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700791 case eSIR_NDI_MODE:
792 session->limSystemRole = eLIM_NDI_ROLE;
793 break;
794
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800795
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796 /*
797 * There is one more mode called auto mode.
798 * which is used no where
799 */
800
801 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
802
803 default:
804 /* not used anywhere...used in scan function */
805 break;
806 }
807
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700808 pe_debug("persona - %d, nss - %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700809 session->pePersona, session->vdev_nss);
810 session->nss = session->vdev_nss;
Kiran Kumar Lokerebc6fb2f2018-05-09 19:04:11 -0700811 if (!mac_ctx->roam.configParam.enable2x2)
812 session->nss = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700814 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815 * parsed (Re)Assoc request structure
816 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700817 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800818 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530819 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700820 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800821 if (NULL == session->parsedAssocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700822 pe_warn("AllocateMemory() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800823 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
824 goto free;
825 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800826 }
827
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700828 if (!sme_start_bss_req->channelId &&
829 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700830 pe_err("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800831 ret_code = eSIR_SME_INVALID_PARAMETERS;
832 goto free;
833 }
834 channel_number = sme_start_bss_req->channelId;
835#ifdef QCA_HT_2040_COEX
836 if (sme_start_bss_req->obssEnabled)
837 session->htSupportedChannelWidthSet =
838 session->htCapability;
839 else
840#endif
841 session->htSupportedChannelWidthSet =
842 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
843 session->htSecondaryChannelOffset =
844 sme_start_bss_req->sec_ch_offset;
845 session->htRecommendedTxWidthSet =
846 (session->htSecondaryChannelOffset) ? 1 : 0;
Abhishek Singh4294f802017-08-10 16:37:07 +0530847 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848 FL("cbMode %u"), sme_start_bss_req->cbMode);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800849 if (lim_is_session_he_capable(session) ||
850 session->vhtCapability || session->htCapability) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800851 chanwidth = sme_start_bss_req->vht_channel_width;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700852 pe_debug("vht_channel_width %u htSupportedChannelWidthSet %d",
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800853 sme_start_bss_req->vht_channel_width,
854 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800855 session->ch_width = chanwidth;
856 if (session->htSupportedChannelWidthSet) {
857 session->ch_center_freq_seg0 =
858 sme_start_bss_req->center_freq_seg0;
859 session->ch_center_freq_seg1 =
860 sme_start_bss_req->center_freq_seg1;
861 } else {
862 session->ch_center_freq_seg0 = 0;
863 session->ch_center_freq_seg1 = 0;
864 }
865 }
gaurank kathpaliad88ef882018-08-14 15:20:11 +0530866 if (policy_mgr_is_hw_dbs_capable(mac_ctx->psoc) &&
867 (policy_mgr_get_current_hw_mode(mac_ctx->psoc, &hw_mode) ==
868 QDF_STATUS_SUCCESS) &&
869 hw_mode.dbs_cap) {
870 session->nss = 1;
871 pe_debug("HW is in DBS mode. Nss set to [%d]",
872 session->nss);
873 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800874 if (session->vhtCapability &&
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800875 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800876 session->nss = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700877 pe_debug("nss set to [%d]", session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800878 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700879 pe_debug("vht su tx bformer %d",
Krunal Soni53993f72016-07-08 18:20:03 -0700880 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800881
882 /* Delete pre-auth list if any */
883 lim_delete_pre_auth_list(mac_ctx);
884
885 /*
886 * keep the RSN/WPA IE information in PE Session Entry
887 * later will be using this to check when received (Re)Assoc req
888 */
889 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
890 &sme_start_bss_req->rsnIE, session);
891
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700892 if (LIM_IS_AP_ROLE(session) ||
893 LIM_IS_IBSS_ROLE(session) ||
894 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800895 session->gLimProtectionControl =
896 sme_start_bss_req->protEnabled;
897 /*
898 * each byte will have the following info
899 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
900 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
901 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530902 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800903 (void *)&sme_start_bss_req->ht_capab,
904 sizeof(uint16_t));
905 /* Initialize WPS PBC session link list */
906 session->pAPWPSPBCSession = NULL;
907 }
908 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530909 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800910 if (NULL == mlm_start_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700911 pe_err("Allocate Memory failed for mlmStartReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800912 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
913 goto free;
914 }
915
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800916 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530917 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800918 (uint8_t *) &sme_start_bss_req->ssId,
919 sme_start_bss_req->ssId.length + 1);
920 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
921 mlm_start_req->obssProtEnabled =
922 sme_start_bss_req->obssProtEnabled;
923
924 mlm_start_req->bssType = session->bssType;
925
926 /* Fill PE session Id from the session Table */
927 mlm_start_req->sessionId = session->peSessionId;
928
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700929 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
930 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800931 /*
932 * Copy the BSSId from sessionTable to
933 * mlmStartReq struct
934 */
935 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
936 } else {
937 /* ibss mode */
938 mac_ctx->lim.gLimIbssCoalescingHappened = false;
939
940 ret_status = wlan_cfg_get_int(mac_ctx,
941 WNI_CFG_IBSS_AUTO_BSSID,
942 &auto_gen_bssid);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700943 if (ret_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700944 pe_err("Get Auto Gen BSSID fail,Status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800945 ret_status);
Abhishek Singh4294f802017-08-10 16:37:07 +0530946 ret_code = eSIR_LOGE_EXCEPTION;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800947 goto free;
948 }
949
950 if (!auto_gen_bssid) {
951 /*
952 * We're not auto generating BSSID.
953 * Instead, get it from session entry
954 */
955 sir_copy_mac_addr(mlm_start_req->bssId,
956 session->bssId);
957 /*
958 * Start IBSS group BSSID
959 * Auto Generating BSSID.
960 */
961 auto_gen_bssid = ((mlm_start_req->bssId[0] &
962 0x01) ? true : false);
963 }
964
965 if (auto_gen_bssid) {
966 /*
967 * if BSSID is not any uc id.
968 * then use locally generated BSSID.
969 * Autogenerate the BSSID
970 */
971 lim_get_random_bssid(mac_ctx,
972 mlm_start_req->bssId);
973 mlm_start_req->bssId[0] = 0x02;
974
975 /*
976 * Copy randomly generated BSSID
977 * to the session Table
978 */
979 sir_copy_mac_addr(session->bssId,
980 mlm_start_req->bssId);
981 }
982 }
983 /* store the channel num in mlmstart req structure */
984 mlm_start_req->channelNumber = session->currentOperChannel;
985 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
986 mlm_start_req->beaconPeriod =
987 session->beaconParams.beaconInterval;
Arif Hussain671a1902017-03-17 09:08:32 -0700988 mlm_start_req->cac_duration_ms =
989 sme_start_bss_req->cac_duration_ms;
990 mlm_start_req->dfs_regdomain =
991 sme_start_bss_req->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800992 if (LIM_IS_AP_ROLE(session)) {
993 mlm_start_req->dtimPeriod = session->dtimPeriod;
994 mlm_start_req->wps_state = session->wps_state;
995
996 } else {
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530997 val = mac_ctx->mlme_cfg->sap_cfg.dtim_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800998 mlm_start_req->dtimPeriod = (uint8_t) val;
999 }
1000
Karthik Kantamneni22dd0f62018-08-07 14:53:50 +05301001 mlm_start_req->cfParamSet.cfpPeriod =
1002 mac_ctx->mlme_cfg->rates.cfp_period;
1003 mlm_start_req->cfParamSet.cfpMaxDuration =
1004 mac_ctx->mlme_cfg->rates.cfp_max_duration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001005
1006 /*
1007 * this may not be needed anymore now,
1008 * as rateSet is now included in the
1009 * session entry and MLM has session context.
1010 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301011 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012 (void *)&session->rateSet,
1013 sizeof(tSirMacRateSet));
1014
1015 /* Now populate the 11n related parameters */
1016 mlm_start_req->nwType = session->nwType;
1017 mlm_start_req->htCapable = session->htCapability;
1018
1019 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1020 /* Unused */
1021 mlm_start_req->dualCTSProtection =
1022 mac_ctx->lim.gHTDualCTSProtection;
1023 mlm_start_req->txChannelWidthSet =
1024 session->htRecommendedTxWidthSet;
1025
1026 session->limRFBand = lim_get_rf_band(channel_number);
1027
1028 /* Initialize 11h Enable Flag */
1029 session->lim11hEnable = 0;
gaolez76d2a162017-03-21 19:23:58 +08001030 if (mlm_start_req->bssType != eSIR_IBSS_MODE &&
1031 (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001032 BAND_5G == session->limRFBand)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001033 if (wlan_cfg_get_int(mac_ctx,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001034 WNI_CFG_11H_ENABLED, &val) != QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001035 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001036 else
1037 session->lim11hEnable = val;
1038
1039 if (session->lim11hEnable &&
1040 (eSIR_INFRA_AP_MODE ==
1041 mlm_start_req->bssType)) {
Abhishek Singhdfa69c32018-08-30 15:39:34 +05301042 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001043 wlan_cfg_get_int(mac_ctx,
1044 WNI_CFG_DFS_MASTER_ENABLED,
1045 &val);
1046 session->lim11hEnable = val;
1047 }
Abhishek Singhdfa69c32018-08-30 15:39:34 +05301048 if (QDF_IS_STATUS_ERROR(qdf_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001050 pe_err("Get Fail, CFG DFS ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051 }
1052
1053 if (!session->lim11hEnable) {
1054 if (cfg_set_int(mac_ctx,
1055 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001056 QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001057 /*
1058 * Failed to set the CFG param
1059 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1060 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001061 pe_err("Set LOCAL_POWER_CONSTRAINT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001062 }
1063
Jiachao Wu712d4fd2017-08-23 16:52:34 +08001064 mlm_start_req->beacon_tx_rate = session->beacon_tx_rate;
1065
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001066 session->limPrevSmeState = session->limSmeState;
1067 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1068 MTRACE(mac_trace
1069 (mac_ctx, TRACE_CODE_SME_STATE,
1070 session->peSessionId,
1071 session->limSmeState));
1072
Abhishek Singhdfa69c32018-08-30 15:39:34 +05301073 qdf_status = lim_send_start_vdev_req(session, mlm_start_req);
1074 if (QDF_IS_STATUS_ERROR(qdf_status))
1075 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001076 return;
1077 } else {
1078
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001079 pe_err("Received unexpected START_BSS_REQ, in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001080 mac_ctx->lim.gLimSmeState);
1081 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001082 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001083 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1084
1085free:
1086 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001087 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001088 session->pLimStartBssReq = NULL;
1089 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001090 if (NULL != sme_start_bss_req)
1091 qdf_mem_free(sme_start_bss_req);
1092 if (NULL != mlm_start_req)
1093 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001094 if (NULL != session) {
1095 pe_delete_session(mac_ctx, session);
1096 session = NULL;
1097 }
1098 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1099 session, sme_session_id, sme_transaction_id);
1100}
1101
1102/**
1103 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1104 *
1105 * @pMac: Global MAC context
1106 * @pMsg: Message pointer
1107 *
1108 * Wrapper for the function __lim_handle_sme_start_bss_request
1109 * This message will be defered until softmac come out of
1110 * scan mode or if we have detected radar on the current
1111 * operating channel.
1112 *
1113 * return true - If we consumed the buffer
1114 * false - If have defered the message.
1115 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001116static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1117 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001118{
1119 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1120 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1121 /**
1122 * If message defered, buffer is not consumed yet.
1123 * So return false
1124 */
1125 return false;
1126 }
1127
1128 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1129 return true;
1130}
1131
1132/**
1133 * lim_get_random_bssid()
1134 *
1135 * FUNCTION:This function is called to process generate the random number for bssid
1136 * This function is called to process SME_SCAN_REQ message
1137 * from HDD or upper layer application.
1138 *
1139 * LOGIC:
1140 *
1141 * ASSUMPTIONS:
1142 *
1143 * NOTE:
1144 * 1. geneartes the unique random number for bssid in ibss
1145 *
1146 * @param pMac Pointer to Global MAC structure
1147 * @param *data Pointer to bssid buffer
1148 * @return None
1149 */
1150void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1151{
1152 uint32_t random[2];
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001153
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001154 random[0] = tx_time_get();
1155 random[0] |= (random[0] << 15);
1156 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301157 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001158}
1159
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001160/**
1161 * __lim_process_clear_dfs_channel_list()
1162 *
1163 ***FUNCTION:
Jeff Johnsonc00ae5b2018-05-06 16:06:35 -07001164 ***Clear DFS channel list when country is changed/acquired.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001165 .*This message is sent from SME.
1166 *
1167 ***LOGIC:
1168 *
1169 ***ASSUMPTIONS:
1170 *
1171 ***NOTE:
1172 *
1173 * @param pMac Pointer to Global MAC structure
1174 * @param *pMsgBuf A pointer to the SME message buffer
1175 * @return None
1176 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001177static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1178 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001179{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301180 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001181}
1182
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301183#ifdef WLAN_FEATURE_SAE
1184
1185/**
1186 * lim_update_sae_config()- This API update SAE session info to csr config
1187 * from join request.
1188 * @session: PE session
1189 * @sme_join_req: pointer to join request
1190 *
1191 * Return: None
1192 */
1193static void lim_update_sae_config(tpPESession session,
1194 tpSirSmeJoinReq sme_join_req)
1195{
1196 session->sae_pmk_cached = sme_join_req->sae_pmk_cached;
1197
1198 pe_debug("pmk_cached %d for BSSID=" MAC_ADDRESS_STR,
1199 session->sae_pmk_cached,
1200 MAC_ADDR_ARRAY(sme_join_req->bssDescription.bssId));
1201}
1202#else
1203static inline void lim_update_sae_config(tpPESession session,
1204 tpSirSmeJoinReq sme_join_req)
1205{}
1206#endif
1207
1208
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001209/**
1210 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1211 * @mac_ctx: Pointer to Global MAC structure
1212 * @msg_buf: A pointer to the SME message buffer
1213 *
1214 * This function is called to process SME_JOIN_REQ message
1215 * from HDD or upper layer application.
1216 *
1217 * Return: None
1218 */
1219static void
1220__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1221{
1222 tpSirSmeJoinReq sme_join_req = NULL;
1223 tLimMlmJoinReq *mlm_join_req;
1224 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1225 uint32_t val = 0;
1226 uint16_t n_size;
1227 uint8_t session_id;
1228 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301229 uint8_t sme_session_id = 0;
1230 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001231 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001232 uint16_t ie_len;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001233 const uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001234 tSirBssDescription *bss_desc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001235
Arif Hussain995fcaf2016-07-18 11:28:22 -07001236 if (!mac_ctx || !msg_buf) {
1237 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1238 FL("JOIN REQ with invalid data"));
1239 return;
1240 }
1241
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001242/* FEATURE_WLAN_DIAG_SUPPORT */
1243#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1244 /*
1245 * Not sending any session, since it is not created yet.
1246 * The response whould have correct state.
1247 */
1248 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1249#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1250
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001251 /*
1252 * Expect Join request in idle state.
1253 * Reassociate request is expected in link established state.
1254 */
1255
1256 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1257 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1258 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1259 msg_buf);
1260
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301261 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001262 if (NULL == sme_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001263 pe_err("AllocateMemory failed for sme_join_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001264 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301265 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001266 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301267 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001268 n_size);
1269
1270 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1271 /* Received invalid eWNI_SME_JOIN_REQ */
1272 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001273 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001274 sme_join_req->sessionId);
1275 ret_code = eSIR_SME_INVALID_PARAMETERS;
1276 goto end;
1277 }
1278
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001279 /*
1280 * Update the capability here itself as this is used in
1281 * lim_extract_ap_capability() below. If not updated issues
1282 * like not honoring power constraint on 1st association after
1283 * driver loading might occur.
1284 */
1285 lim_update_rrm_capability(mac_ctx, sme_join_req);
1286
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001287 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001288 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001289 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001290 &session_id);
1291
1292 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001293 pe_err("Session(%d) Already exists for BSSID: "
1294 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001295 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001296 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001297 session->limSmeState);
1298
1299 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1300 session->smeSessionId == sme_join_req->sessionId) {
1301 /*
1302 * Received eWNI_SME_JOIN_REQ for same
1303 * BSS as currently associated.
1304 * Log the event and send success
1305 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001306 pe_warn("SessionId: %d", session_id);
1307 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 /* Send Join success response to host */
1309 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1310 session = NULL;
1311 goto end;
1312 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001313 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001314 ret_code = eSIR_SME_REFUSED;
1315 session = NULL;
1316 goto end;
1317 }
1318 } else {
1319 /*
1320 * Session Entry does not exist for given BSSId
1321 * Try to Create a new session
1322 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001323 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001324 &session_id, mac_ctx->lim.maxStation,
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +05301325 eSIR_INFRASTRUCTURE_MODE,
1326 sme_join_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001327 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001328 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001329 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1330 goto end;
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301331 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001332 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001333 session_id);
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301334 }
1335
1336 /* Update the beacon/probe filter in mac_ctx */
1337 lim_set_bcn_probe_filter(mac_ctx, session,
1338 &sme_join_req->ssId,
1339 bss_desc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001340 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001341 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Arif Hussain6686c0b2018-08-21 18:21:05 -07001342 session->enable_session_twt_support =
1343 sme_join_req->enable_session_twt_support;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001344 /*
1345 * Store Session related parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001346 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001347
1348 /* store the smejoin req handle in session table */
1349 session->pLimJoinReq = sme_join_req;
1350
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001351 /* Store SME transaction Id in session Table */
1352 session->transactionId = sme_join_req->transactionId;
1353
1354 /* Store beaconInterval */
1355 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001356 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001357
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301358 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001359 sizeof(session->htConfig));
1360
Sandeep Puligilla98917432016-06-10 13:50:28 -07001361 qdf_mem_copy(&(session->vht_config),
1362 &(sme_join_req->vht_config),
1363 sizeof(session->vht_config));
1364
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001365 /* Copying of bssId is already done, while creating session */
1366 sir_copy_mac_addr(session->selfMacAddr,
1367 sme_join_req->selfMacAddr);
1368 session->bssType = sme_join_req->bsstype;
1369
1370 session->statypeForBss = STA_ENTRY_PEER;
1371 session->limWmeEnabled = sme_join_req->isWMEenabled;
1372 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301373 session->wps_registration = sme_join_req->wps_registration;
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001374 session->he_with_wep_tkip = sme_join_req->he_with_wep_tkip;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001375
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301376 session->enable_bcast_probe_rsp =
1377 sme_join_req->enable_bcast_probe_rsp;
1378
Jeff Johnson179fd8a2018-05-11 14:20:05 -07001379 /* Store vendor specific IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001380 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1382
Naveen Rawat08db88f2017-09-08 15:07:48 -07001383 vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001384 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001385 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001386
1387 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001388 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001389 session->isCiscoVendorAP = true;
1390 } else {
1391 session->isCiscoVendorAP = false;
1392 }
1393
1394 /* Copy the dot 11 mode in to the session table */
1395
1396 session->dot11mode = sme_join_req->dot11mode;
1397#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1398 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1399#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001400 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1402 session->enableHtSmps = sme_join_req->enableHtSmps;
1403 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001404 session->send_smps_action =
1405 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001406 /*
1407 * By default supported NSS 1x1 is set to true
1408 * and later on updated while determining session
1409 * supported rates which is the intersection of
1410 * self and peer rates
1411 */
1412 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301413 /*Store Persona */
1414 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001415 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 -08001416 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001417 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001418 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301419 session->supported_nss_1x1,
1420 session->pePersona,
1421 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001422
1423 /*Store Persona */
1424 session->pePersona = sme_join_req->staPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +05301425 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301426 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d force_24ghz_in_ht20 %d"),
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001427 session->pePersona, sme_join_req->cbMode,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301428 session->nwType, session->dot11mode,
1429 sme_join_req->force_24ghz_in_ht20);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001430
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001431 /* Copy The channel Id to the session Table */
1432 session->currentOperChannel = bss_desc->channelId;
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301433
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001434 session->vhtCapability =
1435 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001436 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301437 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001438 session->vht_config.su_beam_formee =
1439 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001441 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001442 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001443 session->enableVhtpAid =
1444 sme_join_req->enableVhtpAid;
1445 session->enableVhtGid =
1446 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001447 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001448 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001449 }
Krunal Soni53993f72016-07-08 18:20:03 -07001450
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001451 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301452 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001453 session->vht_config.su_beam_formee,
1454 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001455 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001456 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001457 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001458 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301459 session->force_24ghz_in_ht20 =
1460 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001461 /* cbMode is already merged value of peer and self -
1462 * done by csr in csr_get_cb_mode_from_ies */
1463 session->htSupportedChannelWidthSet =
1464 (sme_join_req->cbMode) ? 1 : 0;
1465 session->htRecommendedTxWidthSet =
1466 session->htSupportedChannelWidthSet;
1467 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1468
1469 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1470 session->ch_center_freq_seg0 =
1471 session->currentOperChannel - 2;
1472 session->ch_width = CH_WIDTH_40MHZ;
1473 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1474 sme_join_req->cbMode) {
1475 session->ch_center_freq_seg0 =
1476 session->currentOperChannel + 2;
1477 session->ch_width = CH_WIDTH_40MHZ;
1478 } else {
1479 session->ch_center_freq_seg0 = 0;
1480 session->ch_width = CH_WIDTH_20MHZ;
1481 }
1482
Naveen Rawataeca1b92017-10-16 16:55:31 -07001483 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1484 lim_update_session_he_capable(mac_ctx, session);
1485 lim_copy_join_req_he_cap(session, sme_join_req);
1486 }
1487
1488
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001489 /* Record if management frames need to be protected */
1490#ifdef WLAN_FEATURE_11W
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +05301491 if ((eSIR_ED_AES_128_CMAC ==
1492 sme_join_req->MgmtEncryptionType) ||
1493 (eSIR_ED_AES_GMAC_128 == sme_join_req->MgmtEncryptionType) ||
1494 (eSIR_ED_AES_GMAC_256 == sme_join_req->MgmtEncryptionType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001495 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001496 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001497 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001498#endif
1499
1500#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001501 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001502#endif
1503
1504 /* Copy the SSID from smejoinreq to session entry */
1505 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301506 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001507 session->ssId.length);
1508
1509 /*
1510 * Determin 11r or ESE connection based on input from SME
1511 * which inturn is dependent on the profile the user wants
1512 * to connect to, So input is coming from supplicant
1513 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001514 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001515#ifdef FEATURE_WLAN_ESE
1516 session->isESEconnection = sme_join_req->isESEconnection;
1517#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001518 session->isFastTransitionEnabled =
1519 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001520
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521 session->isFastRoamIniFeatureEnabled =
1522 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001523 session->txLdpcIniFeatureEnabled =
1524 sme_join_req->txLdpcIniFeatureEnabled;
1525
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301526 lim_update_fils_config(session, sme_join_req);
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301527 lim_update_sae_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001528 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1529 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001530 } else {
1531 /*
1532 * Throw an error and return and make
1533 * sure to delete the session.
1534 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001535 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001536 session->bssType);
1537 ret_code = eSIR_SME_INVALID_PARAMETERS;
1538 goto end;
1539 }
1540
1541 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301542 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001543 &sme_join_req->addIEScan, sizeof(tSirAddie));
1544
1545 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301546 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001547 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1548
1549 val = sizeof(tLimMlmJoinReq) +
1550 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301551 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001552 if (NULL == mlm_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001553 pe_err("AllocateMemory failed for mlmJoinReq");
Nitesh Shah0102cac2016-07-13 14:38:30 +05301554 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1555 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001556 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001557
1558 /* PE SessionId is stored as a part of JoinReq */
1559 mlm_join_req->sessionId = session->peSessionId;
1560
1561 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1562 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001563 QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001564 pe_err("couldn't retrieve JoinFailureTimer value"
1565 " setting to default value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001566 mlm_join_req->joinFailureTimeout =
1567 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1568 }
1569
1570 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301571 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001572 (void *)&sme_join_req->operationalRateSet,
1573 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301574 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001575 (void *)&sme_join_req->extendedRateSet,
1576 sizeof(tSirMacRateSet));
1577 /*
1578 * this may not be needed anymore now, as rateSet is now
1579 * included in the session entry and MLM has session context.
1580 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301581 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582 (void *)&session->rateSet,
1583 sizeof(tSirMacRateSet));
1584
1585 session->encryptType = sme_join_req->UCEncryptionType;
1586
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301587 session->supported_nss_1x1 = sme_join_req->supported_nss_1x1;
1588 session->vdev_nss = sme_join_req->vdev_nss;
1589 session->nss = sme_join_req->nss;
1590 session->nss_forced_1x1 = sme_join_req->nss_forced_1x1;
1591
1592 pe_debug("nss %d, vdev_nss %d, supported_nss_1x1 %d",
1593 session->nss,
1594 session->vdev_nss,
1595 session->supported_nss_1x1);
1596
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001597 mlm_join_req->bssDescription.length =
1598 session->pLimJoinReq->bssDescription.length;
1599
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301600 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001601 (uint8_t *)
1602 &session->pLimJoinReq->bssDescription.bssId,
1603 session->pLimJoinReq->bssDescription.length + 2);
1604
1605 session->limCurrentBssCaps =
1606 session->pLimJoinReq->bssDescription.capabilityInfo;
1607
1608 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1609 session->currentOperChannel);
1610 local_power_constraint = reg_max;
1611
1612 lim_extract_ap_capability(mac_ctx,
1613 (uint8_t *)
1614 session->pLimJoinReq->bssDescription.ieFields,
1615 lim_get_ielen_from_bss_description(
1616 &session->pLimJoinReq->bssDescription),
1617 &session->limCurrentBssQosCaps,
1618 &session->limCurrentBssPropCap,
1619 &session->gLimCurrentBssUapsd,
1620 &local_power_constraint, session);
1621
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001622 session->maxTxPower = lim_get_max_tx_power(reg_max,
1623 local_power_constraint,
1624 mac_ctx->roam.configParam.nTxPowerCap);
Abhinav Kumard528d192018-03-09 17:31:12 +05301625 session->def_max_tx_pwr = session->maxTxPower;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301626
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001627 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301628 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001629
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301630 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1631 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1632 pe_debug("Update MaxTxPower in join Req to %d",
1633 sme_join_req->powerCap.maxTxPower);
1634 }
1635
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001636 if (session->gLimCurrentBssUapsd) {
1637 session->gUapsdPerAcBitmask =
1638 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001639 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001640 session->gUapsdPerAcBitmask);
1641
1642 /* resetting the dynamic uapsd mask */
1643 session->gUapsdPerAcDeliveryEnableMask = 0;
1644 session->gUapsdPerAcTriggerEnableMask = 0;
1645 }
1646
1647 session->limRFBand =
1648 lim_get_rf_band(session->currentOperChannel);
1649
1650 /* Initialize 11h Enable Flag */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001651 if (BAND_5G == session->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001652 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001653 &val) != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001654 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001655 session->lim11hEnable =
1656 WNI_CFG_11H_ENABLED_STADEF;
1657 } else {
1658 session->lim11hEnable = val;
1659 }
1660 } else {
1661 session->lim11hEnable = 0;
1662 }
1663
1664 /*
1665 * To care of the scenario when STA transitions from
1666 * IBSS to Infrastructure mode.
1667 */
1668 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1669
1670 session->limPrevSmeState = session->limSmeState;
1671 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1672 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1673 session->peSessionId,
1674 session->limSmeState));
1675
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001676 /* Indicate whether spectrum management is enabled */
1677 session->spectrumMgtEnabled =
1678 sme_join_req->spectrumMgtIndicator;
1679
1680 /* Enable the spectrum management if this is a DFS channel */
1681 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001682 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001683 session->currentOperChannel))
1684 session->spectrumMgtEnabled = true;
1685
1686 session->isOSENConnection = sme_join_req->isOSENConnection;
1687
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001688 /* Issue LIM_MLM_JOIN_REQ to MLM */
1689 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1690 (uint32_t *) mlm_join_req);
1691 return;
1692
1693 } else {
1694 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001695 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001696 mac_ctx->lim.gLimSmeState);
1697 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1698 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1699 session = NULL;
1700 goto end;
1701 }
1702
1703end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301704 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1705 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001706
1707 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301708 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001709 sme_join_req = NULL;
1710 if (NULL != session)
1711 session->pLimJoinReq = NULL;
1712 }
1713 if (ret_code != eSIR_SME_SUCCESS) {
1714 if (NULL != session) {
1715 pe_delete_session(mac_ctx, session);
1716 session = NULL;
1717 }
1718 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001719 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001720 sme_session_id, ret_code);
1721 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1722 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1723 sme_transaction_id);
1724}
1725
Amar Singhala297bfa2015-10-15 15:07:29 -07001726uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001727 uint8_t iniTxPower)
1728{
1729 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301730 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001731
Anurag Chouhan6d760662016-02-20 16:05:43 +05301732 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001733 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1734 maxTxPower = txPower;
1735 else if (txPower < MIN_TX_PWR_CAP)
1736 maxTxPower = MIN_TX_PWR_CAP;
1737 else
1738 maxTxPower = MAX_TX_PWR_CAP;
1739
1740 return maxTxPower;
1741}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001742
1743/**
1744 * __lim_process_sme_reassoc_req() - process reassoc req
1745 *
1746 * @mac_ctx: Pointer to Global MAC structure
1747 * @msg_buf: pointer to the SME message buffer
1748 *
1749 * This function is called to process SME_REASSOC_REQ message
1750 * from HDD or upper layer application.
1751 *
1752 * Return: None
1753 */
1754
1755static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
1756 uint32_t *msg_buf)
1757{
1758 uint16_t caps;
1759 uint32_t val;
1760 tpSirSmeJoinReq reassoc_req = NULL;
1761 tLimMlmReassocReq *mlm_reassoc_req;
1762 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1763 tpPESession session_entry = NULL;
1764 uint8_t session_id;
1765 uint8_t sme_session_id;
1766 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001767 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001768 uint32_t tele_bcn_en = 0;
1769 uint16_t size;
1770
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001771 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301772 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001773 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001774 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001775
1776 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1777 goto end;
1778 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301779 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001780
1781 if (!lim_is_sme_join_req_valid(mac_ctx,
1782 (tpSirSmeJoinReq)reassoc_req)) {
1783 /*
1784 * Received invalid eWNI_SME_REASSOC_REQ
1785 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001786 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787
1788 ret_code = eSIR_SME_INVALID_PARAMETERS;
1789 goto end;
1790 }
1791
1792 session_entry = pe_find_session_by_bssid(mac_ctx,
1793 reassoc_req->bssDescription.bssId,
1794 &session_id);
1795 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001796 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001797 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
1798 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001799 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001800 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
1801 &sme_session_id, &transaction_id);
1802 session_entry =
1803 pe_find_session_by_sme_session_id(mac_ctx,
1804 sme_session_id);
1805 if (session_entry != NULL)
1806 lim_handle_sme_join_result(mac_ctx,
1807 eSIR_SME_INVALID_PARAMETERS,
1808 eSIR_MAC_UNSPEC_FAILURE_STATUS,
1809 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001810 goto end;
1811 }
1812#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
1813 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001814 session_entry, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001815#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1816 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
1817
1818 /* Store the reassoc handle in the session Table */
1819 session_entry->pLimReAssocReq = reassoc_req;
1820
1821 session_entry->dot11mode = reassoc_req->dot11mode;
1822 session_entry->vhtCapability =
1823 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001824
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301825 if (session_entry->vhtCapability) {
1826 if (session_entry->pePersona == QDF_STA_MODE) {
1827 session_entry->vht_config.su_beam_formee =
1828 reassoc_req->vht_config.su_beam_formee;
1829 } else {
1830 reassoc_req->vht_config.su_beam_formee = 0;
1831 }
1832 session_entry->enableVhtpAid =
1833 reassoc_req->enableVhtpAid;
1834 session_entry->enableVhtGid =
1835 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001836 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301837 }
1838
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301839 session_entry->supported_nss_1x1 = reassoc_req->supported_nss_1x1;
1840 session_entry->vdev_nss = reassoc_req->vdev_nss;
1841 session_entry->nss = reassoc_req->nss;
1842 session_entry->nss_forced_1x1 = reassoc_req->nss_forced_1x1;
1843
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001844 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301845 session_entry->vhtCapability,
1846 session_entry->vht_config.su_beam_formee,
1847 session_entry->vht_config.su_beam_former);
1848
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001849 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
1850 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001851 session_entry->send_smps_action =
1852 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001853 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001854 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001855 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001856 session_entry->send_smps_action,
1857 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001858 /*
1859 * Reassociate request is expected
1860 * in link established state only.
1861 */
1862
1863 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001864 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
1865 /*
1866 * May be from 11r FT pre-auth. So lets check it
1867 * before we bail out
1868 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001869 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870 session_entry->peSessionId);
1871
1872 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301873 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001874 session_entry->limReAssocbssId,
1875 6)) {
1876 lim_print_mac_addr(mac_ctx,
1877 reassoc_req->bssDescription.
1878 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001879 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001880 ret_code = eSIR_SME_INVALID_PARAMETERS;
1881 goto end;
1882 }
1883
1884 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
1885 session_entry);
1886 return;
1887 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888 /*
1889 * Should not have received eWNI_SME_REASSOC_REQ
1890 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001891 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001892 session_entry->limSmeState);
1893 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
1894
1895 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1896 goto end;
1897 }
1898
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301899 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001900 session_entry->pLimReAssocReq->bssDescription.bssId,
1901 sizeof(tSirMacAddr));
1902
1903 session_entry->limReassocChannelId =
1904 session_entry->pLimReAssocReq->bssDescription.channelId;
1905
1906 session_entry->reAssocHtSupportedChannelWidthSet =
1907 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
1908 session_entry->reAssocHtRecommendedTxWidthSet =
1909 session_entry->reAssocHtSupportedChannelWidthSet;
1910 session_entry->reAssocHtSecondaryChannelOffset =
1911 session_entry->pLimReAssocReq->cbMode;
1912
1913 session_entry->limReassocBssCaps =
1914 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
1915 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1916 session_entry->currentOperChannel);
1917 local_pwr_constraint = reg_max;
1918
1919 lim_extract_ap_capability(mac_ctx,
1920 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
1921 lim_get_ielen_from_bss_description(
1922 &session_entry->pLimReAssocReq->bssDescription),
1923 &session_entry->limReassocBssQosCaps,
1924 &session_entry->limReassocBssPropCap,
1925 &session_entry->gLimCurrentBssUapsd,
1926 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05301927 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001928 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301929 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001930 /* Copy the SSID from session entry to local variable */
1931 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301932 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001933 reassoc_req->ssId.ssId,
1934 session_entry->limReassocSSID.length);
1935 if (session_entry->gLimCurrentBssUapsd) {
1936 session_entry->gUapsdPerAcBitmask =
1937 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001938 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001939 session_entry->gUapsdPerAcBitmask);
1940 }
1941
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301942 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001943 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001944 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001945
1946 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1947 goto end;
1948 }
1949
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301950 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001951 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
1952
1953 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
1954 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001955 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001956 pe_err("could not retrieve ReassocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001957
1958 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001959 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001960 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301961
1962 lim_update_caps_info_for_bss(mac_ctx, &caps,
1963 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001964 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301965
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001966 mlm_reassoc_req->capabilityInfo = caps;
1967
1968 /* Update PE session_id */
1969 mlm_reassoc_req->sessionId = session_id;
1970
1971 /*
1972 * If telescopic beaconing is enabled, set listen interval to
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05301973 * CFG_TELE_BCN_MAX_LI
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001974 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001975
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05301976 tele_bcn_en = mac_ctx->mlme_cfg->sap_cfg.tele_bcn_wakeup_en;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001977
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05301978 if (tele_bcn_en)
1979 val = mac_ctx->mlme_cfg->sap_cfg.tele_bcn_max_li;
1980 else
1981 val = mac_ctx->mlme_cfg->sap_cfg.listen_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001982
1983 mlm_reassoc_req->listenInterval = (uint16_t) val;
1984
1985 /* Indicate whether spectrum management is enabled */
1986 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
1987
1988 /* Enable the spectrum management if this is a DFS channel */
1989 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001990 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991 session_entry->currentOperChannel))
1992 session_entry->spectrumMgtEnabled = true;
1993
1994 session_entry->limPrevSmeState = session_entry->limSmeState;
1995 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
1996
1997 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1998 session_entry->peSessionId,
1999 session_entry->limSmeState));
2000
2001 lim_post_mlm_message(mac_ctx,
2002 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2003 return;
2004end:
2005 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302006 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002007 if (session_entry)
2008 session_entry->pLimReAssocReq = NULL;
2009 }
2010
2011 if (session_entry) {
2012 /*
2013 * error occurred after we determined the session so extract
2014 * session and transaction info from there
2015 */
2016 sme_session_id = session_entry->smeSessionId;
2017 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002018 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002019 /*
2020 * error occurred before or during the time we determined
2021 * the session so extract the session and transaction info
2022 * from the message
2023 */
2024 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2025 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002026 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002027 /*
2028 * Send Reassoc failure response to host
2029 * (note session_entry may be NULL, but that's OK)
2030 */
2031 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2032 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2033 session_entry, sme_session_id,
2034 transaction_id);
2035}
2036
2037bool send_disassoc_frame = 1;
2038/**
2039 * __lim_process_sme_disassoc_req()
2040 *
2041 ***FUNCTION:
2042 * This function is called to process SME_DISASSOC_REQ message
2043 * from HDD or upper layer application.
2044 *
2045 ***LOGIC:
2046 *
2047 ***ASSUMPTIONS:
2048 *
2049 ***NOTE:
2050 *
2051 * @param pMac Pointer to Global MAC structure
2052 * @param *pMsgBuf A pointer to the SME message buffer
2053 * @return None
2054 */
2055
2056static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2057{
2058 uint16_t disassocTrigger, reasonCode;
2059 tLimMlmDisassocReq *pMlmDisassocReq;
2060 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2061 tSirSmeDisassocReq smeDisassocReq;
2062 tpPESession psessionEntry = NULL;
2063 uint8_t sessionId;
2064 uint8_t smesessionId;
2065 uint16_t smetransactionId;
2066
2067 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002068 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002069 return;
2070 }
2071
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302072 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002073 smesessionId = smeDisassocReq.sessionId;
2074 smetransactionId = smeDisassocReq.transactionId;
2075 if (!lim_is_sme_disassoc_req_valid(pMac,
2076 &smeDisassocReq,
2077 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002078 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002079 if (pMac->lim.gLimRspReqd) {
2080 pMac->lim.gLimRspReqd = false;
2081
2082 retCode = eSIR_SME_INVALID_PARAMETERS;
2083 disassocTrigger = eLIM_HOST_DISASSOC;
2084 goto sendDisassoc;
2085 }
2086
2087 return;
2088 }
2089
2090 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002091 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002092 &sessionId);
2093 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002094 pe_err("session does not exist for given bssId "
2095 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002096 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002097 retCode = eSIR_SME_INVALID_PARAMETERS;
2098 disassocTrigger = eLIM_HOST_DISASSOC;
2099 goto sendDisassoc;
2100 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002101 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2102 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2104 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002105 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002106
2107#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2108 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2109 0, smeDisassocReq.reasonCode);
2110#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2111
2112 /* Update SME session Id and SME transaction ID */
2113
2114 psessionEntry->smeSessionId = smesessionId;
2115 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002116 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002117 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002118
2119 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2120 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002121 switch (psessionEntry->limSmeState) {
2122 case eLIM_SME_ASSOCIATED_STATE:
2123 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002124 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002125 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002126 psessionEntry->limPrevSmeState =
2127 psessionEntry->limSmeState;
2128 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002129 /* Delete all TDLS peers connected before leaving BSS */
2130 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002131 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2132 psessionEntry->peSessionId,
2133 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002134 break;
2135
2136 case eLIM_SME_WT_DEAUTH_STATE:
2137 /* PE shall still process the DISASSOC_REQ and proceed with
2138 * link tear down even if it had already sent a DEAUTH_IND to
2139 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2140 * its been set when PE entered WT_DEAUTH_STATE.
2141 */
2142 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2143 MTRACE(mac_trace
2144 (pMac, TRACE_CODE_SME_STATE,
2145 psessionEntry->peSessionId,
2146 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002147 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002148 break;
2149
2150 case eLIM_SME_WT_DISASSOC_STATE:
Jeff Johnson47d75242018-05-12 15:58:53 -07002151 /* PE Received a Disassoc frame. Normally it gets DISASSOC_CNF but it
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002152 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2153 * PE can continue processing DISASSOC_REQ and send the response instead
2154 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2155 * for disassoc frame.
2156 *
2157 * It will send a disassoc, which is ok. However, we can use the global flag
2158 * sendDisassoc to not send disassoc frame.
2159 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002160 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002161 break;
2162
2163 case eLIM_SME_JOIN_FAILURE_STATE: {
2164 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002165 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002166 if (pMac->lim.gLimRspReqd) {
2167 retCode = eSIR_SME_SUCCESS;
2168 disassocTrigger = eLIM_HOST_DISASSOC;
2169 goto sendDisassoc;
2170 }
2171 }
2172 break;
2173 default:
2174 /**
2175 * STA is not currently associated.
2176 * Log error and send response to host
2177 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002178 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002179 psessionEntry->limSmeState);
2180 lim_print_sme_state(pMac, LOGE,
2181 psessionEntry->limSmeState);
2182
2183 if (pMac->lim.gLimRspReqd) {
2184 if (psessionEntry->limSmeState !=
2185 eLIM_SME_WT_ASSOC_STATE)
2186 pMac->lim.gLimRspReqd = false;
2187
2188 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2189 disassocTrigger = eLIM_HOST_DISASSOC;
2190 goto sendDisassoc;
2191 }
2192
2193 return;
2194 }
2195
2196 break;
2197
2198 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002199 /* Fall through */
2200 break;
2201
2202 case eLIM_STA_IN_IBSS_ROLE:
2203 default:
2204 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002205 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002206 GET_LIM_SYSTEM_ROLE(psessionEntry));
2207
2208 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2209 disassocTrigger = eLIM_HOST_DISASSOC;
2210 goto sendDisassoc;
2211 } /* end switch (pMac->lim.gLimSystemRole) */
2212
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302213 disassocTrigger = eLIM_HOST_DISASSOC;
2214 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002215
2216 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002217 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002218 send_disassoc_frame = 0;
2219 }
2220 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002221 pe_debug("Sending Disasscoc with disassoc Trigger"
2222 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002223 disassocTrigger, reasonCode);
2224
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302225 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002226 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002227 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002228 return;
2229 }
2230
Anurag Chouhanc5548422016-02-24 18:33:27 +05302231 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002232 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002233
2234 pMlmDisassocReq->reasonCode = reasonCode;
2235 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2236
2237 /* Update PE session ID */
2238 pMlmDisassocReq->sessionId = sessionId;
2239
2240 lim_post_mlm_message(pMac,
2241 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2242 return;
2243
2244sendDisassoc:
2245 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002246 lim_send_sme_disassoc_ntf(pMac,
2247 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002248 retCode,
2249 disassocTrigger,
2250 1, smesessionId, smetransactionId,
2251 psessionEntry);
2252 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002253 lim_send_sme_disassoc_ntf(pMac,
2254 smeDisassocReq.peer_macaddr.bytes,
2255 retCode, disassocTrigger, 1,
2256 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002257
2258} /*** end __lim_process_sme_disassoc_req() ***/
2259
2260/** -----------------------------------------------------------------
2261 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2262
2263 This function is called to process SME_DISASSOC_CNF message
2264 from HDD or upper layer application.
2265
2266 \param pMac - global mac structure
2267 \param pStaDs - station dph hash node
2268 \return none
2269 \sa
2270 ----------------------------------------------------------------- */
2271static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2272{
2273 tSirSmeDisassocCnf smeDisassocCnf;
2274 uint16_t aid;
2275 tpDphHashNode pStaDs;
2276 tpPESession psessionEntry;
2277 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302278 uint32_t *msg = NULL;
2279 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002280
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302281 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002282 sizeof(struct sSirSmeDisassocCnf));
2283
2284 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002285 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002286 &sessionId);
2287 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002288 pe_err("session does not exist for given bssId");
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302289 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302290 smeDisassocCnf.sme_session_id,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302291 eSIR_SME_INVALID_SESSION,
2292 NULL);
2293 if (QDF_IS_STATUS_SUCCESS(status))
2294 lim_send_sme_disassoc_deauth_ntf(pMac,
2295 QDF_STATUS_SUCCESS,
2296 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002297 return;
2298 }
2299
2300 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002301 pe_err("received invalid SME_DISASSOC_CNF message");
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302302 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2303 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302304 eSIR_SME_INVALID_PARAMETERS,
2305 &smeDisassocCnf.bssid.bytes[0]);
2306 if (QDF_IS_STATUS_SUCCESS(status))
2307 lim_send_sme_disassoc_deauth_ntf(pMac,
2308 QDF_STATUS_SUCCESS,
2309 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002310 return;
2311 }
2312#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2313 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2314 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2315 psessionEntry,
2316 (uint16_t) smeDisassocCnf.statusCode, 0);
2317 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2318 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2319 psessionEntry,
2320 (uint16_t) smeDisassocCnf.statusCode, 0);
2321#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2322
2323 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2324 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002325 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2326 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2327 && (psessionEntry->limSmeState !=
2328 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002329 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002330 psessionEntry->limSmeState);
2331 lim_print_sme_state(pMac, LOGE,
2332 psessionEntry->limSmeState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302333 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302334 psessionEntry->smeSessionId,
2335 eSIR_SME_INVALID_STATE,
2336 &smeDisassocCnf.bssid.bytes[0]);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302337 if (QDF_IS_STATUS_SUCCESS(status))
2338 lim_send_sme_disassoc_deauth_ntf(pMac,
2339 QDF_STATUS_SUCCESS,
2340 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002341 return;
2342 }
2343 break;
2344
2345 case eLIM_AP_ROLE:
2346 /* Fall through */
2347 break;
2348
2349 case eLIM_STA_IN_IBSS_ROLE:
2350 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002351 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002352 GET_LIM_SYSTEM_ROLE(psessionEntry));
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302353 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2354 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302355 eSIR_SME_INVALID_STATE,
2356 &smeDisassocCnf.bssid.bytes[0]);
2357 if (QDF_IS_STATUS_SUCCESS(status))
2358 lim_send_sme_disassoc_deauth_ntf(pMac,
2359 QDF_STATUS_SUCCESS,
2360 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002361 return;
2362 }
2363
2364 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2365 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2366 LIM_IS_AP_ROLE(psessionEntry)) {
2367 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002368 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002369 &psessionEntry->dph.dphHashTable);
2370 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002371 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2372 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002373 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302374 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302375 psessionEntry->smeSessionId,
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05302376 eSIR_SME_INVALID_PARAMETERS,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302377 &smeDisassocCnf.bssid.bytes[0]);
2378 if (QDF_IS_STATUS_SUCCESS(status))
2379 lim_send_sme_disassoc_deauth_ntf(pMac,
2380 QDF_STATUS_SUCCESS,
2381 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002382 return;
2383 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302384
2385 if ((pStaDs->mlmStaContext.mlmState ==
2386 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2387 (pStaDs->mlmStaContext.mlmState ==
Arif Hussain5fa13782018-05-10 11:29:52 -07002388 eLIM_MLM_WT_DEL_BSS_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002389 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002390 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302391 pStaDs->mlmStaContext.mlmState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302392 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302393 psessionEntry->smeSessionId,
2394 eSIR_SME_SUCCESS,
2395 NULL);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302396 if (QDF_IS_STATUS_SUCCESS(status))
2397 lim_send_sme_disassoc_deauth_ntf(pMac,
2398 QDF_STATUS_SUCCESS,
2399 (uint32_t *)msg);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302400 return;
2401 }
2402
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002403 /* Delete FT session if there exists one */
2404 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002405 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2406
2407 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002408 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002409 }
2410
2411 return;
2412}
2413
2414/**
2415 * __lim_process_sme_deauth_req() - process sme deauth req
2416 * @mac_ctx: Pointer to Global MAC structure
2417 * @msg_buf: pointer to the SME message buffer
2418 *
2419 * This function is called to process SME_DEAUTH_REQ message
2420 * from HDD or upper layer application.
2421 *
2422 * Return: None
2423 */
2424
2425static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2426 uint32_t *msg_buf)
2427{
2428 uint16_t deauth_trigger, reason_code;
2429 tLimMlmDeauthReq *mlm_deauth_req;
2430 tSirSmeDeauthReq sme_deauth_req;
2431 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2432 tpPESession session_entry;
2433 uint8_t session_id; /* PE sessionId */
2434 uint8_t sme_session_id;
2435 uint16_t sme_transaction_id;
2436
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302437 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002438 sme_session_id = sme_deauth_req.sessionId;
2439 sme_transaction_id = sme_deauth_req.transactionId;
2440
2441 /*
2442 * We need to get a session first but we don't even know
2443 * if the message is correct.
2444 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002445 session_entry = pe_find_session_by_bssid(mac_ctx,
2446 sme_deauth_req.bssid.bytes,
2447 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002448 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002449 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002450 ret_code = eSIR_SME_INVALID_PARAMETERS;
2451 deauth_trigger = eLIM_HOST_DEAUTH;
2452 goto send_deauth;
2453 }
2454
2455 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2456 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002457 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002458 mac_ctx->lim.gLimRspReqd = false;
2459
2460 ret_code = eSIR_SME_INVALID_PARAMETERS;
2461 deauth_trigger = eLIM_HOST_DEAUTH;
2462 goto send_deauth;
2463 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002464 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2465 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002466 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2467 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002468 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002469#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2470 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2471 session_entry, 0, sme_deauth_req.reasonCode);
2472#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2473
2474 /* Update SME session ID and Transaction ID */
2475 session_entry->smeSessionId = sme_session_id;
2476 session_entry->transactionId = sme_transaction_id;
2477
2478 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2479 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002480 switch (session_entry->limSmeState) {
2481 case eLIM_SME_ASSOCIATED_STATE:
2482 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302483 /* Delete all TDLS peers connected before leaving BSS */
2484 lim_delete_tdls_peers(mac_ctx, session_entry);
Abhinav Kumarac12c762018-05-02 13:51:02 +05302485 /* fallthrough */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002486 case eLIM_SME_WT_ASSOC_STATE:
2487 case eLIM_SME_JOIN_FAILURE_STATE:
2488 case eLIM_SME_IDLE_STATE:
2489 session_entry->limPrevSmeState =
2490 session_entry->limSmeState;
2491 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2492 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2493 session_entry->peSessionId,
2494 session_entry->limSmeState));
2495 /* Send Deauthentication request to MLM below */
2496 break;
2497 case eLIM_SME_WT_DEAUTH_STATE:
2498 case eLIM_SME_WT_DISASSOC_STATE:
2499 /*
Jeff Johnson47d75242018-05-12 15:58:53 -07002500 * PE Received a Deauth/Disassoc frame. Normally it get
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002501 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2502 * Which means host is also trying to disconnect.
2503 * PE can continue processing DEAUTH_REQ and send
2504 * the response instead of failing the request.
2505 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2506 * was sent for deauth/disassoc frame.
2507 */
2508 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002509 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002510 break;
2511 default:
2512 /*
2513 * STA is not in a state to deauthenticate with
2514 * peer. Log error and send response to host.
2515 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002516 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002517 session_entry->limSmeState);
2518 lim_print_sme_state(mac_ctx, LOGE,
2519 session_entry->limSmeState);
2520
2521 if (mac_ctx->lim.gLimRspReqd) {
2522 mac_ctx->lim.gLimRspReqd = false;
2523
2524 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2525 deauth_trigger = eLIM_HOST_DEAUTH;
2526
wadesong42968e92017-06-08 14:11:21 +08002527 /*
2528 * here we received deauth request from AP so
2529 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2530 * have ISSUED delSta then mlm state should be
2531 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2532 * delBSS rsp then mlm state should be
2533 * eLIM_MLM_IDLE_STATE so the below condition
2534 * captures the state where delSta not done
2535 * and firmware still in connected state.
2536 */
2537 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002538 eLIM_SME_WT_DEAUTH_STATE &&
2539 session_entry->limMlmState !=
2540 eLIM_MLM_IDLE_STATE &&
2541 session_entry->limMlmState !=
2542 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002543 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002544 goto send_deauth;
2545 }
2546 return;
2547 }
2548 break;
2549
2550 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002551 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002552 if (mac_ctx->lim.gLimRspReqd) {
2553 mac_ctx->lim.gLimRspReqd = false;
2554 ret_code = eSIR_SME_INVALID_PARAMETERS;
2555 deauth_trigger = eLIM_HOST_DEAUTH;
2556 goto send_deauth;
2557 }
2558 return;
2559 case eLIM_AP_ROLE:
2560 break;
2561 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002562 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002563 GET_LIM_SYSTEM_ROLE(session_entry));
2564 if (mac_ctx->lim.gLimRspReqd) {
2565 mac_ctx->lim.gLimRspReqd = false;
2566 ret_code = eSIR_SME_INVALID_PARAMETERS;
2567 deauth_trigger = eLIM_HOST_DEAUTH;
2568 goto send_deauth;
2569 }
2570 return;
2571 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2572
2573 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2574 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002575 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002576 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2577 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2578 } else {
2579 deauth_trigger = eLIM_HOST_DEAUTH;
2580 reason_code = sme_deauth_req.reasonCode;
2581 }
2582
2583 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302584 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002585 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002586 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002587 if (mac_ctx->lim.gLimRspReqd) {
2588 mac_ctx->lim.gLimRspReqd = false;
2589 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2590 deauth_trigger = eLIM_HOST_DEAUTH;
2591 goto send_deauth;
2592 }
2593 return;
2594 }
2595
Anurag Chouhanc5548422016-02-24 18:33:27 +05302596 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002597 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002598
2599 mlm_deauth_req->reasonCode = reason_code;
2600 mlm_deauth_req->deauthTrigger = deauth_trigger;
2601
2602 /* Update PE session Id */
2603 mlm_deauth_req->sessionId = session_id;
2604
2605 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2606 (uint32_t *)mlm_deauth_req);
2607 return;
2608
2609send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002610 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2611 ret_code, deauth_trigger, 1,
2612 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002613}
2614
2615/**
2616 * __lim_process_sme_set_context_req()
2617 *
2618 * @mac_ctx: Pointer to Global MAC structure
2619 * @msg_buf: pointer to the SME message buffer
2620 *
2621 * This function is called to process SME_SETCONTEXT_REQ message
2622 * from HDD or upper layer application.
2623 *
2624 * Return: None
2625 */
2626
2627static void
2628__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2629{
2630 tpSirSmeSetContextReq set_context_req;
2631 tLimMlmSetKeysReq *mlm_set_key_req;
2632 tpPESession session_entry;
2633 uint8_t session_id; /* PE sessionID */
2634 uint8_t sme_session_id;
2635 uint16_t sme_transaction_id;
2636
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002637 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002638 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002639 return;
2640 }
2641
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302642 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002643 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002644 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002645 return;
2646 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302647 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002648 sizeof(struct sSirSmeSetContextReq));
2649 sme_session_id = set_context_req->sessionId;
2650 sme_transaction_id = set_context_req->transactionId;
2651
2652 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002653 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002654 goto end;
2655 }
2656
2657 if (set_context_req->keyMaterial.numKeys >
2658 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002659 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660 set_context_req->keyMaterial.numKeys);
2661 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002662 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002663 eSIR_SME_INVALID_PARAMETERS, NULL,
2664 sme_session_id, sme_transaction_id);
2665 goto end;
2666 }
2667
2668 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002669 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002670 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002671 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002672 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002673 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002674 eSIR_SME_INVALID_PARAMETERS, NULL,
2675 sme_session_id, sme_transaction_id);
2676 goto end;
2677 }
2678#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2679 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2680 session_entry, 0, 0);
2681#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2682
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002683 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002684 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2685 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002686 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002687 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2688 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302689 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002690 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002691 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002692 goto end;
2693 }
2694 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2695 mlm_set_key_req->numKeys =
2696 set_context_req->keyMaterial.numKeys;
2697 if (mlm_set_key_req->numKeys >
2698 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002699 pe_err("no.of keys exceeded max num of default keys limit");
Jingxiang Ge4168a232018-01-03 18:47:15 +08002700 qdf_mem_free(mlm_set_key_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002701 goto end;
2702 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302703 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002704 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002705
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302706 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002707 (uint8_t *) &set_context_req->keyMaterial.key,
2708 sizeof(tSirKeys) *
2709 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2710 numKeys : 1));
2711
2712 mlm_set_key_req->sessionId = session_id;
2713 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002714 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002715 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002716
2717 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2718 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2719 LIM_IS_AP_ROLE(session_entry)) {
2720 if (set_context_req->keyMaterial.key[0].keyLength) {
2721 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002722
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002723 key_id =
2724 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302725 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002726 &session_entry->WEPKeyMaterial[key_id],
2727 (uint8_t *) &set_context_req->keyMaterial,
2728 sizeof(tSirKeyMaterial));
2729 } else {
2730 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002731
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002732 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2733 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302734 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002735 &mlm_set_key_req->key[i],
2736 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2737 sizeof(tSirKeys));
2738 }
2739 }
2740 }
2741 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2742 (uint32_t *) mlm_set_key_req);
2743 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002744 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002745 GET_LIM_SYSTEM_ROLE(session_entry),
2746 session_entry->limSmeState);
2747 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2748
2749 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002750 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002751 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2752 session_entry, sme_session_id,
2753 sme_transaction_id);
2754 }
2755end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302756 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002757 return;
2758}
2759
2760/**
2761 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2762 *
2763 * @mac_ctx: Pointer to Global MAC structure
2764 * @msg_buf: pointer to the SME message buffer
2765 *
2766 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2767 * from HDD or upper layer application.
2768 *
2769 * Return: None
2770 */
2771
Jeff Johnson801f1532016-10-07 07:54:50 -07002772static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2773 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002774{
2775 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2776 tpDphHashNode sta_ds = NULL;
2777 tpPESession session_entry = NULL;
2778 tSap_Event sap_event;
2779 tpWLAN_SAPEventCB sap_event_cb = NULL;
2780 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2781 uint8_t session_id = CSR_SESSION_ID_INVALID;
2782 uint8_t assoc_id = 0;
2783 uint8_t sta_cnt = 0;
2784
2785 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002786 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002787 return;
2788 }
2789
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302790 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002791 sizeof(struct sSirSmeGetAssocSTAsReq));
2792 /*
2793 * Get Associated stations from PE.
2794 * Find PE session Entry
2795 */
2796 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08002797 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002798 &session_id);
2799 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002800 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002801 goto lim_assoc_sta_end;
2802 }
2803
2804 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002805 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002806 session_entry->limSmeState,
2807 GET_LIM_SYSTEM_ROLE(session_entry));
2808 goto lim_assoc_sta_end;
2809 }
2810 /* Retrieve values obtained in the request message */
2811 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
2812 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2813
2814 if (NULL == assoc_sta_tmp)
2815 goto lim_assoc_sta_end;
2816 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
2817 assoc_id++) {
2818 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
2819 &session_entry->dph.dphHashTable);
2820 if (NULL == sta_ds)
2821 continue;
2822 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302823 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002824 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302825 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002826 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
2827 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
2828
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302829 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002830 (uint8_t *)&sta_ds->supportedRates,
2831 sizeof(tSirSupportedRates));
2832 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
2833 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
2834 assoc_sta_tmp->Support40Mhz =
2835 sta_ds->htDsssCckRate40MHzSupport;
2836
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002837 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002838 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002839 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002840 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002841 pe_debug("Association Id: %d Station Index: %d",
2842 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002843 assoc_sta_tmp++;
2844 sta_cnt++;
2845 }
2846 }
2847lim_assoc_sta_end:
2848 /*
2849 * Call hdd callback with sap event to send the list of
2850 * associated stations from PE
2851 */
2852 if (sap_event_cb != NULL) {
2853 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
2854 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302855 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002856 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
2857 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
2858 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2859 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
2860 }
2861}
2862
2863/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002864 * __lim_counter_measures()
2865 *
2866 * FUNCTION:
2867 * This function is called to "implement" MIC counter measure
2868 * and is *temporary* only
2869 *
2870 * LOGIC: on AP, disassoc all STA associated thru TKIP,
2871 * we don't do the proper STA disassoc sequence since the
Jeff Johnsond460e842018-05-11 13:25:53 -07002872 * BSS will be stopped anyway
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002873 *
2874 ***ASSUMPTIONS:
2875 *
2876 ***NOTE:
2877 *
2878 * @param pMac Pointer to Global MAC structure
2879 * @return None
2880 */
2881
2882static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
2883{
2884 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002885
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002886 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002887 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
2888 mac, psessionEntry, false);
2889};
2890
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302891/**
2892 * lim_send_stop_bss_failure_resp() -send failure delete bss resp to sme
2893 * @mac_ctx: mac ctx
2894 * @session: session pointer
2895 *
2896 * Return None
2897 */
2898static void lim_send_stop_bss_failure_resp(tpAniSirGlobal mac_ctx,
2899 tpPESession session)
2900{
2901 session->limSmeState = session->limPrevSmeState;
2902
2903 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE, session->peSessionId,
2904 session->limSmeState));
2905
2906 lim_send_sme_rsp(mac_ctx, eWNI_SME_STOP_BSS_RSP,
2907 eSIR_SME_STOP_BSS_FAILURE, session->smeSessionId,
2908 session->transactionId);
2909}
2910
2911void lim_delete_all_peers(tpPESession session)
2912{
2913 uint8_t i = 0;
2914 tpAniSirGlobal mac_ctx = session->mac_ctx;
2915 tpDphHashNode sta_ds = NULL;
2916 QDF_STATUS status;
2917
2918 for (i = 1; i < session->dph.dphHashTable.size; i++) {
2919 sta_ds = dph_get_hash_entry(mac_ctx, i,
2920 &session->dph.dphHashTable);
2921 if (!sta_ds)
2922 continue;
2923 status = lim_del_sta(mac_ctx, sta_ds, false, session);
2924 if (QDF_STATUS_SUCCESS == status) {
2925 lim_delete_dph_hash_entry(mac_ctx, sta_ds->staAddr,
2926 sta_ds->assocId, session);
2927 lim_release_peer_idx(mac_ctx, sta_ds->assocId, session);
2928 } else {
2929 pe_err("lim_del_sta failed with Status: %d", status);
2930 QDF_ASSERT(0);
2931 }
2932 }
Abhishek Singhcaa61852018-09-12 15:50:04 +05302933
2934#ifdef CONFIG_VDEV_SM
2935 status =
2936 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
2937 WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE,
2938 sizeof(*session), session);
2939 if (QDF_IS_STATUS_ERROR(status)) {
2940 pe_err("failed to post WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE for vdevid %d",
2941 session->smeSessionId);
2942 lim_send_stop_bss_failure_resp(mac_ctx, session);
2943 }
2944#endif
2945
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302946}
2947
Abhishek Singhcaa61852018-09-12 15:50:04 +05302948QDF_STATUS lim_send_vdev_stop(tpPESession session)
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302949{
2950 tpAniSirGlobal mac_ctx = session->mac_ctx;
2951 QDF_STATUS status;
2952
2953 status = lim_del_bss(mac_ctx, NULL, session->bssIdx, session);
2954
2955 if (QDF_IS_STATUS_ERROR(status)) {
2956 pe_err("delBss failed for bss %d", session->bssIdx);
2957 lim_send_stop_bss_failure_resp(mac_ctx, session);
2958 }
Abhishek Singhcaa61852018-09-12 15:50:04 +05302959
2960 return status;
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302961}
2962
2963/**
2964 * lim_delete_peers_and_send_vdev_stop() -delete peers and send vdev stop
2965 * @session: session pointer
2966 *
2967 * Return None
2968 */
Abhishek Singhcaa61852018-09-12 15:50:04 +05302969#ifdef CONFIG_VDEV_SM
2970static void lim_delete_peers_and_send_vdev_stop(tpPESession session)
2971{
2972 tpAniSirGlobal mac_ctx = session->mac_ctx;
2973 QDF_STATUS status;
2974
2975 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
2976 WLAN_VDEV_SM_EV_DOWN,
2977 sizeof(*session), session);
2978 if (QDF_IS_STATUS_ERROR(status)) {
2979 pe_err("failed to post WLAN_VDEV_SM_EV_DOWN for vdevid %d",
2980 session->smeSessionId);
2981 lim_send_stop_bss_failure_resp(mac_ctx, session);
2982 }
2983}
2984#else
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302985static void lim_delete_peers_and_send_vdev_stop(tpPESession session)
2986{
2987 lim_delete_all_peers(session);
2988 /* send a delBss to HAL and wait for a response */
2989 lim_send_vdev_stop(session);
2990}
Abhishek Singhcaa61852018-09-12 15:50:04 +05302991#endif
2992
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302993
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002994static void
2995__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2996{
2997 tSirSmeStopBssReq stopBssReq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002998 tLimSmeStates prevState;
2999 tpPESession psessionEntry;
3000 uint8_t smesessionId;
3001 uint8_t sessionId;
3002 uint16_t smetransactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003003
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303004 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003005 smesessionId = stopBssReq.sessionId;
3006 smetransactionId = stopBssReq.transactionId;
3007
3008 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003009 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003010 /* Send Stop BSS response to host */
3011 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3012 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3013 smetransactionId);
3014 return;
3015 }
3016
3017 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003018 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003019 &sessionId);
3020 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003021 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003022 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3023 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3024 smetransactionId);
3025 return;
3026 }
3027#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3028 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3029 0, 0);
3030#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3031
3032 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3033 LIM_IS_STA_ROLE(psessionEntry)) {
3034 /**
3035 * Should not have received STOP_BSS_REQ in states
3036 * other than 'normal' state or on STA in Infrastructure
3037 * mode. Log error and return response to host.
3038 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003039 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003040 psessionEntry->limSmeState,
3041 GET_LIM_SYSTEM_ROLE(psessionEntry));
3042 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3043 /* / Send Stop BSS response to host */
3044 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3045 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3046 smetransactionId);
3047 return;
3048 }
3049
3050 if (LIM_IS_AP_ROLE(psessionEntry))
3051 lim_wpspbc_close(pMac, psessionEntry);
3052
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003053 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003054 stopBssReq.reasonCode);
3055
3056 prevState = psessionEntry->limSmeState;
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303057 psessionEntry->limPrevSmeState = prevState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058
3059 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3060 MTRACE(mac_trace
3061 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3062 psessionEntry->limSmeState));
3063
3064 /* Update SME session Id and Transaction Id */
3065 psessionEntry->smeSessionId = smesessionId;
3066 psessionEntry->transactionId = smetransactionId;
3067
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003068 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3069 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3070 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003071 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003072
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003073 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3074 /* Send disassoc all stations associated thru TKIP */
3075 __lim_counter_measures(pMac, psessionEntry);
3076 else
3077 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003078 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3079 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003080 }
3081
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003082 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3083 /* Free the buffer allocated in START_BSS_REQ */
3084 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3085 psessionEntry->addIeParams.probeRespDataLen = 0;
3086 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003087
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003088 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3089 psessionEntry->addIeParams.assocRespDataLen = 0;
3090 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003091
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003092 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3093 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3094 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003095
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003096 /*
3097 * lim_del_bss is also called as part of coalescing,
3098 * when we send DEL BSS followed by Add Bss msg.
3099 */
3100 pMac->lim.gLimIbssCoalescingHappened = false;
3101 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003102
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303103 lim_delete_peers_and_send_vdev_stop(psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003104
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003105}
3106
3107/**
3108 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3109 * @pMac: Global MAC context
3110 * @pMsg: Message from SME
3111 *
3112 * Wrapper for the function __lim_handle_sme_stop_bss_request
3113 * This message will be defered until softmac come out of
3114 * scan mode. Message should be handled even if we have
3115 * detected radar in the current operating channel.
3116 *
3117 * Return: true - If we consumed the buffer
3118 * false - If have defered the message.
3119 */
3120
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003121static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3122 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003123{
3124 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3125 /**
3126 * If message defered, buffer is not consumed yet.
3127 * So return false
3128 */
3129 return false;
3130 }
3131 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3132 return true;
3133} /*** end __lim_process_sme_stop_bss_req() ***/
3134
3135void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3136 uint32_t body, tpPESession psessionEntry)
3137{
3138
3139 (void)body;
3140 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3141 lim_ibss_delete(pMac, psessionEntry);
3142 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3143 lim_delete_pre_auth_list(pMac);
3144 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3145 psessionEntry->smeSessionId,
3146 psessionEntry->transactionId);
3147 return;
3148}
3149
3150/**
3151 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3152 *
3153 * @mac_ctx: pointer to mac context
3154 * @msg_type: message type
3155 * @msg_buf: pointer to the SME message buffer
3156 *
3157 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3158 * in BTAMP AP.
3159 *
3160 * Return: None
3161 */
3162
3163void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3164 uint32_t *msg_buf)
3165{
3166 tSirSmeAssocCnf assoc_cnf;
3167 tpDphHashNode sta_ds = NULL;
3168 tpPESession session_entry = NULL;
3169 uint8_t session_id;
3170 tpSirAssocReq assoc_req;
3171
3172 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003173 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003174 goto end;
3175 }
3176
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303177 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003178 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003179 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003180 goto end;
3181 }
3182
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003183 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003184 &session_id);
3185 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003186 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003187 goto end;
3188 }
3189
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003190 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003191 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3192 (session_entry->limSmeState !=
3193 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003194 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003195 msg_type, session_entry->limSmeState,
3196 GET_LIM_SYSTEM_ROLE(session_entry));
3197 goto end;
3198 }
3199 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3200 &session_entry->dph.dphHashTable);
3201 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003202 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003203 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303204 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003205
3206 /*
3207 * send a DISASSOC_IND message to WSM to make sure
3208 * the state in WSM and LIM is the same
3209 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003210 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003211 eSIR_SME_STA_NOT_ASSOCIATED,
3212 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3213 session_entry->smeSessionId,
3214 session_entry->transactionId,
3215 session_entry);
3216 goto end;
3217 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303218 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003219 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303220 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003221 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003222 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303223 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003224 goto end;
3225 }
3226
3227 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3228 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3229 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3230 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3231 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003232 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3233 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003234 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303235 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003236 goto end;
3237 }
3238 /*
3239 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3240 * has been received
3241 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003242 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3244 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3245
3246 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3247 /*
3248 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3249 * when it had received Assoc Request frame. Now, PE just needs
3250 * to send association rsp frame to the requesting BTAMP-STA.
3251 */
3252 sta_ds->mlmStaContext.mlmState =
3253 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003254 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003255 sta_ds->assocId);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003256 lim_send_assoc_rsp_mgmt_frame(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003257 sta_ds->assocId, sta_ds->staAddr,
3258 sta_ds->mlmStaContext.subType, sta_ds,
3259 session_entry);
3260 goto end;
3261 } else {
3262 /*
3263 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3264 * to be associated since the HAL sta entry is created for
3265 * denied STA we need to remove this HAL entry.
3266 * So to do that set updateContext to 1
3267 */
3268 if (!sta_ds->mlmStaContext.updateContext)
3269 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003270 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003271 assoc_cnf.statusCode, sta_ds->assocId);
3272 lim_reject_association(mac_ctx, sta_ds->staAddr,
3273 sta_ds->mlmStaContext.subType,
3274 true, sta_ds->mlmStaContext.authType,
3275 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003276 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003277 session_entry);
3278 }
3279end:
3280 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3281 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3282 assoc_req = (tpSirAssocReq)
3283 session_entry->parsedAssocReq[sta_ds->assocId];
3284 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303285 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003286 assoc_req->assocReqFrame = NULL;
3287 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303288 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003289 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3290 }
3291}
3292
3293static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3294{
3295 tpDphHashNode pStaDs;
3296 tSirMacAddr peerMac;
3297 tpSirAddtsReq pSirAddts;
3298 uint32_t timeout;
3299 tpPESession psessionEntry;
3300 uint8_t sessionId; /* PE sessionId */
3301 uint8_t smesessionId;
3302 uint16_t smetransactionId;
3303
3304 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003305 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003306 return;
3307 }
3308
3309 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3310 &smetransactionId);
3311
3312 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3313
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003314 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3315 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003316 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003317 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003318 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303319 NULL, pSirAddts->req.tspec,
3320 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321 return;
3322 }
3323#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3324 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3325 0);
3326#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3327
3328 /* if sta
3329 * - verify assoc state
3330 * - send addts request to ap
3331 * - wait for addts response from ap
3332 * if ap, just ignore with error log
3333 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003334 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3335 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3336 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003337
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003338 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003339 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303340 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003341 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003342
3343 pStaDs =
3344 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3345 &psessionEntry->dph.dphHashTable);
3346
3347 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003348 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303349 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003350 }
3351
3352 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3353 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003354 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303355 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003356 }
3357
3358 pSirAddts->req.wsmTspecPresent = 0;
3359 pSirAddts->req.wmeTspecPresent = 0;
3360 pSirAddts->req.lleTspecPresent = 0;
3361
3362 if ((pStaDs->wsmEnabled) &&
3363 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3364 SIR_MAC_ACCESSPOLICY_EDCA))
3365 pSirAddts->req.wsmTspecPresent = 1;
3366 else if (pStaDs->wmeEnabled)
3367 pSirAddts->req.wmeTspecPresent = 1;
3368 else if (pStaDs->lleEnabled)
3369 pSirAddts->req.lleTspecPresent = 1;
3370 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003371 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303372 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003373 }
3374
3375 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3376 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003377 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003378 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303379 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003380 }
3381
3382 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003383 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003384 pMac->lim.gLimAddtsReq.req.dialogToken,
3385 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3386 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3387 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303388 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003389 }
3390
3391 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3392
3393 /* save the addts request */
3394 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303395 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003396 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3397
3398 /* ship out the message now */
3399 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3400 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303401 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003402 /* start a timer to wait for the response */
3403 if (pSirAddts->timeout)
3404 timeout = pSirAddts->timeout;
3405 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003406 QDF_STATUS_SUCCESS) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303407 pe_debug("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003408 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303409 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003410 }
3411
3412 timeout = SYS_MS_TO_TICKS(timeout);
3413 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3414 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003415 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303416 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003417 }
3418 pMac->lim.gLimAddtsRspTimerCount++;
3419 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3420 pMac->lim.gLimAddtsRspTimerCount) !=
3421 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003422 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303423 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003424 }
3425 MTRACE(mac_trace
3426 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3427 eLIM_ADDTS_RSP_TIMER));
3428
3429 /* add the sessionId to the timer object */
3430 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3431 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3432 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003433 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303434 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003435 }
3436 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303437
3438send_failure_addts_rsp:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003439 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303440 psessionEntry, pSirAddts->req.tspec,
3441 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003442}
3443
3444static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3445{
3446 tSirMacAddr peerMacAddr;
3447 uint8_t ac;
3448 tSirMacTSInfo *pTsinfo;
3449 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3450 tpDphHashNode pStaDs = NULL;
3451 tpPESession psessionEntry;
3452 uint8_t sessionId;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003453 uint32_t status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003454 uint8_t smesessionId;
3455 uint16_t smetransactionId;
3456
3457 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3458 &smetransactionId);
3459
3460 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003461 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462 &sessionId);
3463 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003464 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003465 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003466 goto end;
3467 }
3468#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3469 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3470 0);
3471#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3472
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003473 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003474 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003475 pe_err("lim_validate_delts_req failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003476 status = QDF_STATUS_E_FAILURE;
3477 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_E_FAILURE, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003478 smesessionId, smetransactionId);
3479 return;
3480 }
3481
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003482 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3483 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003484 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3485
3486 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3487 pDeltsReq->req.wmeTspecPresent,
3488 &pDeltsReq->req.tsinfo,
3489 &pDeltsReq->req.tspec, psessionEntry);
3490
3491 pTsinfo =
3492 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3493 tsinfo : &pDeltsReq->req.tsinfo;
3494
3495 /* We've successfully send DELTS frame to AP. Update the
3496 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3497 * is no longer trigger enabled or delivery enabled
3498 */
3499 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3500 pTsinfo, CLEAR_UAPSD_MASK);
3501
3502 /* We're deleting the TSPEC, so this particular AC is no longer
3503 * admitted. PE needs to downgrade the EDCA
3504 * parameters(for the AC for which TS is being deleted) to the
3505 * next best AC for which ACM is not enabled, and send the
3506 * updated values to HAL.
3507 */
3508 ac = upToAc(pTsinfo->traffic.userPrio);
3509
3510 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3511 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3512 ~(1 << ac);
3513 } else if (pTsinfo->traffic.direction ==
3514 SIR_MAC_DIRECTION_DNLINK) {
3515 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3516 ~(1 << ac);
3517 } else if (pTsinfo->traffic.direction ==
3518 SIR_MAC_DIRECTION_BIDIR) {
3519 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3520 ~(1 << ac);
3521 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3522 ~(1 << ac);
3523 }
3524
3525 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3526 psessionEntry);
3527
3528 pStaDs =
3529 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3530 &psessionEntry->dph.dphHashTable);
3531 if (pStaDs != NULL) {
3532 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003533 pStaDs->bssId, false);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003534 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003535 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003536 pe_err("Self entry missing in Hash Table");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003537 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003538 }
3539#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003540 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003541#endif
3542
3543 /* send an sme response back */
3544end:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003545 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_SUCCESS, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003546 smesessionId, smetransactionId);
3547}
3548
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303549void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003550{
3551 /* fetch the sessionEntry based on the sessionId */
3552 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003553
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003554 psessionEntry = pe_find_session_by_session_id(pMac,
3555 pMac->lim.limTimers.gLimAddtsRspTimer.
3556 sessionId);
3557 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003558 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003559 return;
3560 }
3561
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003562 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003563 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003564 GET_LIM_SYSTEM_ROLE(psessionEntry));
3565 pMac->lim.gLimAddtsSent = false;
3566 return;
3567 }
3568
3569 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003570 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003571 return;
3572 }
3573
3574 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003575 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003576 pMac->lim.gLimAddtsRspTimerCount);
3577 return;
3578 }
3579 /* this a real response timeout */
3580 pMac->lim.gLimAddtsSent = false;
3581 pMac->lim.gLimAddtsRspTimerCount++;
3582
3583 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3584 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3585 psessionEntry->smeSessionId,
3586 psessionEntry->transactionId);
3587}
3588
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003589#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003590/**
3591 * __lim_process_sme_get_statistics_request()
3592 *
3593 ***FUNCTION:
3594 *
3595 *
3596 ***NOTE:
3597 *
3598 * @param pMac Pointer to Global MAC structure
3599 * @param *pMsgBuf A pointer to the SME message buffer
3600 * @return None
3601 */
3602static void
3603__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3604{
3605 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003606 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003607
3608 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3609
3610 msgQ.type = WMA_GET_STATISTICS_REQ;
3611
3612 msgQ.reserved = 0;
3613 msgQ.bodyptr = pMsgBuf;
3614 msgQ.bodyval = 0;
3615 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3616
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003617 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303618 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003619 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003620 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003621 return;
3622 }
3623
3624 return;
3625}
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003626#else
3627static void __lim_process_sme_get_statistics_request(
3628 struct sAniSirGlobal *mac_ctx, uint32_t *pMsgBuf) {}
3629#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003630
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003631#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003632/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003633 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003634 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003635 * @pMac: Pointer to Global MAC structure
3636 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003637 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003638 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003639 */
3640static void
3641__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3642{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003643 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003644
3645 msgQ.type = WMA_TSM_STATS_REQ;
3646 msgQ.reserved = 0;
3647 msgQ.bodyptr = pMsgBuf;
3648 msgQ.bodyval = 0;
3649 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3650
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003651 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303652 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003653 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003654 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003655 return;
3656 }
3657}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003658#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003659
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08003660static void lim_process_sme_set_addba_accept(tpAniSirGlobal mac_ctx,
3661 struct sme_addba_accept *msg)
3662{
3663 if (!msg) {
3664 pe_err("Msg Buffer is NULL");
3665 return;
3666 }
3667 if (!msg->addba_accept)
3668 mac_ctx->reject_addba_req = 1;
3669 else
3670 mac_ctx->reject_addba_req = 0;
3671}
3672
Arif Hussaineb8ba362018-03-07 19:15:13 -08003673static void lim_process_sme_update_edca_params(tpAniSirGlobal mac_ctx,
3674 uint32_t sme_session_id)
3675{
3676 tpPESession pe_session;
3677 tpDphHashNode sta_ds_ptr;
3678
3679 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3680 if (!pe_session) {
3681 pe_err("Session does not exist: sme_id %d", sme_session_id);
3682 return;
3683 }
3684 pe_session->gLimEdcaParamsActive[EDCA_AC_BE].no_ack =
3685 mac_ctx->no_ack_policy_cfg[EDCA_AC_BE];
3686 pe_session->gLimEdcaParamsActive[EDCA_AC_BK].no_ack =
3687 mac_ctx->no_ack_policy_cfg[EDCA_AC_BK];
3688 pe_session->gLimEdcaParamsActive[EDCA_AC_VI].no_ack =
3689 mac_ctx->no_ack_policy_cfg[EDCA_AC_VI];
3690 pe_session->gLimEdcaParamsActive[EDCA_AC_VO].no_ack =
3691 mac_ctx->no_ack_policy_cfg[EDCA_AC_VO];
3692 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3693 &pe_session->dph.dphHashTable);
3694 if (sta_ds_ptr)
3695 lim_send_edca_params(mac_ctx,
3696 pe_session->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003697 sta_ds_ptr->bssId, false);
Arif Hussaineb8ba362018-03-07 19:15:13 -08003698 else
3699 pe_err("Self entry missing in Hash Table");
3700}
3701
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07003702static void lim_process_sme_update_mu_edca_params(tpAniSirGlobal mac_ctx,
3703 uint32_t sme_session_id)
3704{
3705 tpPESession pe_session;
3706 tpDphHashNode sta_ds_ptr;
3707
3708 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3709 if (!pe_session) {
3710 pe_err("Session does not exist: sme_id %d", sme_session_id);
3711 return;
3712 }
3713 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3714 &pe_session->dph.dphHashTable);
3715 if (sta_ds_ptr)
3716 lim_send_edca_params(mac_ctx, mac_ctx->usr_mu_edca_params,
3717 sta_ds_ptr->bssId, true);
3718 else
3719 pe_err("Self entry missing in Hash Table");
3720}
3721
Naveen Rawat8029a402017-06-01 10:54:19 -07003722static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3723 struct update_config *msg)
3724{
3725 tpPESession pe_session;
3726
3727 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3728 if (msg == NULL) {
3729 pe_err("Buffer is Pointing to NULL");
3730 return;
3731 }
3732
3733 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3734 msg->sme_session_id);
3735 if (pe_session == NULL) {
3736 pe_warn("Session does not exist for given BSSID");
3737 return;
3738 }
3739
3740 switch (msg->capab) {
3741 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3742 pe_session->htConfig.ht_rx_ldpc = msg->value;
3743 break;
3744 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3745 pe_session->htConfig.ht_tx_stbc = msg->value;
3746 break;
3747 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3748 pe_session->htConfig.ht_rx_stbc = msg->value;
3749 break;
3750 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3751 pe_session->htConfig.ht_sgi20 = msg->value;
3752 break;
3753 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3754 pe_session->htConfig.ht_sgi40 = msg->value;
3755 break;
3756 }
3757
3758 if (LIM_IS_AP_ROLE(pe_session)) {
3759 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3760 lim_send_beacon_ind(mac_ctx, pe_session);
3761 }
3762}
3763
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003764void
3765lim_send_vdev_restart(tpAniSirGlobal pMac,
3766 tpPESession psessionEntry, uint8_t sessionId)
3767{
3768 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003769 struct scheduler_msg msgQ = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003770 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003771
3772 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003773 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003774 return;
3775 }
3776
3777 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303778 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003779 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003780 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003781 return;
3782 }
3783
3784 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3785 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003786 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003787
3788 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3789 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3790 msgQ.bodyval = 0;
3791
3792 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003793 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003794 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303795 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003796 }
3797}
3798
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303799/**
3800 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3801 * @mac_ctx: Pointer to Global MAC structure
3802 * @msg_buf: Pointer to SME message buffer
3803 *
3804 * Return: None
3805 */
3806static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3807 uint32_t *msg_buf)
3808{
3809 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003810 struct scheduler_msg wma_msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003811 QDF_STATUS status;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303812 tSirRoamOffloadScanReq *req_buffer;
3813 uint16_t local_ie_len;
3814 uint8_t *local_ie_buf;
3815
3816 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3817 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3818 req_buffer->sessionId);
3819
3820 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3821 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003822 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303823 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303824 return;
3825 }
3826
3827 local_ie_len = req_buffer->assoc_ie.length;
3828 /* Update ext cap IE if present */
3829 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003830 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3831 local_ie_buf, &local_ie_len)) {
3832 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003833 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3834 req_buffer->assoc_ie.length = local_ie_len;
3835 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3836 local_ie_buf, local_ie_len);
3837 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303838 }
3839 qdf_mem_free(local_ie_buf);
3840
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303841 if (pe_session)
3842 lim_update_fils_rik(pe_session, req_buffer);
3843
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303844 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3845 wma_msg.bodyptr = req_buffer;
3846
3847 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003848 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003849 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303850 qdf_mem_free(req_buffer);
3851 }
3852}
3853
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303854/*
3855 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3856 * @mac_ctx: Pointer to global mac context
3857 * @session: Pointer to PE session
3858 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3859 * 1 - Disable broadcast SSID
3860 *
3861 * Return: None
3862 */
3863static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3864 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003865{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003866 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003867 session->ssidHidden, ssid_hidden);
3868
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003869 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303870 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003871 } else {
3872 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05303873 return;
3874 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003875
3876 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303877 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003878
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003879 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303880}
3881
3882/**
3883 * __lim_process_sme_session_update - process SME session update msg
3884 *
3885 * @mac_ctx: Pointer to global mac context
3886 * @msg_buf: Pointer to the received message buffer
3887 *
3888 * Return: None
3889 */
3890static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
3891 uint32_t *msg_buf)
3892{
3893 struct sir_update_session_param *msg;
3894 tpPESession session;
3895
3896 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003897 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303898 return;
3899 }
3900
3901 msg = (struct sir_update_session_param *) msg_buf;
3902
3903 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
3904 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003905 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303906 msg->session_id);
3907 return;
3908 }
3909
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003910 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303911 msg->param_type, msg->param_val);
3912 switch (msg->param_type) {
3913 case SIR_PARAM_SSID_HIDDEN:
3914 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
3915 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303916 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
3917 session->ignore_assoc_disallowed = msg->param_val;
3918 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303919 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003920 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303921 break;
3922 }
3923}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003924
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003925/*
3926 Update the beacon Interval dynamically if beaconInterval is different in MCC
3927 */
3928static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3929{
3930 tpSirChangeBIParams pChangeBIParams;
3931 tpPESession psessionEntry;
3932 uint8_t sessionId = 0;
3933 tUpdateBeaconParams beaconParams;
3934
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003935 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003936
3937 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003938 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003939 return;
3940 }
3941
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303942 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003943 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
3944
3945 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08003946 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003947 &sessionId);
3948 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003949 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003950 return;
3951 }
3952
3953 /*Update sessionEntry Beacon Interval */
3954 if (psessionEntry->beaconParams.beaconInterval !=
3955 pChangeBIParams->beaconInterval) {
3956 psessionEntry->beaconParams.beaconInterval =
3957 pChangeBIParams->beaconInterval;
3958 }
3959
3960 /*Update sch beaconInterval */
3961 if (pMac->sch.schObject.gSchBeaconInterval !=
3962 pChangeBIParams->beaconInterval) {
3963 pMac->sch.schObject.gSchBeaconInterval =
3964 pChangeBIParams->beaconInterval;
3965
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003966 pe_debug("LIM send update BeaconInterval Indication: %d",
3967 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003968
3969 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
3970 /* Update beacon */
3971 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3972
3973 beaconParams.bssIdx = psessionEntry->bssIdx;
3974 /* Set change in beacon Interval */
3975 beaconParams.beaconInterval =
3976 pChangeBIParams->beaconInterval;
3977 beaconParams.paramChangeBitmap =
3978 PARAM_BCN_INTERVAL_CHANGED;
3979 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
3980 }
3981 }
3982
3983 return;
3984} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
3985
3986#ifdef QCA_HT_2040_COEX
3987static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
3988 uint32_t *pMsgBuf)
3989{
3990 tpSirSetHT2040Mode pSetHT2040Mode;
3991 tpPESession psessionEntry;
3992 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003993 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003994 tUpdateVHTOpMode *pHtOpMode = NULL;
3995 uint16_t staId = 0;
3996 tpDphHashNode pStaDs = NULL;
3997
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003998 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003999 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004000 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004001 return;
4002 }
4003
4004 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4005
4006 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004007 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004008 &sessionId);
4009 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004010 pe_debug("Session does not exist for given BSSID");
4011 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004012 return;
4013 }
4014
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004015 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004016 pSetHT2040Mode->cbMode);
4017 /*Update sessionEntry HT related fields */
4018 switch (pSetHT2040Mode->cbMode) {
4019 case PHY_SINGLE_CHANNEL_CENTERED:
4020 psessionEntry->htSecondaryChannelOffset =
4021 PHY_SINGLE_CHANNEL_CENTERED;
4022 psessionEntry->htRecommendedTxWidthSet = 0;
4023 if (pSetHT2040Mode->obssEnabled)
4024 psessionEntry->htSupportedChannelWidthSet
4025 = eHT_CHANNEL_WIDTH_40MHZ;
4026 else
4027 psessionEntry->htSupportedChannelWidthSet
4028 = eHT_CHANNEL_WIDTH_20MHZ;
4029 break;
4030 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4031 psessionEntry->htSecondaryChannelOffset =
4032 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4033 psessionEntry->htRecommendedTxWidthSet = 1;
4034 break;
4035 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4036 psessionEntry->htSecondaryChannelOffset =
4037 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4038 psessionEntry->htRecommendedTxWidthSet = 1;
4039 break;
4040 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004041 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004042 return;
4043 }
4044
4045 /* Update beacon */
4046 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4047 lim_send_beacon_ind(pMac, psessionEntry);
4048
4049 /* update OP Mode for each associated peer */
4050 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4051 pStaDs = dph_get_hash_entry(pMac, staId,
4052 &psessionEntry->dph.dphHashTable);
4053 if (NULL == pStaDs)
4054 continue;
4055
4056 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304057 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004058 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004059 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004060 return;
4061 }
4062 pHtOpMode->opMode =
4063 (psessionEntry->htSecondaryChannelOffset ==
4064 PHY_SINGLE_CHANNEL_CENTERED) ?
4065 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4066 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304067 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004068 sizeof(tSirMacAddr));
4069 pHtOpMode->smesessionId = sessionId;
4070
4071 msg.type = WMA_UPDATE_OP_MODE;
4072 msg.reserved = 0;
4073 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004074 if (!QDF_IS_STATUS_SUCCESS
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05304075 (scheduler_post_message(QDF_MODULE_ID_PE,
4076 QDF_MODULE_ID_WMA,
4077 QDF_MODULE_ID_WMA,
4078 &msg))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004079 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304080 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004081 return;
4082 }
Jeff Johnson47d75242018-05-12 15:58:53 -07004083 pe_debug("Notified FW about OP mode: %d for staId=%d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004084 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004085
4086 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004087 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004088 }
4089
4090 return;
4091}
4092#endif
4093
4094/* -------------------------------------------------------------------- */
4095/**
4096 * __lim_process_report_message
4097 *
4098 * FUNCTION: Processes the next received Radio Resource Management message
4099 *
4100 * LOGIC:
4101 *
4102 * ASSUMPTIONS:
4103 *
4104 * NOTE:
4105 *
4106 * @param None
4107 * @return None
4108 */
4109
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004110static void __lim_process_report_message(tpAniSirGlobal pMac,
4111 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004112{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004113 switch (pMsg->type) {
4114 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4115 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4116 break;
4117 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004118 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004119 break;
4120 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004121 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004122 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004123}
4124
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004125/* -------------------------------------------------------------------- */
4126/**
4127 * lim_send_set_max_tx_power_req
4128 *
4129 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4130 *
4131 * LOGIC:
4132 *
4133 * ASSUMPTIONS:
4134 *
4135 * NOTE:
4136 *
4137 * @param txPower txPower to be set.
4138 * @param pSessionEntry session entry.
4139 * @return None
4140 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004141QDF_STATUS
Amar Singhala297bfa2015-10-15 15:07:29 -07004142lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004143 tpPESession pSessionEntry)
4144{
4145 tpMaxTxPowerParams pMaxTxParams = NULL;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004146 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004147 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004148
4149 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004150 pe_err("Invalid parameters");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004151 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004152 }
4153
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304154 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004155 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004156 pe_err("Unable to allocate memory for pMaxTxParams");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004157 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004158
4159 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004160 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304161 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304162 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304163 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004164 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304165 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004166
4167 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4168 msgQ.bodyptr = pMaxTxParams;
4169 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004170 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004171 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4172 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004173 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004174 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304175 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004176 }
4177 return retCode;
4178}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004179
4180/**
4181 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4182 *
4183 * @mac_ctx: Pointer to Global MAC structure
4184 * @msg_buf: pointer to the SME message buffer
4185 *
4186 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4187 * from SME. It Register this information within PE.
4188 *
4189 * Return: None
4190 */
4191static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4192 uint32_t *msg_buf)
4193{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304194 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004195 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4196 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4197 struct mgmt_frm_reg_info *next = NULL;
4198 bool match = false;
4199
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004200 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201 sme_req->registerFrame, sme_req->frameType,
4202 sme_req->matchLen);
4203 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304204 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304205 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4206 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304207 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004208
4209 while (lim_mgmt_regn != NULL) {
4210 if (lim_mgmt_regn->frameType != sme_req->frameType)
4211 goto skip_match;
4212 if (sme_req->matchLen) {
4213 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304214 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004215 sme_req->matchData,
4216 lim_mgmt_regn->matchLen))) {
4217 /* found match! */
4218 match = true;
4219 break;
4220 }
4221 } else {
4222 /* found match! */
4223 match = true;
4224 break;
4225 }
4226skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304227 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304228 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004229 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304230 (qdf_list_node_t *)lim_mgmt_regn,
4231 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304232 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004233 lim_mgmt_regn = next;
4234 next = NULL;
4235 }
4236 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304237 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004238 if (QDF_STATUS_SUCCESS ==
4239 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004240 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004241 (qdf_list_node_t *)lim_mgmt_regn))
4242 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304243 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004244 }
4245
4246 if (sme_req->registerFrame) {
4247 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304248 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004249 sme_req->matchLen);
4250 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004251 lim_mgmt_regn->frameType = sme_req->frameType;
4252 lim_mgmt_regn->matchLen = sme_req->matchLen;
4253 lim_mgmt_regn->sessionId = sme_req->sessionId;
4254 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304255 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004256 sme_req->matchData,
4257 sme_req->matchLen);
4258 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304259 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004260 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304261 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004262 gLimMgmtFrameRegistratinQueue,
4263 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304264 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004265 &mac_ctx->lim.lim_frame_register_lock);
4266 }
4267 }
4268 return;
4269}
4270
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004271static void
4272__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4273{
4274 tpSirResetAPCapsChange pResetCapsChange;
4275 tpPESession psessionEntry;
4276 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004277
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004278 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004279 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004280 return;
4281 }
4282
4283 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4284 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004285 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4286 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004287 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004288 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004289 return;
4290 }
4291
4292 psessionEntry->limSentCapsChangeNtf = false;
4293 return;
4294}
4295
4296/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304297 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4298 * indication callback in PE.
4299 * @mac_ptr: Mac pointer
4300 * @msg_buf: Msg pointer containing the callback
4301 *
4302 * This function is used save the Management frame
4303 * indication callback in PE.
4304 *
4305 * Return: None
4306 */
4307static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4308 uint32_t *msg_buf)
4309{
4310 struct sir_sme_mgmt_frame_cb_req *sme_req =
4311 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4312
4313 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004314 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304315 return;
4316 }
4317 if (sme_req->callback)
4318 mac_ctx->mgmt_frame_ind_cb =
4319 (sir_mgmt_frame_ind_callback)sme_req->callback;
4320 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004321 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304322}
4323
4324/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304325 *__lim_process_send_disassoc_frame: function processes disassoc frame
4326 * @mac_ctx: pointer to mac context
4327 * @msg_buf: message buffer
4328 *
4329 * function processes disassoc request received from SME
4330 *
4331 * return: none
4332 */
4333static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4334 uint32_t *msg_buf)
4335{
4336 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004337 QDF_STATUS status;
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304338 tpPESession session_entry = NULL;
4339 uint8_t sme_session_id;
4340 uint16_t sme_trans_id;
4341
4342 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004343 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304344 return;
4345 }
4346
4347 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4348 &sme_trans_id);
4349
4350 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4351 &sme_send_disassoc_frame_req,
4352 (uint8_t *)msg_buf);
4353
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004354 if ((QDF_STATUS_E_FAILURE == status) ||
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304355 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4356 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004357 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304358 return;
4359 }
4360
4361 session_entry = pe_find_session_by_sme_session_id(
4362 mac_ctx, sme_session_id);
4363 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004364 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304365 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4366 return;
4367 }
4368
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004369 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 +05304370 sme_send_disassoc_frame_req.msg_type,
4371 sme_send_disassoc_frame_req.length,
4372 sme_send_disassoc_frame_req.session_id,
4373 sme_send_disassoc_frame_req.trans_id,
4374 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4375 sme_send_disassoc_frame_req.reason,
4376 sme_send_disassoc_frame_req.wait_for_ack);
4377
4378 lim_send_disassoc_mgmt_frame(mac_ctx,
4379 sme_send_disassoc_frame_req.reason,
4380 sme_send_disassoc_frame_req.peer_mac,
4381 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4382}
4383
4384/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004385 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4386 * @mac_ctx: Pointer to Global MAC structure
4387 * @pdev_id: pdev id to set the IE.
4388 * @nss: Nss values to prepare the HT IE.
4389 *
4390 * Prepares the HT IE with self capabilities for different
4391 * Nss values and sends the set HT IE req to FW.
4392 *
4393 * Return: None
4394 */
4395static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4396 uint8_t nss)
4397{
4398 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004399 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004400 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004401 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004402 tHtCaps *p_ht_cap;
4403 int i;
4404
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004405 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004406 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4407 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004408 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004409 return;
4410 }
4411 ie_params->nss = i;
4412 ie_params->pdev_id = pdev_id;
4413 ie_params->ie_type = DOT11_HT_IE;
4414 /* 2 for IE len and EID */
4415 ie_params->ie_len = 2 + sizeof(tHtCaps);
4416 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4417 if (NULL == ie_params->ie_ptr) {
4418 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004419 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004420 return;
4421 }
4422 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4423 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4424 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4425 ie_params->ie_len);
4426
4427 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004428 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4429 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004430 if (NULL == p_ie) {
4431 qdf_mem_free(ie_params->ie_ptr);
4432 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004433 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004434 return;
4435 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004436 p_ht_cap = (tHtCaps *)&p_ie[2];
4437 p_ht_cap->supportedMCSSet[1] = 0;
4438 p_ht_cap->txSTBC = 0;
4439 }
4440
4441 msg.type = WMA_SET_PDEV_IE_REQ;
4442 msg.bodyptr = ie_params;
4443 msg.bodyval = 0;
4444
4445 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004446 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004447 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004448 qdf_mem_free(ie_params->ie_ptr);
4449 qdf_mem_free(ie_params);
4450 return;
4451 }
4452 }
4453}
4454
4455/**
4456 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4457 * @mac_ctx: Pointer to Global MAC structure
4458 * @pdev_id: pdev id to set the IE.
4459 * @nss: Nss values to prepare the VHT IE.
4460 *
4461 * Prepares the VHT IE with self capabilities for different
4462 * Nss values and sends the set VHT IE req to FW.
4463 *
4464 * Return: None
4465 */
4466static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4467 uint8_t nss)
4468{
4469 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004470 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004471 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004472 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004473 tSirMacVHTCapabilityInfo *vht_cap;
4474 int i;
4475 tSirVhtMcsInfo *vht_mcs;
4476
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004477 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004478 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4479 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004480 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004481 return;
4482 }
4483 ie_params->nss = i;
4484 ie_params->pdev_id = pdev_id;
4485 ie_params->ie_type = DOT11_VHT_IE;
4486 /* 2 for IE len and EID */
4487 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4488 sizeof(tSirVhtMcsInfo);
4489 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4490 if (NULL == ie_params->ie_ptr) {
4491 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004492 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004493 return;
4494 }
4495 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4496 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4497 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4498 ie_params->ie_len);
4499
4500 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004501 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4502 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004503 if (NULL == p_ie) {
4504 qdf_mem_free(ie_params->ie_ptr);
4505 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004506 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004507 return;
4508 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004509 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4510 vht_cap->txSTBC = 0;
4511 vht_mcs =
4512 (tSirVhtMcsInfo *)&p_ie[2 +
4513 sizeof(tSirMacVHTCapabilityInfo)];
4514 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4515 vht_mcs->rxHighest =
4516 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4517 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4518 vht_mcs->txHighest =
4519 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4520 }
4521 msg.type = WMA_SET_PDEV_IE_REQ;
4522 msg.bodyptr = ie_params;
4523 msg.bodyval = 0;
4524
4525 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004526 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004527 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004528 qdf_mem_free(ie_params->ie_ptr);
4529 qdf_mem_free(ie_params);
4530 return;
4531 }
4532 }
4533}
4534
4535/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004536 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4537 * @mac_ctx: Pointer to Global MAC structure
4538 * @msg_buf: Pointer to the SME message buffer
4539 *
4540 * This function is called by limProcessMessageQueue(). This function sets the
4541 * VDEV IEs to the FW.
4542 *
4543 * Return: None
4544 */
4545static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4546 uint32_t *msg_buf)
4547{
4548 struct sir_set_vdev_ies_per_band *p_msg =
4549 (struct sir_set_vdev_ies_per_band *)msg_buf;
4550
4551 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004552 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004553 return;
4554 }
4555
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004556 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004557 p_msg->vdev_id);
4558 /* intentionally using NULL here so that self capabilty are sent */
4559 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4560 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004561 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004562}
4563
4564/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004565 * lim_process_set_pdev_IEs() - process the set pdev IE req
4566 * @mac_ctx: Pointer to Global MAC structure
4567 * @msg_buf: Pointer to the SME message buffer
4568 *
4569 * This function is called by limProcessMessageQueue(). This
4570 * function sets the PDEV IEs to the FW.
4571 *
4572 * Return: None
4573 */
4574static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4575{
4576 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4577
4578 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4579
4580 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004581 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004582 return;
4583 }
4584
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004585 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004586 ht_vht_cfg->nss);
4587 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4588
4589 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4590 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4591 ht_vht_cfg->nss);
4592}
4593
4594/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304595 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4596 *
4597 * access policy
4598 * @mac_ctx: pointer to mac context
4599 * @msg: message buffer
4600 *
4601 * function processes vendor IE and access policy from SME and updates PE
4602 *
4603 * session entry
4604 *
4605 * return: none
4606*/
4607static void lim_process_sme_update_access_policy_vendor_ie(
4608 tpAniSirGlobal mac_ctx,
4609 uint32_t *msg)
4610{
4611 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4612 struct sPESession *pe_session_entry;
Pragaspathi Thilagaraj9b7a1162018-05-07 16:28:13 +05304613 uint16_t num_bytes;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304614
4615 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004616 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304617 return;
4618 }
4619 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4620 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4621 update_vendor_ie->sme_session_id);
4622
4623 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004624 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304625 update_vendor_ie->sme_session_id);
4626 return;
4627 }
4628 if (pe_session_entry->access_policy_vendor_ie)
4629 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4630
4631 num_bytes = update_vendor_ie->ie[1] + 2;
4632 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4633
4634 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004635 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304636 return;
4637 }
4638 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4639 &update_vendor_ie->ie[0], num_bytes);
4640
4641 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4642}
4643
4644/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004645 * lim_process_sme_req_messages()
4646 *
4647 ***FUNCTION:
4648 * This function is called by limProcessMessageQueue(). This
4649 * function processes SME request messages from HDD or upper layer
4650 * application.
4651 *
4652 ***LOGIC:
4653 *
4654 ***ASSUMPTIONS:
4655 *
4656 ***NOTE:
4657 *
4658 * @param pMac Pointer to Global MAC structure
4659 * @param msgType Indicates the SME message type
4660 * @param *pMsgBuf A pointer to the SME message buffer
4661 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4662 * false - if pMsgBuf is not to be freed.
4663 */
4664
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004665bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4666 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004667{
Jeff Johnson33142e62018-05-06 17:58:36 -07004668 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesn't want pMsgBuf to be freed. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004669 uint32_t *pMsgBuf = pMsg->bodyptr;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004670
4671 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004672 lim_msg_str(pMsg->type), pMsg->type,
4673 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4674 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004675
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004676 /* If no insert NOA required then execute the code below */
4677
4678 switch (pMsg->type) {
4679 case eWNI_SME_SYS_READY_IND:
4680 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4681 break;
4682
4683 case eWNI_SME_START_BSS_REQ:
4684 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4685 break;
4686
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004687 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4688 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4689 break;
4690 case eWNI_SME_JOIN_REQ:
4691 __lim_process_sme_join_req(pMac, pMsgBuf);
4692 break;
4693
4694 case eWNI_SME_REASSOC_REQ:
4695 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4696 break;
4697
4698 case eWNI_SME_DISASSOC_REQ:
4699 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4700 break;
4701
4702 case eWNI_SME_DISASSOC_CNF:
4703 case eWNI_SME_DEAUTH_CNF:
4704 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4705 break;
4706
4707 case eWNI_SME_DEAUTH_REQ:
4708 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4709 break;
4710
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304711 case eWNI_SME_SEND_DISASSOC_FRAME:
4712 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4713 break;
4714
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004715 case eWNI_SME_SETCONTEXT_REQ:
4716 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4717 break;
4718
4719 case eWNI_SME_STOP_BSS_REQ:
4720 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4721 break;
4722
4723 case eWNI_SME_ASSOC_CNF:
4724 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004725 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004726 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4727 pMsgBuf);
4728 break;
4729
4730 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004731 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004732 __lim_process_sme_addts_req(pMac, pMsgBuf);
4733 break;
4734
4735 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004736 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004737 __lim_process_sme_delts_req(pMac, pMsgBuf);
4738 break;
4739
4740 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004741 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004742 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4743 break;
4744
4745 case eWNI_SME_GET_STATISTICS_REQ:
4746 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4747 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4748 bufConsumed = false;
4749 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004750#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004751 case eWNI_SME_GET_TSM_STATS_REQ:
4752 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4753 bufConsumed = false;
4754 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004755#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004756 case eWNI_SME_GET_ASSOC_STAS_REQ:
4757 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4758 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304759 case eWNI_SME_SESSION_UPDATE_PARAM:
4760 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004761 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304762 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4763 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4764 bufConsumed = false;
4765 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004766 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4767 /* Update the beaconInterval */
4768 __lim_process_sme_change_bi(pMac, pMsgBuf);
4769 break;
4770
4771#ifdef QCA_HT_2040_COEX
4772 case eWNI_SME_SET_HT_2040_MODE:
4773 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4774 break;
4775#endif
4776
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004777 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4778 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4779 __lim_process_report_message(pMac, pMsg);
4780 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004781
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004782 case eWNI_SME_FT_PRE_AUTH_REQ:
4783 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4784 break;
4785 case eWNI_SME_FT_UPDATE_KEY:
4786 lim_process_ft_update_key(pMac, pMsgBuf);
4787 break;
4788
4789 case eWNI_SME_FT_AGGR_QOS_REQ:
4790 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4791 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004792
4793 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4794 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4795 break;
4796#ifdef FEATURE_WLAN_TDLS
4797 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4798 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4799 break;
4800 case eWNI_SME_TDLS_ADD_STA_REQ:
4801 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4802 break;
4803 case eWNI_SME_TDLS_DEL_STA_REQ:
4804 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4805 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004806#endif
4807 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4808 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4809 break;
4810
4811 case eWNI_SME_CHANNEL_CHANGE_REQ:
4812 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4813 break;
4814
4815 case eWNI_SME_START_BEACON_REQ:
4816 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4817 break;
4818
4819 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4820 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4821 break;
4822
4823 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4824 lim_process_update_add_ies(pMac, pMsgBuf);
4825 break;
4826
4827 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4828 lim_process_modify_add_ies(pMac, pMsgBuf);
4829 break;
4830 case eWNI_SME_SET_HW_MODE_REQ:
4831 lim_process_set_hw_mode(pMac, pMsgBuf);
4832 break;
4833 case eWNI_SME_NSS_UPDATE_REQ:
4834 lim_process_nss_update_request(pMac, pMsgBuf);
4835 break;
4836 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4837 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4838 break;
4839 case eWNI_SME_SET_IE_REQ:
4840 lim_process_set_ie_req(pMac, pMsgBuf);
4841 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304842 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4843 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
4844 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304845 case eWNI_SME_EXT_CHANGE_CHANNEL:
4846 lim_process_ext_change_channel(pMac, pMsgBuf);
4847 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08004848 case eWNI_SME_SET_ANTENNA_MODE_REQ:
4849 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
4850 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004851 case eWNI_SME_PDEV_SET_HT_VHT_IE:
4852 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07004853 break;
4854 case eWNI_SME_SET_VDEV_IES_PER_BAND:
4855 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
4856 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304857 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
4858 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
4859 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07004860 case eWNI_SME_UPDATE_CONFIG:
4861 lim_process_sme_update_config(pMac,
4862 (struct update_config *)pMsgBuf);
4863 break;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004864 case eWNI_SME_SET_ADDBA_ACCEPT:
4865 lim_process_sme_set_addba_accept(pMac,
4866 (struct sme_addba_accept *)pMsgBuf);
4867 break;
Arif Hussaineb8ba362018-03-07 19:15:13 -08004868 case eWNI_SME_UPDATE_EDCA_PROFILE:
4869 lim_process_sme_update_edca_params(pMac, pMsg->bodyval);
4870 break;
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07004871 case WNI_SME_UPDATE_MU_EDCA_PARAMS:
4872 lim_process_sme_update_mu_edca_params(pMac, pMsg->bodyval);
4873 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004874 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304875 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004876 pMsg->bodyptr = NULL;
4877 break;
4878 } /* switch (msgType) */
4879
4880 return bufConsumed;
4881} /*** end lim_process_sme_req_messages() ***/
4882
4883/**
4884 * lim_process_sme_start_beacon_req()
4885 *
4886 ***FUNCTION:
4887 * This function is called by limProcessMessageQueue(). This
4888 * function processes SME request messages from HDD or upper layer
4889 * application.
4890 *
4891 ***LOGIC:
4892 *
4893 ***ASSUMPTIONS:
4894 *
4895 ***NOTE:
4896 *
4897 * @param pMac Pointer to Global MAC structure
4898 * @param msgType Indicates the SME message type
4899 * @param *pMsgBuf A pointer to the SME message buffer
4900 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4901 * false - if pMsgBuf is not to be freed.
4902 */
4903static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
4904{
4905 tpSirStartBeaconIndication pBeaconStartInd;
4906 tpPESession psessionEntry;
4907 uint8_t sessionId; /* PE sessionID */
4908
4909 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004910 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004911 return;
4912 }
4913
4914 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
4915 psessionEntry = pe_find_session_by_bssid(pMac,
4916 pBeaconStartInd->bssid,
4917 &sessionId);
4918 if (psessionEntry == NULL) {
4919 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004920 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004921 return;
4922 }
4923
4924 if (pBeaconStartInd->beaconStartStatus == true) {
4925 /*
4926 * Currently this Indication comes from SAP
4927 * to start Beacon Tx on a DFS channel
4928 * since beaconing has to be done on DFS
4929 * channel only after CAC WAIT is completed.
4930 * On a DFS Channel LIM does not start beacon
4931 * Tx right after the WMA_ADD_BSS_RSP.
4932 */
4933 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05304934 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004935 FL("Start Beacon with ssid %s Ch %d"),
4936 psessionEntry->ssId.ssId,
4937 psessionEntry->currentOperChannel);
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05304938 lim_send_beacon(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08004939 lim_enable_obss_detection_config(pMac, psessionEntry);
Arif Hussain05fb4872018-01-03 16:02:55 -08004940 lim_send_obss_color_collision_cfg(pMac, psessionEntry,
4941 OBSS_COLOR_COLLISION_DETECTION);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004942 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004943 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004944 return;
4945 }
4946}
4947
4948/**
4949 * lim_process_sme_channel_change_request() - process sme ch change req
4950 *
4951 * @mac_ctx: Pointer to Global MAC structure
4952 * @msg_buf: pointer to the SME message buffer
4953 *
4954 * This function is called to process SME_CHANNEL_CHANGE_REQ message
4955 *
4956 * Return: None
4957 */
4958static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
4959 uint32_t *msg_buf)
4960{
4961 tpSirChanChangeRequest ch_change_req;
4962 tpPESession session_entry;
4963 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07004964 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004965 uint32_t val = 0;
4966
4967 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004968 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004969 return;
4970 }
4971 ch_change_req = (tpSirChanChangeRequest)msg_buf;
4972
4973 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
4974 ch_change_req->targetChannel);
4975
4976 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
4977 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004978 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004979 return;
4980 }
4981
4982 session_entry = pe_find_session_by_bssid(mac_ctx,
4983 ch_change_req->bssid, &session_id);
4984 if (session_entry == NULL) {
4985 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004986 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004987 return;
4988 }
4989
Manjunathappa Prakash34fda792018-02-07 18:23:42 -08004990 if ((session_entry->currentOperChannel ==
4991 ch_change_req->targetChannel) &&
4992 (session_entry->ch_width == ch_change_req->ch_width)) {
4993 pe_err("Target channel and mode is same as current channel and mode channel %d and mode %d",
4994 session_entry->currentOperChannel, session_entry->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004995 return;
4996 }
4997
4998 if (LIM_IS_AP_ROLE(session_entry))
4999 session_entry->channelChangeReasonCode =
5000 LIM_SWITCH_CHANNEL_SAP_DFS;
5001 else
5002 session_entry->channelChangeReasonCode =
5003 LIM_SWITCH_CHANNEL_OPERATION;
5004
Bala Venkateshb39ed152017-12-26 19:35:27 +05305005 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d, nw_type %d, dot11mode %d",
5006 session_entry->currentOperChannel,
5007 ch_change_req->targetChannel,
5008 ch_change_req->ch_width,
5009 ch_change_req->nw_type,
5010 ch_change_req->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005011
5012 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005013 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005014 session_entry->ch_center_freq_seg0 =
5015 ch_change_req->center_freq_seg_0;
5016 session_entry->ch_center_freq_seg1 =
5017 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005018 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005019 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005020 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005021 session_entry->htRecommendedTxWidthSet =
5022 session_entry->htSupportedChannelWidthSet;
5023 session_entry->currentOperChannel =
5024 ch_change_req->targetChannel;
5025 session_entry->limRFBand =
5026 lim_get_rf_band(session_entry->currentOperChannel);
Vignesh Viswanathan153ae932018-04-11 14:24:13 +05305027
5028 /* Update the global beacon filter */
5029 lim_update_bcn_probe_filter(mac_ctx, session_entry);
5030
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005031 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08005032 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005033 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005034 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005035 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005036 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005037 }
5038
5039 session_entry->lim11hEnable = val;
5040 session_entry->dot11mode = ch_change_req->dot11mode;
Bala Venkateshb39ed152017-12-26 19:35:27 +05305041 session_entry->nwType = ch_change_req->nw_type;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305042 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005043 &ch_change_req->operational_rateset,
5044 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305045 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005046 &ch_change_req->extended_rateset,
5047 sizeof(session_entry->extRateSet));
5048 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5049 session_entry->ch_center_freq_seg0,
5050 session_entry->ch_center_freq_seg1,
5051 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07005052 max_tx_pwr, session_entry->peSessionId,
5053 ch_change_req->cac_duration_ms,
5054 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005055}
5056
5057/******************************************************************************
5058* lim_start_bss_update_add_ie_buffer()
5059*
5060***FUNCTION:
5061* This function checks the src buffer and its length and then malloc for
5062* dst buffer update the same
5063*
5064***LOGIC:
5065*
5066***ASSUMPTIONS:
5067*
5068***NOTE:
5069*
5070* @param pMac Pointer to Global MAC structure
5071* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5072* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5073* @param *pSrcData_buff A pointer of uint8_t src buffer
5074* @param srcDataLen src buffer length
5075******************************************************************************/
5076
5077static void
5078lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5079 uint8_t **pDstData_buff,
5080 uint16_t *pDstDataLen,
5081 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5082{
5083
5084 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5085 *pDstDataLen = srcDataLen;
5086
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305087 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005088
5089 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005090 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005091 return;
5092 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305093 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005094 } else {
5095 *pDstData_buff = NULL;
5096 *pDstDataLen = 0;
5097 }
5098}
5099
5100/******************************************************************************
5101* lim_update_add_ie_buffer()
5102*
5103***FUNCTION:
5104* This function checks the src buffer and length if src buffer length more
5105* than dst buffer length then free the dst buffer and malloc for the new src
5106* length, and update the dst buffer and length. But if dst buffer is bigger
5107* than src buffer length then it just update the dst buffer and length
5108*
5109***LOGIC:
5110*
5111***ASSUMPTIONS:
5112*
5113***NOTE:
5114*
5115* @param pMac Pointer to Global MAC structure
5116* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5117* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5118* @param *pSrcData_buff A pointer of uint8_t src buffer
5119* @param srcDataLen src buffer length
5120******************************************************************************/
5121
5122static void
5123lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5124 uint8_t **pDstData_buff,
5125 uint16_t *pDstDataLen,
5126 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5127{
5128
5129 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005130 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005131 return;
5132 }
5133
5134 if (srcDataLen > *pDstDataLen) {
5135 *pDstDataLen = srcDataLen;
5136 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305137 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005138 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305139 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005140
5141 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005142 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005143 *pDstDataLen = 0;
5144 return;
5145 }
5146 }
5147
5148 /* copy the content of buffer into dst buffer
5149 */
5150 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305151 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005152
5153}
5154
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005155/**
5156 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5157 * @pMac : Pointer to Global MAC structure
5158 * @pDstData_buff : A pointer to pointer of dst buffer
5159 * @pDstDataLen : A pointer to pointer of dst buffer length
5160 * @pModifyIE : A pointer to tSirModifyIE
5161 *
5162 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5163 *
5164 * Return:
5165 * True or false depending upon whether IE is updated or not
5166 */
5167static bool
5168lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5169 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5170{
Hong Shi1553d692016-09-28 12:16:19 +08005171 int32_t oui_length;
5172 uint8_t *ibss_ie = NULL;
5173 uint8_t *vendor_ie;
5174#define MAC_VENDOR_OUI "\x00\x16\x32"
5175#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005176
5177 ibss_ie = pModifyIE->pIEBuffer;
5178 oui_length = pModifyIE->oui_length;
5179
5180 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005181 pe_err("Invalid set IBSS vendor IE command length %d",
5182 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005183 return false;
5184 }
5185
Hong Shi1553d692016-09-28 12:16:19 +08005186 /*
5187 * Why replace only beacon OUI data here:
5188 * 1. other ie (such as wpa) shall not be overwritten here.
5189 * 2. per spec, beacon oui ie might be set twice and original one
5190 * shall be updated.
5191 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005192 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005193 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5194 if (vendor_ie) {
5195 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5196 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5197 pModifyIE->ieBufferlength);
5198 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005199 uint16_t new_length;
5200 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005201
Naveen Rawat668dee32017-09-29 14:39:40 -07005202 /*
5203 * check for uint16 overflow before using sum of two numbers as
5204 * length of size to malloc
5205 */
5206 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5207 pe_err("U16 overflow due to %d + %d",
5208 pModifyIE->ieBufferlength, *pDstDataLen);
5209 return false;
5210 }
5211
5212 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5213 new_ptr = qdf_mem_malloc(new_length);
Hong Shi1553d692016-09-28 12:16:19 +08005214 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005215 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005216 return false;
5217 }
5218 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5219 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5220 pModifyIE->ieBufferlength);
5221 qdf_mem_free(*pDstData_buff);
5222 *pDstDataLen = new_length;
5223 *pDstData_buff = new_ptr;
5224 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005225 return true;
5226}
5227
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005228/*
5229* lim_process_modify_add_ies() - process modify additional IE req.
5230*
5231* @mac_ctx: Pointer to Global MAC structure
5232* @msg_buf: pointer to the SME message buffer
5233*
5234* This function update the PE buffers for additional IEs.
5235*
5236* Return: None
5237*/
5238static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5239 uint32_t *msg_buf)
5240{
5241 tpSirModifyIEsInd modify_add_ies;
5242 tpPESession session_entry;
5243 uint8_t session_id;
5244 bool ret = false;
5245 tSirAddIeParams *add_ie_params;
5246
5247 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005248 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005249 return;
5250 }
5251
5252 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5253 /* Incoming message has smeSession, use BSSID to find PE session */
5254 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005255 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005256
5257 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005258 pe_err("Session not found for given bssid"
5259 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005260 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005261 goto end;
5262 }
5263 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5264 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5265 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005266 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005267 modify_add_ies->modifyIE.pIEBuffer,
5268 modify_add_ies->modifyIE.ieBufferlength,
5269 modify_add_ies->modifyIE.ieID,
5270 modify_add_ies->modifyIE.ieIDLen,
5271 modify_add_ies->updateType);
5272 goto end;
5273 }
5274 add_ie_params = &session_entry->addIeParams;
5275 switch (modify_add_ies->updateType) {
5276 case eUPDATE_IE_PROBE_RESP:
5277 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005278 if (LIM_IS_IBSS_ROLE(session_entry)) {
5279 lim_update_ibss_prop_add_ies(mac_ctx,
5280 &add_ie_params->probeRespData_buff,
5281 &add_ie_params->probeRespDataLen,
5282 &modify_add_ies->modifyIE);
5283 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005284 break;
5285 case eUPDATE_IE_ASSOC_RESP:
5286 /* assoc resp IE */
5287 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305288 QDF_TRACE(QDF_MODULE_ID_PE,
5289 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005290 "assoc resp add ie not present %d"),
5291 add_ie_params->assocRespDataLen);
5292 }
5293 /* search through the buffer and modify the IE */
5294 break;
5295 case eUPDATE_IE_PROBE_BCN:
5296 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005297 if (LIM_IS_IBSS_ROLE(session_entry)) {
5298 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5299 &add_ie_params->probeRespBCNData_buff,
5300 &add_ie_params->probeRespBCNDataLen,
5301 &modify_add_ies->modifyIE);
5302 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005303 if (ret == true && modify_add_ies->modifyIE.notify) {
5304 lim_handle_param_update(mac_ctx,
5305 modify_add_ies->updateType);
5306 }
5307 break;
5308 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005309 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005310 modify_add_ies->updateType);
5311 break;
5312 }
5313end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305314 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005315 modify_add_ies->modifyIE.pIEBuffer = NULL;
5316}
5317
5318/*
5319* lim_process_update_add_ies() - process additional IE update req
5320*
5321* @mac_ctx: Pointer to Global MAC structure
5322* @msg_buf: pointer to the SME message buffer
5323*
5324* This function update the PE buffers for additional IEs.
5325*
5326* Return: None
5327*/
5328static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5329 uint32_t *msg_buf)
5330{
5331 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5332 uint8_t session_id;
5333 tpPESession session_entry;
5334 tSirAddIeParams *addn_ie;
5335 uint16_t new_length = 0;
5336 uint8_t *new_ptr = NULL;
5337 tSirUpdateIE *update_ie;
5338
5339 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005340 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005341 return;
5342 }
5343 update_ie = &update_add_ies->updateIE;
5344 /* incoming message has smeSession, use BSSID to find PE session */
5345 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005346 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005347
5348 if (NULL == session_entry) {
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05305349 pe_debug("Session not found for given bssid"
5350 MAC_ADDRESS_STR,
5351 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005352 goto end;
5353 }
5354 addn_ie = &session_entry->addIeParams;
5355 /* if len is 0, upper layer requested freeing of buffer */
5356 if (0 == update_ie->ieBufferlength) {
5357 switch (update_add_ies->updateType) {
5358 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305359 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005360 addn_ie->probeRespData_buff = NULL;
5361 addn_ie->probeRespDataLen = 0;
5362 break;
5363 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305364 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005365 addn_ie->assocRespData_buff = NULL;
5366 addn_ie->assocRespDataLen = 0;
5367 break;
5368 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305369 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005370 addn_ie->probeRespBCNData_buff = NULL;
5371 addn_ie->probeRespBCNDataLen = 0;
5372
5373 if (update_ie->notify)
5374 lim_handle_param_update(mac_ctx,
5375 update_add_ies->updateType);
5376 break;
5377 default:
5378 break;
5379 }
5380 return;
5381 }
5382 switch (update_add_ies->updateType) {
5383 case eUPDATE_IE_PROBE_RESP:
5384 if (update_ie->append) {
5385 /*
5386 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005387 * with combined length.
5388 * Multiple back to back append commands
5389 * can lead to a huge length.So, check
5390 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005391 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005392 if (addn_ie->probeRespDataLen >
5393 (USHRT_MAX - update_ie->ieBufferlength)) {
5394 pe_err("IE Length overflow, curr:%d, new:%d",
5395 addn_ie->probeRespDataLen,
5396 update_ie->ieBufferlength);
5397 goto end;
5398 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005399 new_length = update_ie->ieBufferlength +
5400 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305401 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005402 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005403 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005404 goto end;
5405 }
5406 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305407 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005408 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305409 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005410 update_ie->pAdditionIEBuffer,
5411 update_ie->ieBufferlength);
5412 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305413 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005414 /* adjust length accordingly */
5415 addn_ie->probeRespDataLen = new_length;
5416 /* save refernece of local buffer in PE session */
5417 addn_ie->probeRespData_buff = new_ptr;
5418 goto end;
5419 }
5420 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5421 &addn_ie->probeRespDataLen,
5422 update_ie->pAdditionIEBuffer,
5423 update_ie->ieBufferlength);
5424 break;
5425 case eUPDATE_IE_ASSOC_RESP:
5426 /* assoc resp IE */
5427 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5428 &addn_ie->assocRespDataLen,
5429 update_ie->pAdditionIEBuffer,
5430 update_ie->ieBufferlength);
5431 break;
5432 case eUPDATE_IE_PROBE_BCN:
5433 /* probe resp Bcn IE */
5434 lim_update_add_ie_buffer(mac_ctx,
5435 &addn_ie->probeRespBCNData_buff,
5436 &addn_ie->probeRespBCNDataLen,
5437 update_ie->pAdditionIEBuffer,
5438 update_ie->ieBufferlength);
5439 if (update_ie->notify)
5440 lim_handle_param_update(mac_ctx,
5441 update_add_ies->updateType);
5442 break;
5443 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005444 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005445 break;
5446 }
5447end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305448 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005449 update_ie->pAdditionIEBuffer = NULL;
5450}
5451
5452/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305453 * send_extended_chan_switch_action_frame()- function to send ECSA
5454 * action frame for each sta connected to SAP/GO and AP in case of
5455 * STA .
5456 * @mac_ctx: pointer to global mac structure
5457 * @new_channel: new channel to switch to.
5458 * @ch_bandwidth: BW of channel to calculate op_class
5459 * @session_entry: pe session
5460 *
5461 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5462 *
5463 * Return: void
5464 */
5465
5466static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5467 uint16_t new_channel, uint8_t ch_bandwidth,
5468 tpPESession session_entry)
5469{
5470 uint16_t op_class;
5471 uint8_t switch_mode = 0, i;
5472 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005473 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305474
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005475 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305476 mac_ctx->scan.countryCodeCurrent,
5477 new_channel,
5478 ch_bandwidth);
5479
5480 if (LIM_IS_AP_ROLE(session_entry) &&
5481 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005482 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305483
gaoleze2920bd2017-03-21 17:38:42 +08005484 switch_count = session_entry->gLimChannelSwitch.switchCount;
5485
Abhishek Singh518323d2015-10-19 17:42:01 +05305486 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005487 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305488 psta =
5489 session_entry->dph.dphHashTable.pDphNodeArray + i;
5490 if (psta && psta->added)
5491 lim_send_extended_chan_switch_action_frame(
5492 mac_ctx,
5493 psta->staAddr,
5494 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005495 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305496 }
5497 } else if (LIM_IS_STA_ROLE(session_entry)) {
5498 lim_send_extended_chan_switch_action_frame(mac_ctx,
5499 session_entry->bssId,
5500 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005501 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305502 }
5503
5504}
5505
gaolez76d2a162017-03-21 19:23:58 +08005506void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5507 uint16_t new_channel,
5508 uint8_t ch_bandwidth,
5509 tpPESession session_entry)
5510{
5511 uint16_t op_class;
5512 uint8_t switch_mode = 0, i;
5513 uint8_t switch_count;
5514 tpDphHashNode psta;
5515 tpDphHashNode dph_node_array_ptr;
5516
5517 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5518
5519 op_class = wlan_reg_dmn_get_opclass_from_channel(
5520 mac_ctx->scan.countryCodeCurrent,
5521 new_channel, ch_bandwidth);
5522
5523 if (LIM_IS_AP_ROLE(session_entry) &&
5524 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5525 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5526
5527 switch_count = session_entry->gLimChannelSwitch.switchCount;
5528
5529 if (LIM_IS_AP_ROLE(session_entry)) {
5530 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5531 psta = dph_node_array_ptr + i;
5532 if (!(psta && psta->added))
5533 continue;
5534 if (session_entry->lim_non_ecsa_cap_num == 0)
5535 lim_send_extended_chan_switch_action_frame
5536 (mac_ctx, psta->staAddr, switch_mode,
5537 op_class, new_channel, switch_count,
5538 session_entry);
5539 else
5540 lim_send_channel_switch_mgmt_frame
5541 (mac_ctx, psta->staAddr, switch_mode,
5542 new_channel, switch_count,
5543 session_entry);
5544 }
5545 } else if (LIM_IS_STA_ROLE(session_entry)) {
5546 lim_send_extended_chan_switch_action_frame
5547 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5548 new_channel, switch_count, session_entry);
5549 }
5550}
5551
5552/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005553 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5554 *
5555 * @mac_ctx: Pointer to Global MAC structure
5556 * @msg_buf: pointer to the SME message buffer
5557 *
5558 * This function processes SME request messages from HDD or upper layer
5559 * application.
5560 *
5561 * Return: None
5562 */
5563static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5564 uint32_t *msg_buf)
5565{
5566 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5567 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005568 uint8_t session_id;
5569 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005570 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005571
5572 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005573 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005574 return;
5575 }
5576
5577 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5578 session_entry = pe_find_session_by_bssid(mac_ctx,
5579 dfs_csa_ie_req->bssid, &session_id);
5580 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005581 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005582 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5583 return;
5584 }
5585
5586 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005587 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005588 GET_LIM_SYSTEM_ROLE(session_entry));
5589 return;
5590 }
5591
5592 /* target channel */
5593 session_entry->gLimChannelSwitch.primaryChannel =
5594 dfs_csa_ie_req->targetChannel;
5595
5596 /* Channel switch announcement needs to be included in beacon */
5597 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005598 session_entry->gLimChannelSwitch.switchCount =
5599 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005600 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005601 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305602 session_entry->gLimChannelSwitch.sec_ch_offset =
5603 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005604 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005605 session_entry->gLimChannelSwitch.switchMode =
5606 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005607
5608 /*
5609 * Validate if SAP is operating HT or VHT mode and set the Channel
5610 * Switch Wrapper element with the Wide Band Switch subelement.
5611 */
5612 if (true != session_entry->vhtCapability)
5613 goto skip_vht;
5614
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005615 /* Now encode the Wider Ch BW element depending on the ch width */
5616 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005617 switch (dfs_csa_ie_req->ch_params.ch_width) {
5618 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005619 /*
5620 * Wide channel BW sublement in channel wrapper element is not
5621 * required in case of 20 Mhz operation. Currently It is set
5622 * only set in case of 40/80 Mhz Operation.
5623 */
5624 session_entry->dfsIncludeChanWrapperIe = false;
5625 wider_bw_ch_switch->newChanWidth =
5626 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5627 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005628 case CH_WIDTH_40MHZ:
5629 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005630 wider_bw_ch_switch->newChanWidth =
5631 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5632 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005633 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005634 session_entry->dfsIncludeChanWrapperIe = true;
5635 wider_bw_ch_switch->newChanWidth =
5636 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5637 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005638 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005639 session_entry->dfsIncludeChanWrapperIe = true;
5640 wider_bw_ch_switch->newChanWidth =
5641 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5642 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005643 case CH_WIDTH_80P80MHZ:
5644 session_entry->dfsIncludeChanWrapperIe = true;
5645 wider_bw_ch_switch->newChanWidth =
5646 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005647 /*
5648 * This is not applicable for 20/40/80 Mhz.
5649 * Only used when we support 80+80 Mhz operation.
5650 * In case of 80+80 Mhz, this parameter indicates
5651 * center channel frequency index of 80 Mhz channel of
5652 * frequency segment 1.
5653 */
5654 wider_bw_ch_switch->newCenterChanFreq1 =
5655 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005656 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005657 default:
5658 session_entry->dfsIncludeChanWrapperIe = false;
5659 /*
5660 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5661 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5662 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005663 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005664 break;
5665 }
5666 /* Fetch the center channel based on the channel width */
5667 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005668 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005669skip_vht:
5670 /* Send CSA IE request from here */
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05305671 lim_send_dfs_chan_sw_ie_update(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305672
5673 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5674 ch_offset = BW80;
5675 else
5676 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5677
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005678 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305679 session_entry->gLimChannelSwitch.switchCount,
5680 session_entry->gLimChannelSwitch.primaryChannel,
5681 session_entry->gLimChannelSwitch.ch_width,
5682 session_entry->dfsIncludeChanWrapperIe,
5683 ch_offset);
5684
gaolez76d2a162017-03-21 19:23:58 +08005685 /* Send ECSA/CSA Action frame after updating the beacon */
5686 if (CHAN_HOP_ALL_BANDS_ENABLE)
5687 lim_send_chan_switch_action_frame(mac_ctx,
5688 session_entry->gLimChannelSwitch.primaryChannel,
5689 ch_offset, session_entry);
5690 else
5691 send_extended_chan_switch_action_frame(mac_ctx,
5692 session_entry->gLimChannelSwitch.primaryChannel,
5693 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005694}
5695
5696/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305697 * lim_process_ext_change_channel()- function to send ECSA
5698 * action frame for STA/CLI .
5699 * @mac_ctx: pointer to global mac structure
5700 * @msg: params from sme for new channel.
5701 *
5702 * This function is called to send ECSA frame for STA/CLI.
5703 *
5704 * Return: void
5705 */
5706
5707static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5708 uint32_t *msg)
5709{
5710 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5711 (struct sir_sme_ext_cng_chan_req *) msg;
5712 tpPESession session_entry = NULL;
5713
5714 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005715 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305716 return;
5717 }
5718 session_entry =
5719 pe_find_session_by_sme_session_id(mac_ctx,
5720 ext_chng_channel->session_id);
5721 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005722 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305723 ext_chng_channel->session_id);
5724 return;
5725 }
5726 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005727 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305728 return;
5729 }
5730 send_extended_chan_switch_action_frame(mac_ctx,
5731 ext_chng_channel->new_channel,
5732 0, session_entry);
5733}
5734
5735/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005736 * lim_process_nss_update_request() - process sme nss update req
5737 *
5738 * @mac_ctx: Pointer to Global MAC structure
5739 * @msg_buf: pointer to the SME message buffer
5740 *
5741 * This function processes SME request messages from HDD or upper layer
5742 * application.
5743 *
5744 * Return: None
5745 */
5746static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5747 uint32_t *msg_buf)
5748{
5749 struct sir_nss_update_request *nss_update_req_ptr;
5750 tpPESession session_entry = NULL;
5751
5752 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005753 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005754 return;
5755 }
5756
5757 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305758 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005759 nss_update_req_ptr->vdev_id);
5760 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005761 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005762 nss_update_req_ptr->vdev_id);
5763 return;
5764 }
5765
5766 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005767 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005768 GET_LIM_SYSTEM_ROLE(session_entry));
5769 return;
5770 }
5771
5772 /* populate nss field in the beacon */
5773 session_entry->gLimOperatingMode.present = 1;
5774 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05305775 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
5776
5777 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
5778 (session_entry->ch_width > CH_WIDTH_80MHZ))
5779 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
5780
5781 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
5782
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005783 /* Send nss update request from here */
5784 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005785 QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005786 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005787 return;
5788 }
5789
5790 lim_send_beacon_ind(mac_ctx, session_entry);
5791}
5792
5793/**
5794 * lim_process_set_ie_req() - process sme set IE request
5795 *
5796 * @mac_ctx: Pointer to Global MAC structure
5797 * @msg_buf: pointer to the SME message buffer
5798 *
5799 * This function processes SME request messages from HDD or upper layer
5800 * application.
5801 *
5802 * Return: None
5803 */
5804static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5805{
5806 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305807 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005808
5809 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005810 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005811 return;
5812 }
5813
5814 msg = (struct send_extcap_ie *)msg_buf;
5815 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305816 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005817 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005818
5819}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005820
5821#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Arif Hussain05fb4872018-01-03 16:02:55 -08005822
5823/**
5824 * obss_color_collision_process_color_disable() - Disable bss color
5825 * @mac_ctx: Pointer to Global MAC structure
5826 * @session: pointer to session
5827 *
5828 * This function will disbale bss color.
5829 *
5830 * Return: None
5831 */
5832static void obss_color_collision_process_color_disable(tpAniSirGlobal mac_ctx,
5833 tpPESession session)
5834{
5835 tUpdateBeaconParams beacon_params;
5836
5837 if (!session) {
5838 pe_err("Invalid session");
5839 return;
5840 }
5841
5842 if (session->valid && !LIM_IS_AP_ROLE(session)) {
5843 pe_err("Invalid SystemRole %d",
5844 GET_LIM_SYSTEM_ROLE(session));
5845 return;
5846 }
5847
5848 if (session->bss_color_changing == 1) {
5849 pe_warn("%d: color change in progress", session->smeSessionId);
5850 /* Continue color collision detection */
5851 lim_send_obss_color_collision_cfg(mac_ctx, session,
5852 OBSS_COLOR_COLLISION_DETECTION);
5853 return;
5854 }
5855
5856 if (session->he_op.bss_col_disabled == 1) {
5857 pe_warn("%d: bss color already disabled",
5858 session->smeSessionId);
5859 /* Continue free color detection */
5860 lim_send_obss_color_collision_cfg(mac_ctx, session,
5861 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5862 return;
5863 }
5864
5865 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5866 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5867 session->he_op.bss_col_disabled = 1;
Arif Hussain05fb4872018-01-03 16:02:55 -08005868 beacon_params.bss_color_disabled = 1;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005869 beacon_params.bss_color = session->he_op.bss_color;
Arif Hussain05fb4872018-01-03 16:02:55 -08005870
5871 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005872 QDF_STATUS_SUCCESS) {
Arif Hussain05fb4872018-01-03 16:02:55 -08005873 pe_err("Unable to set op mode IE in beacon");
5874 return;
5875 }
5876
5877 lim_send_beacon_params(mac_ctx, &beacon_params, session);
5878 lim_send_obss_color_collision_cfg(mac_ctx, session,
5879 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5880}
5881
5882/**
5883 * obss_color_collision_process_color_change() - Process bss color change
5884 * @mac_ctx: Pointer to Global MAC structure
5885 * @session: pointer to session
5886 * @obss_color_info: obss color collision/free slot indication info
5887 *
5888 * This function selects new color ib case of bss color collision.
5889 *
5890 * Return: None
5891 */
5892static void obss_color_collision_process_color_change(tpAniSirGlobal mac_ctx,
5893 tpPESession session,
5894 struct wmi_obss_color_collision_info *obss_color_info)
5895{
5896 int i, num_bss_color = 0;
5897 uint32_t bss_color_bitmap;
5898 uint8_t bss_color_index_array[MAX_BSS_COLOR_VALUE];
5899 uint32_t rand_byte = 0;
5900 struct sir_set_he_bss_color he_bss_color;
5901 bool is_color_collision = false;
5902
5903
5904 if (session->bss_color_changing == 1) {
5905 pe_err("%d: color change in progress", session->smeSessionId);
5906 return;
5907 }
5908
5909 if (!session->he_op.bss_col_disabled) {
5910 if (session->he_op.bss_color < 32)
5911 is_color_collision = (obss_color_info->
5912 obss_color_bitmap_bit0to31 >>
5913 session->he_op.bss_color) & 0x01;
5914 else
5915 is_color_collision = (obss_color_info->
5916 obss_color_bitmap_bit32to63 >>
5917 (session->he_op.bss_color -
Arif Hussain9e8c5612018-04-12 16:35:48 -07005918 32)) & 0x01;
Arif Hussain05fb4872018-01-03 16:02:55 -08005919 if (!is_color_collision) {
5920 pe_err("%d: color collision not found, curr_color: %d",
5921 session->smeSessionId,
5922 session->he_op.bss_color);
5923 return;
5924 }
5925 }
5926
5927 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit0to31;
5928
5929 /* Skip color zero */
5930 bss_color_bitmap = bss_color_bitmap >> 1;
5931 for (i = 0; (i < 31) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5932 if (!(bss_color_bitmap & 0x01)) {
5933 bss_color_index_array[num_bss_color] = i + 1;
5934 num_bss_color++;
5935 }
5936 bss_color_bitmap = bss_color_bitmap >> 1;
5937 }
5938
5939 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit32to63;
5940 for (i = 0; (i < 32) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5941 if (!(bss_color_bitmap & 0x01)) {
5942 bss_color_index_array[num_bss_color] = i + 32;
5943 num_bss_color++;
5944 }
5945 bss_color_bitmap = bss_color_bitmap >> 1;
5946 }
5947
5948 if (num_bss_color) {
5949 qdf_get_random_bytes((void *) &rand_byte, 1);
5950 i = (rand_byte + qdf_mc_timer_get_system_ticks()) %
5951 num_bss_color;
5952 pe_debug("New bss color = %d", bss_color_index_array[i]);
5953 he_bss_color.session_id = obss_color_info->vdev_id;
5954 he_bss_color.bss_color = bss_color_index_array[i];
5955 lim_process_set_he_bss_color(mac_ctx,
5956 (uint32_t *)&he_bss_color);
5957 } else {
5958 pe_err("Unable to find bss color from bitmasp");
5959 if (obss_color_info->evt_type ==
5960 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY &&
5961 session->obss_color_collision_dec_evt ==
5962 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
5963 /* In dot11BSSColorCollisionAPPeriod and
5964 * timer expired, time to disable bss color.
5965 */
5966 obss_color_collision_process_color_disable(mac_ctx,
5967 session);
5968 else
5969 /*
5970 * Enter dot11BSSColorCollisionAPPeriod period.
5971 */
5972 lim_send_obss_color_collision_cfg(mac_ctx, session,
5973 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY);
5974 }
5975}
5976
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005977void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5978{
5979 struct sir_set_he_bss_color *bss_color;
5980 tpPESession session_entry = NULL;
5981 tUpdateBeaconParams beacon_params;
5982
5983 if (!msg_buf) {
5984 pe_err("Buffer is Pointing to NULL");
5985 return;
5986 }
5987
5988 bss_color = (struct sir_set_he_bss_color *)msg_buf;
5989 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5990 bss_color->session_id);
5991 if (!session_entry) {
5992 pe_err("Session not found for given session_id %d",
5993 bss_color->session_id);
5994 return;
5995 }
5996
5997 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5998 pe_err("Invalid SystemRole %d",
5999 GET_LIM_SYSTEM_ROLE(session_entry));
6000 return;
6001 }
6002
6003 if (bss_color->bss_color == session_entry->he_op.bss_color) {
6004 pe_err("No change in BSS color, current BSS color %d",
6005 bss_color->bss_color);
6006 return;
6007 }
6008 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
6009 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
6010 session_entry->he_op.bss_col_disabled = 1;
6011 session_entry->he_bss_color_change.countdown =
6012 BSS_COLOR_SWITCH_COUNTDOWN;
6013 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08006014 beacon_params.bss_color_disabled = 1;
6015 beacon_params.bss_color = session_entry->he_op.bss_color;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006016 session_entry->bss_color_changing = 1;
6017
6018 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006019 QDF_STATUS_SUCCESS) {
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006020 pe_err("Unable to set op mode IE in beacon");
6021 return;
6022 }
6023
6024 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
Arif Hussain05fb4872018-01-03 16:02:55 -08006025 lim_send_obss_color_collision_cfg(mac_ctx, session_entry,
6026 OBSS_COLOR_COLLISION_DETECTION_DISABLE);
6027}
6028
6029void lim_send_obss_color_collision_cfg(tpAniSirGlobal mac_ctx,
6030 tpPESession session,
6031 enum wmi_obss_color_collision_evt_type
6032 event_type)
6033{
6034 struct wmi_obss_color_collision_cfg_param *cfg_param;
6035 struct scheduler_msg msg = {0};
6036
6037 if (!session) {
6038 pe_err("Invalid session");
6039 return;
6040 }
6041
6042 if (!session->he_capable ||
6043 !session->is_session_obss_color_collision_det_enabled) {
6044 pe_debug("%d: obss color det not enabled, he_cap:%d, sup:%d:%d",
6045 session->smeSessionId, session->he_capable,
6046 session->is_session_obss_color_collision_det_enabled,
6047 mac_ctx->lim.global_obss_color_collision_det_offload);
6048 return;
6049 }
6050
6051 cfg_param = qdf_mem_malloc(sizeof(*cfg_param));
6052 if (!cfg_param) {
6053 pe_err("Failed to allocate memory");
6054 return;
6055 }
6056
6057 pe_debug("%d: sending event:%d", session->smeSessionId, event_type);
6058 qdf_mem_zero(cfg_param, sizeof(*cfg_param));
6059 cfg_param->vdev_id = session->smeSessionId;
6060 cfg_param->evt_type = event_type;
6061 if (LIM_IS_AP_ROLE(session))
6062 cfg_param->detection_period_ms =
6063 OBSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS;
6064 else
6065 cfg_param->detection_period_ms =
6066 OBSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS;
6067
6068 cfg_param->scan_period_ms = OBSS_COLOR_COLLISION_SCAN_PERIOD_MS;
6069 if (event_type == OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6070 cfg_param->free_slot_expiry_time_ms =
6071 OBSS_COLOR_COLLISION_FREE_SLOT_EXPIRY_MS;
6072
6073 msg.type = WMA_OBSS_COLOR_COLLISION_REQ;
6074 msg.bodyptr = cfg_param;
6075 msg.reserved = 0;
6076
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05306077 if (QDF_IS_STATUS_ERROR(scheduler_post_message(QDF_MODULE_ID_PE,
6078 QDF_MODULE_ID_WMA,
6079 QDF_MODULE_ID_WMA,
6080 &msg))) {
Arif Hussain05fb4872018-01-03 16:02:55 -08006081 pe_err("Failed to post WMA_OBSS_COLOR_COLLISION_REQ to WMA");
6082 qdf_mem_free(cfg_param);
6083 } else {
6084 session->obss_color_collision_dec_evt = event_type;
6085 }
6086}
6087
6088void lim_process_obss_color_collision_info(tpAniSirGlobal mac_ctx,
6089 uint32_t *msg_buf)
6090{
6091 struct wmi_obss_color_collision_info *obss_color_info;
6092 tpPESession session;
6093
6094 if (!msg_buf) {
6095 pe_err("Buffer is Pointing to NULL");
6096 return;
6097 }
6098
6099 obss_color_info = (struct wmi_obss_color_collision_info *)msg_buf;
6100 session = pe_find_session_by_sme_session_id(mac_ctx,
6101 obss_color_info->vdev_id);
6102 if (!session) {
6103 pe_err("Session not found for given session_id %d",
6104 obss_color_info->vdev_id);
6105 return;
6106 }
6107
6108 pe_debug("vdev_id:%d, evt:%d:%d, 0to31:0x%x, 32to63:0x%x, cap:%d:%d:%d",
6109 obss_color_info->vdev_id,
6110 obss_color_info->evt_type,
6111 session->obss_color_collision_dec_evt,
6112 obss_color_info->obss_color_bitmap_bit0to31,
6113 obss_color_info->obss_color_bitmap_bit32to63,
6114 session->he_capable,
6115 session->is_session_obss_color_collision_det_enabled,
6116 mac_ctx->lim.global_obss_color_collision_det_offload);
6117
6118 if (!session->he_capable ||
6119 !session->is_session_obss_color_collision_det_enabled) {
6120 return;
6121 }
6122
6123 switch (obss_color_info->evt_type) {
6124 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
6125 pe_err("%d: FW disabled obss color det. he_cap:%d, sup:%d:%d",
6126 session->smeSessionId, session->he_capable,
6127 session->is_session_obss_color_collision_det_enabled,
6128 mac_ctx->lim.global_obss_color_collision_det_offload);
6129 session->is_session_obss_color_collision_det_enabled = false;
6130 return;
6131 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
6132 case OBSS_COLOR_COLLISION_DETECTION:
6133 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
6134 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6135 pe_debug("Invalid System Role %d",
6136 GET_LIM_SYSTEM_ROLE(session));
6137 return;
6138 }
6139
6140 if (session->obss_color_collision_dec_evt !=
6141 obss_color_info->evt_type) {
6142 pe_debug("%d: Wrong event: %d, skiping",
6143 obss_color_info->vdev_id,
6144 obss_color_info->evt_type);
6145 return;
6146 }
6147 obss_color_collision_process_color_change(mac_ctx, session,
6148 obss_color_info);
6149 break;
6150 default:
6151 pe_err("%d: Invalid event type %d",
6152 obss_color_info->vdev_id, obss_color_info->evt_type);
6153 return;
6154 }
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006155}
6156#endif