blob: e53d1702a73b631dcc04098041c3184653ac7d43 [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
Abhishek Singhc5a54082018-09-12 16:08:03 +05302975 if (wlan_vdev_mlme_get_substate(session->vdev) ==
2976 WLAN_VDEV_SS_START_RESTART_PROGRESS)
2977 status =
2978 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
2979 WLAN_VDEV_SM_EV_RESTART_REQ_FAIL,
Abhishek Singhcaa61852018-09-12 15:50:04 +05302980 sizeof(*session), session);
Abhishek Singhc5a54082018-09-12 16:08:03 +05302981 else
2982 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
2983 WLAN_VDEV_SM_EV_DOWN,
2984 sizeof(*session),
2985 session);
Abhishek Singhcaa61852018-09-12 15:50:04 +05302986 if (QDF_IS_STATUS_ERROR(status)) {
2987 pe_err("failed to post WLAN_VDEV_SM_EV_DOWN for vdevid %d",
2988 session->smeSessionId);
2989 lim_send_stop_bss_failure_resp(mac_ctx, session);
2990 }
2991}
2992#else
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302993static void lim_delete_peers_and_send_vdev_stop(tpPESession session)
2994{
2995 lim_delete_all_peers(session);
2996 /* send a delBss to HAL and wait for a response */
2997 lim_send_vdev_stop(session);
2998}
Abhishek Singhcaa61852018-09-12 15:50:04 +05302999#endif
3000
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303001
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003002static void
3003__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3004{
3005 tSirSmeStopBssReq stopBssReq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003006 tLimSmeStates prevState;
3007 tpPESession psessionEntry;
3008 uint8_t smesessionId;
3009 uint8_t sessionId;
3010 uint16_t smetransactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003011
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303012 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003013 smesessionId = stopBssReq.sessionId;
3014 smetransactionId = stopBssReq.transactionId;
3015
3016 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003017 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003018 /* Send Stop BSS response to host */
3019 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3020 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3021 smetransactionId);
3022 return;
3023 }
3024
3025 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003026 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003027 &sessionId);
3028 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003029 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003030 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3031 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3032 smetransactionId);
3033 return;
3034 }
3035#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3036 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3037 0, 0);
3038#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3039
3040 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3041 LIM_IS_STA_ROLE(psessionEntry)) {
3042 /**
3043 * Should not have received STOP_BSS_REQ in states
3044 * other than 'normal' state or on STA in Infrastructure
3045 * mode. Log error and return response to host.
3046 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003047 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003048 psessionEntry->limSmeState,
3049 GET_LIM_SYSTEM_ROLE(psessionEntry));
3050 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3051 /* / Send Stop BSS response to host */
3052 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3053 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3054 smetransactionId);
3055 return;
3056 }
3057
3058 if (LIM_IS_AP_ROLE(psessionEntry))
3059 lim_wpspbc_close(pMac, psessionEntry);
3060
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003061 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003062 stopBssReq.reasonCode);
3063
3064 prevState = psessionEntry->limSmeState;
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303065 psessionEntry->limPrevSmeState = prevState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003066
3067 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3068 MTRACE(mac_trace
3069 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3070 psessionEntry->limSmeState));
3071
3072 /* Update SME session Id and Transaction Id */
3073 psessionEntry->smeSessionId = smesessionId;
3074 psessionEntry->transactionId = smetransactionId;
3075
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003076 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3077 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3078 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003079 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003080
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003081 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3082 /* Send disassoc all stations associated thru TKIP */
3083 __lim_counter_measures(pMac, psessionEntry);
3084 else
3085 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003086 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3087 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003088 }
3089
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003090 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3091 /* Free the buffer allocated in START_BSS_REQ */
3092 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3093 psessionEntry->addIeParams.probeRespDataLen = 0;
3094 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003095
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003096 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3097 psessionEntry->addIeParams.assocRespDataLen = 0;
3098 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003099
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003100 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3101 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3102 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003103
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003104 /*
3105 * lim_del_bss is also called as part of coalescing,
3106 * when we send DEL BSS followed by Add Bss msg.
3107 */
3108 pMac->lim.gLimIbssCoalescingHappened = false;
3109 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003110
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303111 lim_delete_peers_and_send_vdev_stop(psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003112
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003113}
3114
3115/**
3116 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3117 * @pMac: Global MAC context
3118 * @pMsg: Message from SME
3119 *
3120 * Wrapper for the function __lim_handle_sme_stop_bss_request
3121 * This message will be defered until softmac come out of
3122 * scan mode. Message should be handled even if we have
3123 * detected radar in the current operating channel.
3124 *
3125 * Return: true - If we consumed the buffer
3126 * false - If have defered the message.
3127 */
3128
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003129static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3130 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003131{
3132 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3133 /**
3134 * If message defered, buffer is not consumed yet.
3135 * So return false
3136 */
3137 return false;
3138 }
3139 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3140 return true;
3141} /*** end __lim_process_sme_stop_bss_req() ***/
3142
3143void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3144 uint32_t body, tpPESession psessionEntry)
3145{
3146
3147 (void)body;
3148 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3149 lim_ibss_delete(pMac, psessionEntry);
3150 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3151 lim_delete_pre_auth_list(pMac);
3152 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3153 psessionEntry->smeSessionId,
3154 psessionEntry->transactionId);
3155 return;
3156}
3157
3158/**
3159 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3160 *
3161 * @mac_ctx: pointer to mac context
3162 * @msg_type: message type
3163 * @msg_buf: pointer to the SME message buffer
3164 *
3165 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3166 * in BTAMP AP.
3167 *
3168 * Return: None
3169 */
3170
3171void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3172 uint32_t *msg_buf)
3173{
3174 tSirSmeAssocCnf assoc_cnf;
3175 tpDphHashNode sta_ds = NULL;
3176 tpPESession session_entry = NULL;
3177 uint8_t session_id;
3178 tpSirAssocReq assoc_req;
3179
3180 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003181 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003182 goto end;
3183 }
3184
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303185 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003186 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003187 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003188 goto end;
3189 }
3190
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003191 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192 &session_id);
3193 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003194 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003195 goto end;
3196 }
3197
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003198 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003199 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3200 (session_entry->limSmeState !=
3201 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003202 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003203 msg_type, session_entry->limSmeState,
3204 GET_LIM_SYSTEM_ROLE(session_entry));
3205 goto end;
3206 }
3207 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3208 &session_entry->dph.dphHashTable);
3209 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003210 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003211 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303212 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003213
3214 /*
3215 * send a DISASSOC_IND message to WSM to make sure
3216 * the state in WSM and LIM is the same
3217 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003218 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003219 eSIR_SME_STA_NOT_ASSOCIATED,
3220 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3221 session_entry->smeSessionId,
3222 session_entry->transactionId,
3223 session_entry);
3224 goto end;
3225 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303226 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003227 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303228 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003229 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003230 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303231 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003232 goto end;
3233 }
3234
3235 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3236 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3237 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3238 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3239 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003240 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3241 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003242 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303243 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003244 goto end;
3245 }
3246 /*
3247 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3248 * has been received
3249 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003250 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003251 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3252 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3253
3254 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3255 /*
3256 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3257 * when it had received Assoc Request frame. Now, PE just needs
3258 * to send association rsp frame to the requesting BTAMP-STA.
3259 */
3260 sta_ds->mlmStaContext.mlmState =
3261 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003262 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003263 sta_ds->assocId);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003264 lim_send_assoc_rsp_mgmt_frame(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003265 sta_ds->assocId, sta_ds->staAddr,
3266 sta_ds->mlmStaContext.subType, sta_ds,
3267 session_entry);
3268 goto end;
3269 } else {
3270 /*
3271 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3272 * to be associated since the HAL sta entry is created for
3273 * denied STA we need to remove this HAL entry.
3274 * So to do that set updateContext to 1
3275 */
3276 if (!sta_ds->mlmStaContext.updateContext)
3277 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003278 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279 assoc_cnf.statusCode, sta_ds->assocId);
3280 lim_reject_association(mac_ctx, sta_ds->staAddr,
3281 sta_ds->mlmStaContext.subType,
3282 true, sta_ds->mlmStaContext.authType,
3283 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003284 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003285 session_entry);
3286 }
3287end:
3288 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3289 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3290 assoc_req = (tpSirAssocReq)
3291 session_entry->parsedAssocReq[sta_ds->assocId];
3292 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303293 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003294 assoc_req->assocReqFrame = NULL;
3295 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303296 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003297 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3298 }
3299}
3300
3301static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3302{
3303 tpDphHashNode pStaDs;
3304 tSirMacAddr peerMac;
3305 tpSirAddtsReq pSirAddts;
3306 uint32_t timeout;
3307 tpPESession psessionEntry;
3308 uint8_t sessionId; /* PE sessionId */
3309 uint8_t smesessionId;
3310 uint16_t smetransactionId;
3311
3312 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003313 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003314 return;
3315 }
3316
3317 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3318 &smetransactionId);
3319
3320 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3321
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003322 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3323 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003324 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003325 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003326 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303327 NULL, pSirAddts->req.tspec,
3328 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003329 return;
3330 }
3331#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3332 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3333 0);
3334#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3335
3336 /* if sta
3337 * - verify assoc state
3338 * - send addts request to ap
3339 * - wait for addts response from ap
3340 * if ap, just ignore with error log
3341 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003342 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3343 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3344 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003345
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003346 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003347 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303348 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003349 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003350
3351 pStaDs =
3352 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3353 &psessionEntry->dph.dphHashTable);
3354
3355 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003356 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303357 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003358 }
3359
3360 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3361 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003362 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303363 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003364 }
3365
3366 pSirAddts->req.wsmTspecPresent = 0;
3367 pSirAddts->req.wmeTspecPresent = 0;
3368 pSirAddts->req.lleTspecPresent = 0;
3369
3370 if ((pStaDs->wsmEnabled) &&
3371 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3372 SIR_MAC_ACCESSPOLICY_EDCA))
3373 pSirAddts->req.wsmTspecPresent = 1;
3374 else if (pStaDs->wmeEnabled)
3375 pSirAddts->req.wmeTspecPresent = 1;
3376 else if (pStaDs->lleEnabled)
3377 pSirAddts->req.lleTspecPresent = 1;
3378 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003379 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303380 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003381 }
3382
3383 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3384 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003385 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003386 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303387 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003388 }
3389
3390 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003391 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003392 pMac->lim.gLimAddtsReq.req.dialogToken,
3393 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3394 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3395 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303396 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003397 }
3398
3399 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3400
3401 /* save the addts request */
3402 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303403 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003404 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3405
3406 /* ship out the message now */
3407 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3408 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303409 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003410 /* start a timer to wait for the response */
3411 if (pSirAddts->timeout)
3412 timeout = pSirAddts->timeout;
3413 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003414 QDF_STATUS_SUCCESS) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303415 pe_debug("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003416 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303417 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003418 }
3419
3420 timeout = SYS_MS_TO_TICKS(timeout);
3421 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3422 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003423 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303424 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003425 }
3426 pMac->lim.gLimAddtsRspTimerCount++;
3427 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3428 pMac->lim.gLimAddtsRspTimerCount) !=
3429 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003430 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303431 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003432 }
3433 MTRACE(mac_trace
3434 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3435 eLIM_ADDTS_RSP_TIMER));
3436
3437 /* add the sessionId to the timer object */
3438 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3439 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3440 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003441 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303442 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003443 }
3444 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303445
3446send_failure_addts_rsp:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003447 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303448 psessionEntry, pSirAddts->req.tspec,
3449 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003450}
3451
3452static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3453{
3454 tSirMacAddr peerMacAddr;
3455 uint8_t ac;
3456 tSirMacTSInfo *pTsinfo;
3457 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3458 tpDphHashNode pStaDs = NULL;
3459 tpPESession psessionEntry;
3460 uint8_t sessionId;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003461 uint32_t status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462 uint8_t smesessionId;
3463 uint16_t smetransactionId;
3464
3465 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3466 &smetransactionId);
3467
3468 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003469 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003470 &sessionId);
3471 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003472 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003473 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003474 goto end;
3475 }
3476#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3477 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3478 0);
3479#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3480
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003481 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003482 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003483 pe_err("lim_validate_delts_req failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003484 status = QDF_STATUS_E_FAILURE;
3485 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_E_FAILURE, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003486 smesessionId, smetransactionId);
3487 return;
3488 }
3489
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003490 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3491 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003492 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3493
3494 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3495 pDeltsReq->req.wmeTspecPresent,
3496 &pDeltsReq->req.tsinfo,
3497 &pDeltsReq->req.tspec, psessionEntry);
3498
3499 pTsinfo =
3500 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3501 tsinfo : &pDeltsReq->req.tsinfo;
3502
3503 /* We've successfully send DELTS frame to AP. Update the
3504 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3505 * is no longer trigger enabled or delivery enabled
3506 */
3507 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3508 pTsinfo, CLEAR_UAPSD_MASK);
3509
3510 /* We're deleting the TSPEC, so this particular AC is no longer
3511 * admitted. PE needs to downgrade the EDCA
3512 * parameters(for the AC for which TS is being deleted) to the
3513 * next best AC for which ACM is not enabled, and send the
3514 * updated values to HAL.
3515 */
3516 ac = upToAc(pTsinfo->traffic.userPrio);
3517
3518 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3519 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3520 ~(1 << ac);
3521 } else if (pTsinfo->traffic.direction ==
3522 SIR_MAC_DIRECTION_DNLINK) {
3523 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3524 ~(1 << ac);
3525 } else if (pTsinfo->traffic.direction ==
3526 SIR_MAC_DIRECTION_BIDIR) {
3527 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3528 ~(1 << ac);
3529 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3530 ~(1 << ac);
3531 }
3532
3533 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3534 psessionEntry);
3535
3536 pStaDs =
3537 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3538 &psessionEntry->dph.dphHashTable);
3539 if (pStaDs != NULL) {
3540 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003541 pStaDs->bssId, false);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003542 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003543 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003544 pe_err("Self entry missing in Hash Table");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003545 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003546 }
3547#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003548 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003549#endif
3550
3551 /* send an sme response back */
3552end:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003553 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_SUCCESS, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003554 smesessionId, smetransactionId);
3555}
3556
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303557void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003558{
3559 /* fetch the sessionEntry based on the sessionId */
3560 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003561
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003562 psessionEntry = pe_find_session_by_session_id(pMac,
3563 pMac->lim.limTimers.gLimAddtsRspTimer.
3564 sessionId);
3565 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003566 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003567 return;
3568 }
3569
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003570 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003571 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003572 GET_LIM_SYSTEM_ROLE(psessionEntry));
3573 pMac->lim.gLimAddtsSent = false;
3574 return;
3575 }
3576
3577 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003578 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003579 return;
3580 }
3581
3582 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003583 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003584 pMac->lim.gLimAddtsRspTimerCount);
3585 return;
3586 }
3587 /* this a real response timeout */
3588 pMac->lim.gLimAddtsSent = false;
3589 pMac->lim.gLimAddtsRspTimerCount++;
3590
3591 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3592 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3593 psessionEntry->smeSessionId,
3594 psessionEntry->transactionId);
3595}
3596
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003597#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598/**
3599 * __lim_process_sme_get_statistics_request()
3600 *
3601 ***FUNCTION:
3602 *
3603 *
3604 ***NOTE:
3605 *
3606 * @param pMac Pointer to Global MAC structure
3607 * @param *pMsgBuf A pointer to the SME message buffer
3608 * @return None
3609 */
3610static void
3611__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3612{
3613 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003614 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003615
3616 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3617
3618 msgQ.type = WMA_GET_STATISTICS_REQ;
3619
3620 msgQ.reserved = 0;
3621 msgQ.bodyptr = pMsgBuf;
3622 msgQ.bodyval = 0;
3623 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3624
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003625 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303626 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003627 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003628 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003629 return;
3630 }
3631
3632 return;
3633}
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003634#else
3635static void __lim_process_sme_get_statistics_request(
3636 struct sAniSirGlobal *mac_ctx, uint32_t *pMsgBuf) {}
3637#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003638
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003639#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003640/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003641 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003642 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003643 * @pMac: Pointer to Global MAC structure
3644 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003645 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003646 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003647 */
3648static void
3649__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3650{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003651 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003652
3653 msgQ.type = WMA_TSM_STATS_REQ;
3654 msgQ.reserved = 0;
3655 msgQ.bodyptr = pMsgBuf;
3656 msgQ.bodyval = 0;
3657 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3658
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003659 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303660 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003661 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003662 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003663 return;
3664 }
3665}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003666#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003667
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08003668static void lim_process_sme_set_addba_accept(tpAniSirGlobal mac_ctx,
3669 struct sme_addba_accept *msg)
3670{
3671 if (!msg) {
3672 pe_err("Msg Buffer is NULL");
3673 return;
3674 }
3675 if (!msg->addba_accept)
3676 mac_ctx->reject_addba_req = 1;
3677 else
3678 mac_ctx->reject_addba_req = 0;
3679}
3680
Arif Hussaineb8ba362018-03-07 19:15:13 -08003681static void lim_process_sme_update_edca_params(tpAniSirGlobal mac_ctx,
3682 uint32_t sme_session_id)
3683{
3684 tpPESession pe_session;
3685 tpDphHashNode sta_ds_ptr;
3686
3687 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3688 if (!pe_session) {
3689 pe_err("Session does not exist: sme_id %d", sme_session_id);
3690 return;
3691 }
3692 pe_session->gLimEdcaParamsActive[EDCA_AC_BE].no_ack =
3693 mac_ctx->no_ack_policy_cfg[EDCA_AC_BE];
3694 pe_session->gLimEdcaParamsActive[EDCA_AC_BK].no_ack =
3695 mac_ctx->no_ack_policy_cfg[EDCA_AC_BK];
3696 pe_session->gLimEdcaParamsActive[EDCA_AC_VI].no_ack =
3697 mac_ctx->no_ack_policy_cfg[EDCA_AC_VI];
3698 pe_session->gLimEdcaParamsActive[EDCA_AC_VO].no_ack =
3699 mac_ctx->no_ack_policy_cfg[EDCA_AC_VO];
3700 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3701 &pe_session->dph.dphHashTable);
3702 if (sta_ds_ptr)
3703 lim_send_edca_params(mac_ctx,
3704 pe_session->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003705 sta_ds_ptr->bssId, false);
Arif Hussaineb8ba362018-03-07 19:15:13 -08003706 else
3707 pe_err("Self entry missing in Hash Table");
3708}
3709
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07003710static void lim_process_sme_update_mu_edca_params(tpAniSirGlobal mac_ctx,
3711 uint32_t sme_session_id)
3712{
3713 tpPESession pe_session;
3714 tpDphHashNode sta_ds_ptr;
3715
3716 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3717 if (!pe_session) {
3718 pe_err("Session does not exist: sme_id %d", sme_session_id);
3719 return;
3720 }
3721 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3722 &pe_session->dph.dphHashTable);
3723 if (sta_ds_ptr)
3724 lim_send_edca_params(mac_ctx, mac_ctx->usr_mu_edca_params,
3725 sta_ds_ptr->bssId, true);
3726 else
3727 pe_err("Self entry missing in Hash Table");
3728}
3729
Naveen Rawat8029a402017-06-01 10:54:19 -07003730static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3731 struct update_config *msg)
3732{
3733 tpPESession pe_session;
3734
3735 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3736 if (msg == NULL) {
3737 pe_err("Buffer is Pointing to NULL");
3738 return;
3739 }
3740
3741 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3742 msg->sme_session_id);
3743 if (pe_session == NULL) {
3744 pe_warn("Session does not exist for given BSSID");
3745 return;
3746 }
3747
3748 switch (msg->capab) {
3749 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3750 pe_session->htConfig.ht_rx_ldpc = msg->value;
3751 break;
3752 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3753 pe_session->htConfig.ht_tx_stbc = msg->value;
3754 break;
3755 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3756 pe_session->htConfig.ht_rx_stbc = msg->value;
3757 break;
3758 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3759 pe_session->htConfig.ht_sgi20 = msg->value;
3760 break;
3761 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3762 pe_session->htConfig.ht_sgi40 = msg->value;
3763 break;
3764 }
3765
3766 if (LIM_IS_AP_ROLE(pe_session)) {
3767 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3768 lim_send_beacon_ind(mac_ctx, pe_session);
3769 }
3770}
3771
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003772void
3773lim_send_vdev_restart(tpAniSirGlobal pMac,
3774 tpPESession psessionEntry, uint8_t sessionId)
3775{
3776 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003777 struct scheduler_msg msgQ = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003778 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003779
3780 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003781 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003782 return;
3783 }
3784
3785 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303786 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003787 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003788 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003789 return;
3790 }
3791
3792 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3793 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003794 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003795
3796 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3797 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3798 msgQ.bodyval = 0;
3799
3800 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003801 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003802 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303803 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003804 }
3805}
3806
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303807/**
3808 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3809 * @mac_ctx: Pointer to Global MAC structure
3810 * @msg_buf: Pointer to SME message buffer
3811 *
3812 * Return: None
3813 */
3814static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3815 uint32_t *msg_buf)
3816{
3817 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003818 struct scheduler_msg wma_msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003819 QDF_STATUS status;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303820 tSirRoamOffloadScanReq *req_buffer;
3821 uint16_t local_ie_len;
3822 uint8_t *local_ie_buf;
3823
3824 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3825 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3826 req_buffer->sessionId);
3827
3828 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3829 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003830 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303831 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303832 return;
3833 }
3834
3835 local_ie_len = req_buffer->assoc_ie.length;
3836 /* Update ext cap IE if present */
3837 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003838 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3839 local_ie_buf, &local_ie_len)) {
3840 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003841 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3842 req_buffer->assoc_ie.length = local_ie_len;
3843 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3844 local_ie_buf, local_ie_len);
3845 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303846 }
3847 qdf_mem_free(local_ie_buf);
3848
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303849 if (pe_session)
3850 lim_update_fils_rik(pe_session, req_buffer);
3851
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303852 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3853 wma_msg.bodyptr = req_buffer;
3854
3855 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003856 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003857 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303858 qdf_mem_free(req_buffer);
3859 }
3860}
3861
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303862/*
3863 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3864 * @mac_ctx: Pointer to global mac context
3865 * @session: Pointer to PE session
3866 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3867 * 1 - Disable broadcast SSID
3868 *
3869 * Return: None
3870 */
3871static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3872 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003873{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003874 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003875 session->ssidHidden, ssid_hidden);
3876
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003877 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303878 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003879 } else {
3880 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05303881 return;
3882 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003883
Abhishek Singh6c681f42018-09-12 15:52:36 +05303884#ifdef CONFIG_VDEV_SM
3885 ap_mlme_set_hidden_ssid_restart_in_progress(session->vdev, true);
3886 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3887 WLAN_VDEV_SM_EV_FW_VDEV_RESTART,
3888 sizeof(*session), session);
3889#else
3890
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003891 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303892 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Abhishek Singh6c681f42018-09-12 15:52:36 +05303893#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003894
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003895 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303896}
3897
3898/**
3899 * __lim_process_sme_session_update - process SME session update msg
3900 *
3901 * @mac_ctx: Pointer to global mac context
3902 * @msg_buf: Pointer to the received message buffer
3903 *
3904 * Return: None
3905 */
3906static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
3907 uint32_t *msg_buf)
3908{
3909 struct sir_update_session_param *msg;
3910 tpPESession session;
3911
3912 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003913 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303914 return;
3915 }
3916
3917 msg = (struct sir_update_session_param *) msg_buf;
3918
3919 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
3920 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003921 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303922 msg->session_id);
3923 return;
3924 }
3925
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003926 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303927 msg->param_type, msg->param_val);
3928 switch (msg->param_type) {
3929 case SIR_PARAM_SSID_HIDDEN:
3930 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
3931 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303932 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
3933 session->ignore_assoc_disallowed = msg->param_val;
3934 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303935 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003936 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303937 break;
3938 }
3939}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003940
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003941/*
3942 Update the beacon Interval dynamically if beaconInterval is different in MCC
3943 */
3944static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3945{
3946 tpSirChangeBIParams pChangeBIParams;
3947 tpPESession psessionEntry;
3948 uint8_t sessionId = 0;
3949 tUpdateBeaconParams beaconParams;
3950
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003951 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003952
3953 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003954 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003955 return;
3956 }
3957
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303958 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003959 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
3960
3961 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08003962 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003963 &sessionId);
3964 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003965 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003966 return;
3967 }
3968
3969 /*Update sessionEntry Beacon Interval */
3970 if (psessionEntry->beaconParams.beaconInterval !=
3971 pChangeBIParams->beaconInterval) {
3972 psessionEntry->beaconParams.beaconInterval =
3973 pChangeBIParams->beaconInterval;
3974 }
3975
3976 /*Update sch beaconInterval */
3977 if (pMac->sch.schObject.gSchBeaconInterval !=
3978 pChangeBIParams->beaconInterval) {
3979 pMac->sch.schObject.gSchBeaconInterval =
3980 pChangeBIParams->beaconInterval;
3981
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003982 pe_debug("LIM send update BeaconInterval Indication: %d",
3983 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003984
3985 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
3986 /* Update beacon */
3987 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3988
3989 beaconParams.bssIdx = psessionEntry->bssIdx;
3990 /* Set change in beacon Interval */
3991 beaconParams.beaconInterval =
3992 pChangeBIParams->beaconInterval;
3993 beaconParams.paramChangeBitmap =
3994 PARAM_BCN_INTERVAL_CHANGED;
3995 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
3996 }
3997 }
3998
3999 return;
4000} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4001
4002#ifdef QCA_HT_2040_COEX
4003static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4004 uint32_t *pMsgBuf)
4005{
4006 tpSirSetHT2040Mode pSetHT2040Mode;
4007 tpPESession psessionEntry;
4008 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004009 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004010 tUpdateVHTOpMode *pHtOpMode = NULL;
4011 uint16_t staId = 0;
4012 tpDphHashNode pStaDs = NULL;
4013
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004014 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004015 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004016 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004017 return;
4018 }
4019
4020 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4021
4022 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004023 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004024 &sessionId);
4025 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004026 pe_debug("Session does not exist for given BSSID");
4027 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004028 return;
4029 }
4030
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004031 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004032 pSetHT2040Mode->cbMode);
4033 /*Update sessionEntry HT related fields */
4034 switch (pSetHT2040Mode->cbMode) {
4035 case PHY_SINGLE_CHANNEL_CENTERED:
4036 psessionEntry->htSecondaryChannelOffset =
4037 PHY_SINGLE_CHANNEL_CENTERED;
4038 psessionEntry->htRecommendedTxWidthSet = 0;
4039 if (pSetHT2040Mode->obssEnabled)
4040 psessionEntry->htSupportedChannelWidthSet
4041 = eHT_CHANNEL_WIDTH_40MHZ;
4042 else
4043 psessionEntry->htSupportedChannelWidthSet
4044 = eHT_CHANNEL_WIDTH_20MHZ;
4045 break;
4046 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4047 psessionEntry->htSecondaryChannelOffset =
4048 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4049 psessionEntry->htRecommendedTxWidthSet = 1;
4050 break;
4051 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4052 psessionEntry->htSecondaryChannelOffset =
4053 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4054 psessionEntry->htRecommendedTxWidthSet = 1;
4055 break;
4056 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004057 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004058 return;
4059 }
4060
4061 /* Update beacon */
4062 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4063 lim_send_beacon_ind(pMac, psessionEntry);
4064
4065 /* update OP Mode for each associated peer */
4066 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4067 pStaDs = dph_get_hash_entry(pMac, staId,
4068 &psessionEntry->dph.dphHashTable);
4069 if (NULL == pStaDs)
4070 continue;
4071
4072 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304073 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004074 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004075 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004076 return;
4077 }
4078 pHtOpMode->opMode =
4079 (psessionEntry->htSecondaryChannelOffset ==
4080 PHY_SINGLE_CHANNEL_CENTERED) ?
4081 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4082 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304083 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004084 sizeof(tSirMacAddr));
4085 pHtOpMode->smesessionId = sessionId;
4086
4087 msg.type = WMA_UPDATE_OP_MODE;
4088 msg.reserved = 0;
4089 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004090 if (!QDF_IS_STATUS_SUCCESS
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05304091 (scheduler_post_message(QDF_MODULE_ID_PE,
4092 QDF_MODULE_ID_WMA,
4093 QDF_MODULE_ID_WMA,
4094 &msg))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004095 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304096 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004097 return;
4098 }
Jeff Johnson47d75242018-05-12 15:58:53 -07004099 pe_debug("Notified FW about OP mode: %d for staId=%d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004100 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004101
4102 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004103 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004104 }
4105
4106 return;
4107}
4108#endif
4109
4110/* -------------------------------------------------------------------- */
4111/**
4112 * __lim_process_report_message
4113 *
4114 * FUNCTION: Processes the next received Radio Resource Management message
4115 *
4116 * LOGIC:
4117 *
4118 * ASSUMPTIONS:
4119 *
4120 * NOTE:
4121 *
4122 * @param None
4123 * @return None
4124 */
4125
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004126static void __lim_process_report_message(tpAniSirGlobal pMac,
4127 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004128{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004129 switch (pMsg->type) {
4130 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4131 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4132 break;
4133 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004134 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004135 break;
4136 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004137 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004138 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004139}
4140
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004141/* -------------------------------------------------------------------- */
4142/**
4143 * lim_send_set_max_tx_power_req
4144 *
4145 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4146 *
4147 * LOGIC:
4148 *
4149 * ASSUMPTIONS:
4150 *
4151 * NOTE:
4152 *
4153 * @param txPower txPower to be set.
4154 * @param pSessionEntry session entry.
4155 * @return None
4156 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004157QDF_STATUS
Amar Singhala297bfa2015-10-15 15:07:29 -07004158lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004159 tpPESession pSessionEntry)
4160{
4161 tpMaxTxPowerParams pMaxTxParams = NULL;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004162 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004163 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004164
4165 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004166 pe_err("Invalid parameters");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004167 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004168 }
4169
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304170 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004171 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004172 pe_err("Unable to allocate memory for pMaxTxParams");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004173 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004174
4175 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004176 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304177 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304178 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304179 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004180 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304181 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004182
4183 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4184 msgQ.bodyptr = pMaxTxParams;
4185 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004186 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004187 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4188 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004189 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004190 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304191 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004192 }
4193 return retCode;
4194}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004195
4196/**
4197 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4198 *
4199 * @mac_ctx: Pointer to Global MAC structure
4200 * @msg_buf: pointer to the SME message buffer
4201 *
4202 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4203 * from SME. It Register this information within PE.
4204 *
4205 * Return: None
4206 */
4207static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4208 uint32_t *msg_buf)
4209{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304210 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004211 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4212 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4213 struct mgmt_frm_reg_info *next = NULL;
4214 bool match = false;
4215
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004216 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004217 sme_req->registerFrame, sme_req->frameType,
4218 sme_req->matchLen);
4219 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304220 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304221 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4222 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304223 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004224
4225 while (lim_mgmt_regn != NULL) {
4226 if (lim_mgmt_regn->frameType != sme_req->frameType)
4227 goto skip_match;
4228 if (sme_req->matchLen) {
4229 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304230 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004231 sme_req->matchData,
4232 lim_mgmt_regn->matchLen))) {
4233 /* found match! */
4234 match = true;
4235 break;
4236 }
4237 } else {
4238 /* found match! */
4239 match = true;
4240 break;
4241 }
4242skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304243 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304244 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004245 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304246 (qdf_list_node_t *)lim_mgmt_regn,
4247 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304248 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004249 lim_mgmt_regn = next;
4250 next = NULL;
4251 }
4252 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304253 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004254 if (QDF_STATUS_SUCCESS ==
4255 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004256 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004257 (qdf_list_node_t *)lim_mgmt_regn))
4258 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304259 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004260 }
4261
4262 if (sme_req->registerFrame) {
4263 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304264 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004265 sme_req->matchLen);
4266 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004267 lim_mgmt_regn->frameType = sme_req->frameType;
4268 lim_mgmt_regn->matchLen = sme_req->matchLen;
4269 lim_mgmt_regn->sessionId = sme_req->sessionId;
4270 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304271 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004272 sme_req->matchData,
4273 sme_req->matchLen);
4274 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304275 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004276 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304277 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004278 gLimMgmtFrameRegistratinQueue,
4279 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304280 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004281 &mac_ctx->lim.lim_frame_register_lock);
4282 }
4283 }
4284 return;
4285}
4286
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004287static void
4288__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4289{
4290 tpSirResetAPCapsChange pResetCapsChange;
4291 tpPESession psessionEntry;
4292 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004293
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004294 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004295 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004296 return;
4297 }
4298
4299 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4300 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004301 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4302 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004303 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004304 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004305 return;
4306 }
4307
4308 psessionEntry->limSentCapsChangeNtf = false;
4309 return;
4310}
4311
4312/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304313 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4314 * indication callback in PE.
4315 * @mac_ptr: Mac pointer
4316 * @msg_buf: Msg pointer containing the callback
4317 *
4318 * This function is used save the Management frame
4319 * indication callback in PE.
4320 *
4321 * Return: None
4322 */
4323static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4324 uint32_t *msg_buf)
4325{
4326 struct sir_sme_mgmt_frame_cb_req *sme_req =
4327 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4328
4329 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004330 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304331 return;
4332 }
4333 if (sme_req->callback)
4334 mac_ctx->mgmt_frame_ind_cb =
4335 (sir_mgmt_frame_ind_callback)sme_req->callback;
4336 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004337 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304338}
4339
4340/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304341 *__lim_process_send_disassoc_frame: function processes disassoc frame
4342 * @mac_ctx: pointer to mac context
4343 * @msg_buf: message buffer
4344 *
4345 * function processes disassoc request received from SME
4346 *
4347 * return: none
4348 */
4349static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4350 uint32_t *msg_buf)
4351{
4352 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004353 QDF_STATUS status;
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304354 tpPESession session_entry = NULL;
4355 uint8_t sme_session_id;
4356 uint16_t sme_trans_id;
4357
4358 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004359 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304360 return;
4361 }
4362
4363 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4364 &sme_trans_id);
4365
4366 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4367 &sme_send_disassoc_frame_req,
4368 (uint8_t *)msg_buf);
4369
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004370 if ((QDF_STATUS_E_FAILURE == status) ||
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304371 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4372 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004373 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304374 return;
4375 }
4376
4377 session_entry = pe_find_session_by_sme_session_id(
4378 mac_ctx, sme_session_id);
4379 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004380 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304381 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4382 return;
4383 }
4384
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004385 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 +05304386 sme_send_disassoc_frame_req.msg_type,
4387 sme_send_disassoc_frame_req.length,
4388 sme_send_disassoc_frame_req.session_id,
4389 sme_send_disassoc_frame_req.trans_id,
4390 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4391 sme_send_disassoc_frame_req.reason,
4392 sme_send_disassoc_frame_req.wait_for_ack);
4393
4394 lim_send_disassoc_mgmt_frame(mac_ctx,
4395 sme_send_disassoc_frame_req.reason,
4396 sme_send_disassoc_frame_req.peer_mac,
4397 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4398}
4399
4400/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004401 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4402 * @mac_ctx: Pointer to Global MAC structure
4403 * @pdev_id: pdev id to set the IE.
4404 * @nss: Nss values to prepare the HT IE.
4405 *
4406 * Prepares the HT IE with self capabilities for different
4407 * Nss values and sends the set HT IE req to FW.
4408 *
4409 * Return: None
4410 */
4411static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4412 uint8_t nss)
4413{
4414 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004415 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004416 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004417 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004418 tHtCaps *p_ht_cap;
4419 int i;
4420
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004421 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004422 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4423 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004424 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004425 return;
4426 }
4427 ie_params->nss = i;
4428 ie_params->pdev_id = pdev_id;
4429 ie_params->ie_type = DOT11_HT_IE;
4430 /* 2 for IE len and EID */
4431 ie_params->ie_len = 2 + sizeof(tHtCaps);
4432 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4433 if (NULL == ie_params->ie_ptr) {
4434 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004435 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004436 return;
4437 }
4438 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4439 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4440 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4441 ie_params->ie_len);
4442
4443 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004444 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4445 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004446 if (NULL == p_ie) {
4447 qdf_mem_free(ie_params->ie_ptr);
4448 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004449 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004450 return;
4451 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004452 p_ht_cap = (tHtCaps *)&p_ie[2];
4453 p_ht_cap->supportedMCSSet[1] = 0;
4454 p_ht_cap->txSTBC = 0;
4455 }
4456
4457 msg.type = WMA_SET_PDEV_IE_REQ;
4458 msg.bodyptr = ie_params;
4459 msg.bodyval = 0;
4460
4461 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004462 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004463 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004464 qdf_mem_free(ie_params->ie_ptr);
4465 qdf_mem_free(ie_params);
4466 return;
4467 }
4468 }
4469}
4470
4471/**
4472 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4473 * @mac_ctx: Pointer to Global MAC structure
4474 * @pdev_id: pdev id to set the IE.
4475 * @nss: Nss values to prepare the VHT IE.
4476 *
4477 * Prepares the VHT IE with self capabilities for different
4478 * Nss values and sends the set VHT IE req to FW.
4479 *
4480 * Return: None
4481 */
4482static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4483 uint8_t nss)
4484{
4485 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004486 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004487 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004488 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004489 tSirMacVHTCapabilityInfo *vht_cap;
4490 int i;
4491 tSirVhtMcsInfo *vht_mcs;
4492
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004493 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004494 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4495 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004496 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004497 return;
4498 }
4499 ie_params->nss = i;
4500 ie_params->pdev_id = pdev_id;
4501 ie_params->ie_type = DOT11_VHT_IE;
4502 /* 2 for IE len and EID */
4503 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4504 sizeof(tSirVhtMcsInfo);
4505 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4506 if (NULL == ie_params->ie_ptr) {
4507 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004508 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004509 return;
4510 }
4511 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4512 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4513 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4514 ie_params->ie_len);
4515
4516 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004517 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4518 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004519 if (NULL == p_ie) {
4520 qdf_mem_free(ie_params->ie_ptr);
4521 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004522 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004523 return;
4524 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004525 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4526 vht_cap->txSTBC = 0;
4527 vht_mcs =
4528 (tSirVhtMcsInfo *)&p_ie[2 +
4529 sizeof(tSirMacVHTCapabilityInfo)];
4530 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4531 vht_mcs->rxHighest =
4532 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4533 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4534 vht_mcs->txHighest =
4535 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4536 }
4537 msg.type = WMA_SET_PDEV_IE_REQ;
4538 msg.bodyptr = ie_params;
4539 msg.bodyval = 0;
4540
4541 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004542 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004543 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004544 qdf_mem_free(ie_params->ie_ptr);
4545 qdf_mem_free(ie_params);
4546 return;
4547 }
4548 }
4549}
4550
4551/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004552 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4553 * @mac_ctx: Pointer to Global MAC structure
4554 * @msg_buf: Pointer to the SME message buffer
4555 *
4556 * This function is called by limProcessMessageQueue(). This function sets the
4557 * VDEV IEs to the FW.
4558 *
4559 * Return: None
4560 */
4561static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4562 uint32_t *msg_buf)
4563{
4564 struct sir_set_vdev_ies_per_band *p_msg =
4565 (struct sir_set_vdev_ies_per_band *)msg_buf;
4566
4567 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004568 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004569 return;
4570 }
4571
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004572 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004573 p_msg->vdev_id);
4574 /* intentionally using NULL here so that self capabilty are sent */
4575 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4576 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004577 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004578}
4579
4580/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004581 * lim_process_set_pdev_IEs() - process the set pdev IE req
4582 * @mac_ctx: Pointer to Global MAC structure
4583 * @msg_buf: Pointer to the SME message buffer
4584 *
4585 * This function is called by limProcessMessageQueue(). This
4586 * function sets the PDEV IEs to the FW.
4587 *
4588 * Return: None
4589 */
4590static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4591{
4592 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4593
4594 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4595
4596 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004597 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004598 return;
4599 }
4600
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004601 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004602 ht_vht_cfg->nss);
4603 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4604
4605 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4606 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4607 ht_vht_cfg->nss);
4608}
4609
4610/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304611 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4612 *
4613 * access policy
4614 * @mac_ctx: pointer to mac context
4615 * @msg: message buffer
4616 *
4617 * function processes vendor IE and access policy from SME and updates PE
4618 *
4619 * session entry
4620 *
4621 * return: none
4622*/
4623static void lim_process_sme_update_access_policy_vendor_ie(
4624 tpAniSirGlobal mac_ctx,
4625 uint32_t *msg)
4626{
4627 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4628 struct sPESession *pe_session_entry;
Pragaspathi Thilagaraj9b7a1162018-05-07 16:28:13 +05304629 uint16_t num_bytes;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304630
4631 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004632 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304633 return;
4634 }
4635 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4636 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4637 update_vendor_ie->sme_session_id);
4638
4639 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004640 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304641 update_vendor_ie->sme_session_id);
4642 return;
4643 }
4644 if (pe_session_entry->access_policy_vendor_ie)
4645 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4646
4647 num_bytes = update_vendor_ie->ie[1] + 2;
4648 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4649
4650 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004651 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304652 return;
4653 }
4654 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4655 &update_vendor_ie->ie[0], num_bytes);
4656
4657 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4658}
4659
4660/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004661 * lim_process_sme_req_messages()
4662 *
4663 ***FUNCTION:
4664 * This function is called by limProcessMessageQueue(). This
4665 * function processes SME request messages from HDD or upper layer
4666 * application.
4667 *
4668 ***LOGIC:
4669 *
4670 ***ASSUMPTIONS:
4671 *
4672 ***NOTE:
4673 *
4674 * @param pMac Pointer to Global MAC structure
4675 * @param msgType Indicates the SME message type
4676 * @param *pMsgBuf A pointer to the SME message buffer
4677 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4678 * false - if pMsgBuf is not to be freed.
4679 */
4680
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004681bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4682 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004683{
Jeff Johnson33142e62018-05-06 17:58:36 -07004684 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 -08004685 uint32_t *pMsgBuf = pMsg->bodyptr;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004686
4687 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004688 lim_msg_str(pMsg->type), pMsg->type,
4689 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4690 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004691
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004692 /* If no insert NOA required then execute the code below */
4693
4694 switch (pMsg->type) {
4695 case eWNI_SME_SYS_READY_IND:
4696 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4697 break;
4698
4699 case eWNI_SME_START_BSS_REQ:
4700 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4701 break;
4702
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004703 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4704 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4705 break;
4706 case eWNI_SME_JOIN_REQ:
4707 __lim_process_sme_join_req(pMac, pMsgBuf);
4708 break;
4709
4710 case eWNI_SME_REASSOC_REQ:
4711 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4712 break;
4713
4714 case eWNI_SME_DISASSOC_REQ:
4715 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4716 break;
4717
4718 case eWNI_SME_DISASSOC_CNF:
4719 case eWNI_SME_DEAUTH_CNF:
4720 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4721 break;
4722
4723 case eWNI_SME_DEAUTH_REQ:
4724 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4725 break;
4726
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304727 case eWNI_SME_SEND_DISASSOC_FRAME:
4728 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4729 break;
4730
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004731 case eWNI_SME_SETCONTEXT_REQ:
4732 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4733 break;
4734
4735 case eWNI_SME_STOP_BSS_REQ:
4736 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4737 break;
4738
4739 case eWNI_SME_ASSOC_CNF:
4740 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004741 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004742 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4743 pMsgBuf);
4744 break;
4745
4746 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004747 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004748 __lim_process_sme_addts_req(pMac, pMsgBuf);
4749 break;
4750
4751 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004752 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004753 __lim_process_sme_delts_req(pMac, pMsgBuf);
4754 break;
4755
4756 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004757 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004758 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4759 break;
4760
4761 case eWNI_SME_GET_STATISTICS_REQ:
4762 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4763 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4764 bufConsumed = false;
4765 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004766#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004767 case eWNI_SME_GET_TSM_STATS_REQ:
4768 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4769 bufConsumed = false;
4770 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004771#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004772 case eWNI_SME_GET_ASSOC_STAS_REQ:
4773 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4774 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304775 case eWNI_SME_SESSION_UPDATE_PARAM:
4776 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004777 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304778 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4779 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4780 bufConsumed = false;
4781 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004782 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4783 /* Update the beaconInterval */
4784 __lim_process_sme_change_bi(pMac, pMsgBuf);
4785 break;
4786
4787#ifdef QCA_HT_2040_COEX
4788 case eWNI_SME_SET_HT_2040_MODE:
4789 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4790 break;
4791#endif
4792
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004793 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4794 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4795 __lim_process_report_message(pMac, pMsg);
4796 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004797
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004798 case eWNI_SME_FT_PRE_AUTH_REQ:
4799 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4800 break;
4801 case eWNI_SME_FT_UPDATE_KEY:
4802 lim_process_ft_update_key(pMac, pMsgBuf);
4803 break;
4804
4805 case eWNI_SME_FT_AGGR_QOS_REQ:
4806 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4807 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004808
4809 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4810 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4811 break;
4812#ifdef FEATURE_WLAN_TDLS
4813 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4814 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4815 break;
4816 case eWNI_SME_TDLS_ADD_STA_REQ:
4817 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4818 break;
4819 case eWNI_SME_TDLS_DEL_STA_REQ:
4820 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4821 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004822#endif
4823 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4824 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4825 break;
4826
4827 case eWNI_SME_CHANNEL_CHANGE_REQ:
4828 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4829 break;
4830
4831 case eWNI_SME_START_BEACON_REQ:
4832 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4833 break;
4834
4835 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4836 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4837 break;
4838
4839 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4840 lim_process_update_add_ies(pMac, pMsgBuf);
4841 break;
4842
4843 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4844 lim_process_modify_add_ies(pMac, pMsgBuf);
4845 break;
4846 case eWNI_SME_SET_HW_MODE_REQ:
4847 lim_process_set_hw_mode(pMac, pMsgBuf);
4848 break;
4849 case eWNI_SME_NSS_UPDATE_REQ:
4850 lim_process_nss_update_request(pMac, pMsgBuf);
4851 break;
4852 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4853 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4854 break;
4855 case eWNI_SME_SET_IE_REQ:
4856 lim_process_set_ie_req(pMac, pMsgBuf);
4857 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304858 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4859 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
4860 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304861 case eWNI_SME_EXT_CHANGE_CHANNEL:
4862 lim_process_ext_change_channel(pMac, pMsgBuf);
4863 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08004864 case eWNI_SME_SET_ANTENNA_MODE_REQ:
4865 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
4866 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004867 case eWNI_SME_PDEV_SET_HT_VHT_IE:
4868 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07004869 break;
4870 case eWNI_SME_SET_VDEV_IES_PER_BAND:
4871 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
4872 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304873 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
4874 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
4875 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07004876 case eWNI_SME_UPDATE_CONFIG:
4877 lim_process_sme_update_config(pMac,
4878 (struct update_config *)pMsgBuf);
4879 break;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004880 case eWNI_SME_SET_ADDBA_ACCEPT:
4881 lim_process_sme_set_addba_accept(pMac,
4882 (struct sme_addba_accept *)pMsgBuf);
4883 break;
Arif Hussaineb8ba362018-03-07 19:15:13 -08004884 case eWNI_SME_UPDATE_EDCA_PROFILE:
4885 lim_process_sme_update_edca_params(pMac, pMsg->bodyval);
4886 break;
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07004887 case WNI_SME_UPDATE_MU_EDCA_PARAMS:
4888 lim_process_sme_update_mu_edca_params(pMac, pMsg->bodyval);
4889 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004890 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304891 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004892 pMsg->bodyptr = NULL;
4893 break;
4894 } /* switch (msgType) */
4895
4896 return bufConsumed;
4897} /*** end lim_process_sme_req_messages() ***/
4898
4899/**
4900 * lim_process_sme_start_beacon_req()
4901 *
4902 ***FUNCTION:
4903 * This function is called by limProcessMessageQueue(). This
4904 * function processes SME request messages from HDD or upper layer
4905 * application.
4906 *
4907 ***LOGIC:
4908 *
4909 ***ASSUMPTIONS:
4910 *
4911 ***NOTE:
4912 *
4913 * @param pMac Pointer to Global MAC structure
4914 * @param msgType Indicates the SME message type
4915 * @param *pMsgBuf A pointer to the SME message buffer
4916 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4917 * false - if pMsgBuf is not to be freed.
4918 */
4919static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
4920{
4921 tpSirStartBeaconIndication pBeaconStartInd;
4922 tpPESession psessionEntry;
4923 uint8_t sessionId; /* PE sessionID */
4924
4925 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004926 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004927 return;
4928 }
4929
4930 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
4931 psessionEntry = pe_find_session_by_bssid(pMac,
4932 pBeaconStartInd->bssid,
4933 &sessionId);
4934 if (psessionEntry == NULL) {
4935 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004936 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004937 return;
4938 }
4939
4940 if (pBeaconStartInd->beaconStartStatus == true) {
4941 /*
4942 * Currently this Indication comes from SAP
4943 * to start Beacon Tx on a DFS channel
4944 * since beaconing has to be done on DFS
4945 * channel only after CAC WAIT is completed.
4946 * On a DFS Channel LIM does not start beacon
4947 * Tx right after the WMA_ADD_BSS_RSP.
4948 */
4949 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05304950 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004951 FL("Start Beacon with ssid %s Ch %d"),
4952 psessionEntry->ssId.ssId,
4953 psessionEntry->currentOperChannel);
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05304954 lim_send_beacon(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08004955 lim_enable_obss_detection_config(pMac, psessionEntry);
Arif Hussain05fb4872018-01-03 16:02:55 -08004956 lim_send_obss_color_collision_cfg(pMac, psessionEntry,
4957 OBSS_COLOR_COLLISION_DETECTION);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004958 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004959 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004960 return;
4961 }
4962}
4963
4964/**
4965 * lim_process_sme_channel_change_request() - process sme ch change req
4966 *
4967 * @mac_ctx: Pointer to Global MAC structure
4968 * @msg_buf: pointer to the SME message buffer
4969 *
4970 * This function is called to process SME_CHANNEL_CHANGE_REQ message
4971 *
4972 * Return: None
4973 */
4974static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
4975 uint32_t *msg_buf)
4976{
4977 tpSirChanChangeRequest ch_change_req;
4978 tpPESession session_entry;
4979 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07004980 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004981 uint32_t val = 0;
4982
4983 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004984 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004985 return;
4986 }
4987 ch_change_req = (tpSirChanChangeRequest)msg_buf;
4988
4989 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
4990 ch_change_req->targetChannel);
4991
4992 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
4993 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004994 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004995 return;
4996 }
4997
4998 session_entry = pe_find_session_by_bssid(mac_ctx,
4999 ch_change_req->bssid, &session_id);
5000 if (session_entry == NULL) {
5001 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005002 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005003 return;
5004 }
5005
Manjunathappa Prakash34fda792018-02-07 18:23:42 -08005006 if ((session_entry->currentOperChannel ==
5007 ch_change_req->targetChannel) &&
5008 (session_entry->ch_width == ch_change_req->ch_width)) {
5009 pe_err("Target channel and mode is same as current channel and mode channel %d and mode %d",
5010 session_entry->currentOperChannel, session_entry->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005011 return;
5012 }
5013
5014 if (LIM_IS_AP_ROLE(session_entry))
5015 session_entry->channelChangeReasonCode =
5016 LIM_SWITCH_CHANNEL_SAP_DFS;
5017 else
5018 session_entry->channelChangeReasonCode =
5019 LIM_SWITCH_CHANNEL_OPERATION;
5020
Bala Venkateshb39ed152017-12-26 19:35:27 +05305021 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d, nw_type %d, dot11mode %d",
5022 session_entry->currentOperChannel,
5023 ch_change_req->targetChannel,
5024 ch_change_req->ch_width,
5025 ch_change_req->nw_type,
5026 ch_change_req->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005027
5028 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005029 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005030 session_entry->ch_center_freq_seg0 =
5031 ch_change_req->center_freq_seg_0;
5032 session_entry->ch_center_freq_seg1 =
5033 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005034 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005035 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005036 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005037 session_entry->htRecommendedTxWidthSet =
5038 session_entry->htSupportedChannelWidthSet;
5039 session_entry->currentOperChannel =
5040 ch_change_req->targetChannel;
5041 session_entry->limRFBand =
5042 lim_get_rf_band(session_entry->currentOperChannel);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305043 session_entry->cac_duration_ms = ch_change_req->cac_duration_ms;
5044 session_entry->dfs_regdomain = ch_change_req->dfs_regdomain;
5045 session_entry->maxTxPower = max_tx_pwr;
Vignesh Viswanathan153ae932018-04-11 14:24:13 +05305046
5047 /* Update the global beacon filter */
5048 lim_update_bcn_probe_filter(mac_ctx, session_entry);
5049
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005050 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08005051 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005052 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005053 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005054 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005055 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005056 }
5057
5058 session_entry->lim11hEnable = val;
5059 session_entry->dot11mode = ch_change_req->dot11mode;
Bala Venkateshb39ed152017-12-26 19:35:27 +05305060 session_entry->nwType = ch_change_req->nw_type;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305061 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005062 &ch_change_req->operational_rateset,
5063 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305064 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005065 &ch_change_req->extended_rateset,
5066 sizeof(session_entry->extRateSet));
Abhishek Singh20a8e442018-09-12 15:50:44 +05305067
5068#ifdef CONFIG_VDEV_SM
Abhishek Singha063f1c2018-09-19 11:37:51 +05305069 mlme_set_chan_switch_in_progress(session_entry->vdev, true);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305070 if (wlan_vdev_mlme_get_state(session_entry->vdev) ==
5071 WLAN_VDEV_S_DFS_CAC_WAIT)
5072 wlan_vdev_mlme_sm_deliver_evt(session_entry->vdev,
5073 WLAN_VDEV_SM_EV_RADAR_DETECTED,
5074 sizeof(*session_entry),
5075 session_entry);
5076 else
5077 wlan_vdev_mlme_sm_deliver_evt(session_entry->vdev,
5078 WLAN_VDEV_SM_EV_CSA_COMPLETE,
5079 sizeof(*session_entry),
5080 session_entry);
5081
5082
5083#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005084 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5085 session_entry->ch_center_freq_seg0,
5086 session_entry->ch_center_freq_seg1,
5087 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07005088 max_tx_pwr, session_entry->peSessionId,
5089 ch_change_req->cac_duration_ms,
5090 ch_change_req->dfs_regdomain);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305091#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005092}
5093
5094/******************************************************************************
5095* lim_start_bss_update_add_ie_buffer()
5096*
5097***FUNCTION:
5098* This function checks the src buffer and its length and then malloc for
5099* dst buffer update the same
5100*
5101***LOGIC:
5102*
5103***ASSUMPTIONS:
5104*
5105***NOTE:
5106*
5107* @param pMac Pointer to Global MAC structure
5108* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5109* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5110* @param *pSrcData_buff A pointer of uint8_t src buffer
5111* @param srcDataLen src buffer length
5112******************************************************************************/
5113
5114static void
5115lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5116 uint8_t **pDstData_buff,
5117 uint16_t *pDstDataLen,
5118 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5119{
5120
5121 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5122 *pDstDataLen = srcDataLen;
5123
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305124 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005125
5126 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005127 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005128 return;
5129 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305130 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005131 } else {
5132 *pDstData_buff = NULL;
5133 *pDstDataLen = 0;
5134 }
5135}
5136
5137/******************************************************************************
5138* lim_update_add_ie_buffer()
5139*
5140***FUNCTION:
5141* This function checks the src buffer and length if src buffer length more
5142* than dst buffer length then free the dst buffer and malloc for the new src
5143* length, and update the dst buffer and length. But if dst buffer is bigger
5144* than src buffer length then it just update the dst buffer and length
5145*
5146***LOGIC:
5147*
5148***ASSUMPTIONS:
5149*
5150***NOTE:
5151*
5152* @param pMac Pointer to Global MAC structure
5153* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5154* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5155* @param *pSrcData_buff A pointer of uint8_t src buffer
5156* @param srcDataLen src buffer length
5157******************************************************************************/
5158
5159static void
5160lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5161 uint8_t **pDstData_buff,
5162 uint16_t *pDstDataLen,
5163 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5164{
5165
5166 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005167 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005168 return;
5169 }
5170
5171 if (srcDataLen > *pDstDataLen) {
5172 *pDstDataLen = srcDataLen;
5173 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305174 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005175 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305176 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005177
5178 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005179 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005180 *pDstDataLen = 0;
5181 return;
5182 }
5183 }
5184
5185 /* copy the content of buffer into dst buffer
5186 */
5187 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305188 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005189
5190}
5191
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005192/**
5193 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5194 * @pMac : Pointer to Global MAC structure
5195 * @pDstData_buff : A pointer to pointer of dst buffer
5196 * @pDstDataLen : A pointer to pointer of dst buffer length
5197 * @pModifyIE : A pointer to tSirModifyIE
5198 *
5199 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5200 *
5201 * Return:
5202 * True or false depending upon whether IE is updated or not
5203 */
5204static bool
5205lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5206 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5207{
Hong Shi1553d692016-09-28 12:16:19 +08005208 int32_t oui_length;
5209 uint8_t *ibss_ie = NULL;
5210 uint8_t *vendor_ie;
5211#define MAC_VENDOR_OUI "\x00\x16\x32"
5212#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005213
5214 ibss_ie = pModifyIE->pIEBuffer;
5215 oui_length = pModifyIE->oui_length;
5216
5217 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005218 pe_err("Invalid set IBSS vendor IE command length %d",
5219 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005220 return false;
5221 }
5222
Hong Shi1553d692016-09-28 12:16:19 +08005223 /*
5224 * Why replace only beacon OUI data here:
5225 * 1. other ie (such as wpa) shall not be overwritten here.
5226 * 2. per spec, beacon oui ie might be set twice and original one
5227 * shall be updated.
5228 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005229 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005230 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5231 if (vendor_ie) {
5232 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5233 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5234 pModifyIE->ieBufferlength);
5235 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005236 uint16_t new_length;
5237 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005238
Naveen Rawat668dee32017-09-29 14:39:40 -07005239 /*
5240 * check for uint16 overflow before using sum of two numbers as
5241 * length of size to malloc
5242 */
5243 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5244 pe_err("U16 overflow due to %d + %d",
5245 pModifyIE->ieBufferlength, *pDstDataLen);
5246 return false;
5247 }
5248
5249 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5250 new_ptr = qdf_mem_malloc(new_length);
Hong Shi1553d692016-09-28 12:16:19 +08005251 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005252 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005253 return false;
5254 }
5255 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5256 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5257 pModifyIE->ieBufferlength);
5258 qdf_mem_free(*pDstData_buff);
5259 *pDstDataLen = new_length;
5260 *pDstData_buff = new_ptr;
5261 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005262 return true;
5263}
5264
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005265/*
5266* lim_process_modify_add_ies() - process modify additional IE req.
5267*
5268* @mac_ctx: Pointer to Global MAC structure
5269* @msg_buf: pointer to the SME message buffer
5270*
5271* This function update the PE buffers for additional IEs.
5272*
5273* Return: None
5274*/
5275static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5276 uint32_t *msg_buf)
5277{
5278 tpSirModifyIEsInd modify_add_ies;
5279 tpPESession session_entry;
5280 uint8_t session_id;
5281 bool ret = false;
5282 tSirAddIeParams *add_ie_params;
5283
5284 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005285 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005286 return;
5287 }
5288
5289 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5290 /* Incoming message has smeSession, use BSSID to find PE session */
5291 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005292 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005293
5294 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005295 pe_err("Session not found for given bssid"
5296 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005297 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005298 goto end;
5299 }
5300 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5301 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5302 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005303 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005304 modify_add_ies->modifyIE.pIEBuffer,
5305 modify_add_ies->modifyIE.ieBufferlength,
5306 modify_add_ies->modifyIE.ieID,
5307 modify_add_ies->modifyIE.ieIDLen,
5308 modify_add_ies->updateType);
5309 goto end;
5310 }
5311 add_ie_params = &session_entry->addIeParams;
5312 switch (modify_add_ies->updateType) {
5313 case eUPDATE_IE_PROBE_RESP:
5314 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005315 if (LIM_IS_IBSS_ROLE(session_entry)) {
5316 lim_update_ibss_prop_add_ies(mac_ctx,
5317 &add_ie_params->probeRespData_buff,
5318 &add_ie_params->probeRespDataLen,
5319 &modify_add_ies->modifyIE);
5320 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005321 break;
5322 case eUPDATE_IE_ASSOC_RESP:
5323 /* assoc resp IE */
5324 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305325 QDF_TRACE(QDF_MODULE_ID_PE,
5326 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005327 "assoc resp add ie not present %d"),
5328 add_ie_params->assocRespDataLen);
5329 }
5330 /* search through the buffer and modify the IE */
5331 break;
5332 case eUPDATE_IE_PROBE_BCN:
5333 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005334 if (LIM_IS_IBSS_ROLE(session_entry)) {
5335 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5336 &add_ie_params->probeRespBCNData_buff,
5337 &add_ie_params->probeRespBCNDataLen,
5338 &modify_add_ies->modifyIE);
5339 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005340 if (ret == true && modify_add_ies->modifyIE.notify) {
5341 lim_handle_param_update(mac_ctx,
5342 modify_add_ies->updateType);
5343 }
5344 break;
5345 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005346 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005347 modify_add_ies->updateType);
5348 break;
5349 }
5350end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305351 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005352 modify_add_ies->modifyIE.pIEBuffer = NULL;
5353}
5354
5355/*
5356* lim_process_update_add_ies() - process additional IE update req
5357*
5358* @mac_ctx: Pointer to Global MAC structure
5359* @msg_buf: pointer to the SME message buffer
5360*
5361* This function update the PE buffers for additional IEs.
5362*
5363* Return: None
5364*/
5365static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5366 uint32_t *msg_buf)
5367{
5368 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5369 uint8_t session_id;
5370 tpPESession session_entry;
5371 tSirAddIeParams *addn_ie;
5372 uint16_t new_length = 0;
5373 uint8_t *new_ptr = NULL;
5374 tSirUpdateIE *update_ie;
5375
5376 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005377 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005378 return;
5379 }
5380 update_ie = &update_add_ies->updateIE;
5381 /* incoming message has smeSession, use BSSID to find PE session */
5382 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005383 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005384
5385 if (NULL == session_entry) {
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05305386 pe_debug("Session not found for given bssid"
5387 MAC_ADDRESS_STR,
5388 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005389 goto end;
5390 }
5391 addn_ie = &session_entry->addIeParams;
5392 /* if len is 0, upper layer requested freeing of buffer */
5393 if (0 == update_ie->ieBufferlength) {
5394 switch (update_add_ies->updateType) {
5395 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305396 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005397 addn_ie->probeRespData_buff = NULL;
5398 addn_ie->probeRespDataLen = 0;
5399 break;
5400 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305401 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005402 addn_ie->assocRespData_buff = NULL;
5403 addn_ie->assocRespDataLen = 0;
5404 break;
5405 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305406 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005407 addn_ie->probeRespBCNData_buff = NULL;
5408 addn_ie->probeRespBCNDataLen = 0;
5409
5410 if (update_ie->notify)
5411 lim_handle_param_update(mac_ctx,
5412 update_add_ies->updateType);
5413 break;
5414 default:
5415 break;
5416 }
5417 return;
5418 }
5419 switch (update_add_ies->updateType) {
5420 case eUPDATE_IE_PROBE_RESP:
5421 if (update_ie->append) {
5422 /*
5423 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005424 * with combined length.
5425 * Multiple back to back append commands
5426 * can lead to a huge length.So, check
5427 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005428 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005429 if (addn_ie->probeRespDataLen >
5430 (USHRT_MAX - update_ie->ieBufferlength)) {
5431 pe_err("IE Length overflow, curr:%d, new:%d",
5432 addn_ie->probeRespDataLen,
5433 update_ie->ieBufferlength);
5434 goto end;
5435 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005436 new_length = update_ie->ieBufferlength +
5437 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305438 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005439 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005440 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005441 goto end;
5442 }
5443 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305444 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005445 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305446 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005447 update_ie->pAdditionIEBuffer,
5448 update_ie->ieBufferlength);
5449 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305450 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005451 /* adjust length accordingly */
5452 addn_ie->probeRespDataLen = new_length;
5453 /* save refernece of local buffer in PE session */
5454 addn_ie->probeRespData_buff = new_ptr;
5455 goto end;
5456 }
5457 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5458 &addn_ie->probeRespDataLen,
5459 update_ie->pAdditionIEBuffer,
5460 update_ie->ieBufferlength);
5461 break;
5462 case eUPDATE_IE_ASSOC_RESP:
5463 /* assoc resp IE */
5464 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5465 &addn_ie->assocRespDataLen,
5466 update_ie->pAdditionIEBuffer,
5467 update_ie->ieBufferlength);
5468 break;
5469 case eUPDATE_IE_PROBE_BCN:
5470 /* probe resp Bcn IE */
5471 lim_update_add_ie_buffer(mac_ctx,
5472 &addn_ie->probeRespBCNData_buff,
5473 &addn_ie->probeRespBCNDataLen,
5474 update_ie->pAdditionIEBuffer,
5475 update_ie->ieBufferlength);
5476 if (update_ie->notify)
5477 lim_handle_param_update(mac_ctx,
5478 update_add_ies->updateType);
5479 break;
5480 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005481 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005482 break;
5483 }
5484end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305485 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005486 update_ie->pAdditionIEBuffer = NULL;
5487}
5488
5489/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305490 * send_extended_chan_switch_action_frame()- function to send ECSA
5491 * action frame for each sta connected to SAP/GO and AP in case of
5492 * STA .
5493 * @mac_ctx: pointer to global mac structure
5494 * @new_channel: new channel to switch to.
5495 * @ch_bandwidth: BW of channel to calculate op_class
5496 * @session_entry: pe session
5497 *
5498 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5499 *
5500 * Return: void
5501 */
5502
5503static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5504 uint16_t new_channel, uint8_t ch_bandwidth,
5505 tpPESession session_entry)
5506{
5507 uint16_t op_class;
5508 uint8_t switch_mode = 0, i;
5509 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005510 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305511
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005512 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305513 mac_ctx->scan.countryCodeCurrent,
5514 new_channel,
5515 ch_bandwidth);
5516
5517 if (LIM_IS_AP_ROLE(session_entry) &&
5518 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005519 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305520
gaoleze2920bd2017-03-21 17:38:42 +08005521 switch_count = session_entry->gLimChannelSwitch.switchCount;
5522
Abhishek Singh518323d2015-10-19 17:42:01 +05305523 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005524 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305525 psta =
5526 session_entry->dph.dphHashTable.pDphNodeArray + i;
5527 if (psta && psta->added)
5528 lim_send_extended_chan_switch_action_frame(
5529 mac_ctx,
5530 psta->staAddr,
5531 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005532 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305533 }
5534 } else if (LIM_IS_STA_ROLE(session_entry)) {
5535 lim_send_extended_chan_switch_action_frame(mac_ctx,
5536 session_entry->bssId,
5537 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005538 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305539 }
5540
5541}
5542
gaolez76d2a162017-03-21 19:23:58 +08005543void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5544 uint16_t new_channel,
5545 uint8_t ch_bandwidth,
5546 tpPESession session_entry)
5547{
5548 uint16_t op_class;
5549 uint8_t switch_mode = 0, i;
5550 uint8_t switch_count;
5551 tpDphHashNode psta;
5552 tpDphHashNode dph_node_array_ptr;
5553
5554 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5555
5556 op_class = wlan_reg_dmn_get_opclass_from_channel(
5557 mac_ctx->scan.countryCodeCurrent,
5558 new_channel, ch_bandwidth);
5559
5560 if (LIM_IS_AP_ROLE(session_entry) &&
5561 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5562 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5563
5564 switch_count = session_entry->gLimChannelSwitch.switchCount;
5565
5566 if (LIM_IS_AP_ROLE(session_entry)) {
5567 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5568 psta = dph_node_array_ptr + i;
5569 if (!(psta && psta->added))
5570 continue;
5571 if (session_entry->lim_non_ecsa_cap_num == 0)
5572 lim_send_extended_chan_switch_action_frame
5573 (mac_ctx, psta->staAddr, switch_mode,
5574 op_class, new_channel, switch_count,
5575 session_entry);
5576 else
5577 lim_send_channel_switch_mgmt_frame
5578 (mac_ctx, psta->staAddr, switch_mode,
5579 new_channel, switch_count,
5580 session_entry);
5581 }
5582 } else if (LIM_IS_STA_ROLE(session_entry)) {
5583 lim_send_extended_chan_switch_action_frame
5584 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5585 new_channel, switch_count, session_entry);
5586 }
5587}
5588
5589/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005590 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5591 *
5592 * @mac_ctx: Pointer to Global MAC structure
5593 * @msg_buf: pointer to the SME message buffer
5594 *
5595 * This function processes SME request messages from HDD or upper layer
5596 * application.
5597 *
5598 * Return: None
5599 */
5600static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5601 uint32_t *msg_buf)
5602{
5603 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5604 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005605 uint8_t session_id;
5606 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005607 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005608
5609 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005610 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005611 return;
5612 }
5613
5614 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5615 session_entry = pe_find_session_by_bssid(mac_ctx,
5616 dfs_csa_ie_req->bssid, &session_id);
5617 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005618 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005619 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5620 return;
5621 }
5622
5623 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005624 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005625 GET_LIM_SYSTEM_ROLE(session_entry));
5626 return;
5627 }
5628
5629 /* target channel */
5630 session_entry->gLimChannelSwitch.primaryChannel =
5631 dfs_csa_ie_req->targetChannel;
5632
5633 /* Channel switch announcement needs to be included in beacon */
5634 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005635 session_entry->gLimChannelSwitch.switchCount =
5636 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005637 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005638 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305639 session_entry->gLimChannelSwitch.sec_ch_offset =
5640 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005641 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005642 session_entry->gLimChannelSwitch.switchMode =
5643 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005644
5645 /*
5646 * Validate if SAP is operating HT or VHT mode and set the Channel
5647 * Switch Wrapper element with the Wide Band Switch subelement.
5648 */
5649 if (true != session_entry->vhtCapability)
5650 goto skip_vht;
5651
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005652 /* Now encode the Wider Ch BW element depending on the ch width */
5653 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005654 switch (dfs_csa_ie_req->ch_params.ch_width) {
5655 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005656 /*
5657 * Wide channel BW sublement in channel wrapper element is not
5658 * required in case of 20 Mhz operation. Currently It is set
5659 * only set in case of 40/80 Mhz Operation.
5660 */
5661 session_entry->dfsIncludeChanWrapperIe = false;
5662 wider_bw_ch_switch->newChanWidth =
5663 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5664 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005665 case CH_WIDTH_40MHZ:
5666 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005667 wider_bw_ch_switch->newChanWidth =
5668 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5669 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005670 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005671 session_entry->dfsIncludeChanWrapperIe = true;
5672 wider_bw_ch_switch->newChanWidth =
5673 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5674 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005675 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005676 session_entry->dfsIncludeChanWrapperIe = true;
5677 wider_bw_ch_switch->newChanWidth =
5678 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5679 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005680 case CH_WIDTH_80P80MHZ:
5681 session_entry->dfsIncludeChanWrapperIe = true;
5682 wider_bw_ch_switch->newChanWidth =
5683 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005684 /*
5685 * This is not applicable for 20/40/80 Mhz.
5686 * Only used when we support 80+80 Mhz operation.
5687 * In case of 80+80 Mhz, this parameter indicates
5688 * center channel frequency index of 80 Mhz channel of
5689 * frequency segment 1.
5690 */
5691 wider_bw_ch_switch->newCenterChanFreq1 =
5692 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005693 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005694 default:
5695 session_entry->dfsIncludeChanWrapperIe = false;
5696 /*
5697 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5698 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5699 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005700 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005701 break;
5702 }
5703 /* Fetch the center channel based on the channel width */
5704 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005705 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005706skip_vht:
5707 /* Send CSA IE request from here */
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05305708 lim_send_dfs_chan_sw_ie_update(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305709
5710 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5711 ch_offset = BW80;
5712 else
5713 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5714
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005715 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305716 session_entry->gLimChannelSwitch.switchCount,
5717 session_entry->gLimChannelSwitch.primaryChannel,
5718 session_entry->gLimChannelSwitch.ch_width,
5719 session_entry->dfsIncludeChanWrapperIe,
5720 ch_offset);
5721
gaolez76d2a162017-03-21 19:23:58 +08005722 /* Send ECSA/CSA Action frame after updating the beacon */
5723 if (CHAN_HOP_ALL_BANDS_ENABLE)
5724 lim_send_chan_switch_action_frame(mac_ctx,
5725 session_entry->gLimChannelSwitch.primaryChannel,
5726 ch_offset, session_entry);
5727 else
5728 send_extended_chan_switch_action_frame(mac_ctx,
5729 session_entry->gLimChannelSwitch.primaryChannel,
5730 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005731}
5732
5733/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305734 * lim_process_ext_change_channel()- function to send ECSA
5735 * action frame for STA/CLI .
5736 * @mac_ctx: pointer to global mac structure
5737 * @msg: params from sme for new channel.
5738 *
5739 * This function is called to send ECSA frame for STA/CLI.
5740 *
5741 * Return: void
5742 */
5743
5744static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5745 uint32_t *msg)
5746{
5747 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5748 (struct sir_sme_ext_cng_chan_req *) msg;
5749 tpPESession session_entry = NULL;
5750
5751 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005752 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305753 return;
5754 }
5755 session_entry =
5756 pe_find_session_by_sme_session_id(mac_ctx,
5757 ext_chng_channel->session_id);
5758 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005759 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305760 ext_chng_channel->session_id);
5761 return;
5762 }
5763 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005764 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305765 return;
5766 }
5767 send_extended_chan_switch_action_frame(mac_ctx,
5768 ext_chng_channel->new_channel,
5769 0, session_entry);
5770}
5771
5772/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005773 * lim_process_nss_update_request() - process sme nss update req
5774 *
5775 * @mac_ctx: Pointer to Global MAC structure
5776 * @msg_buf: pointer to the SME message buffer
5777 *
5778 * This function processes SME request messages from HDD or upper layer
5779 * application.
5780 *
5781 * Return: None
5782 */
5783static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5784 uint32_t *msg_buf)
5785{
5786 struct sir_nss_update_request *nss_update_req_ptr;
5787 tpPESession session_entry = NULL;
5788
5789 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005790 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005791 return;
5792 }
5793
5794 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305795 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005796 nss_update_req_ptr->vdev_id);
5797 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005798 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005799 nss_update_req_ptr->vdev_id);
5800 return;
5801 }
5802
5803 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005804 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005805 GET_LIM_SYSTEM_ROLE(session_entry));
5806 return;
5807 }
5808
5809 /* populate nss field in the beacon */
5810 session_entry->gLimOperatingMode.present = 1;
5811 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05305812 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
5813
5814 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
5815 (session_entry->ch_width > CH_WIDTH_80MHZ))
5816 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
5817
5818 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
5819
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005820 /* Send nss update request from here */
5821 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005822 QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005823 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005824 return;
5825 }
5826
5827 lim_send_beacon_ind(mac_ctx, session_entry);
5828}
5829
5830/**
5831 * lim_process_set_ie_req() - process sme set IE request
5832 *
5833 * @mac_ctx: Pointer to Global MAC structure
5834 * @msg_buf: pointer to the SME message buffer
5835 *
5836 * This function processes SME request messages from HDD or upper layer
5837 * application.
5838 *
5839 * Return: None
5840 */
5841static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5842{
5843 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305844 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005845
5846 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005847 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005848 return;
5849 }
5850
5851 msg = (struct send_extcap_ie *)msg_buf;
5852 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305853 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005854 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005855
5856}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005857
5858#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Arif Hussain05fb4872018-01-03 16:02:55 -08005859
5860/**
5861 * obss_color_collision_process_color_disable() - Disable bss color
5862 * @mac_ctx: Pointer to Global MAC structure
5863 * @session: pointer to session
5864 *
5865 * This function will disbale bss color.
5866 *
5867 * Return: None
5868 */
5869static void obss_color_collision_process_color_disable(tpAniSirGlobal mac_ctx,
5870 tpPESession session)
5871{
5872 tUpdateBeaconParams beacon_params;
5873
5874 if (!session) {
5875 pe_err("Invalid session");
5876 return;
5877 }
5878
5879 if (session->valid && !LIM_IS_AP_ROLE(session)) {
5880 pe_err("Invalid SystemRole %d",
5881 GET_LIM_SYSTEM_ROLE(session));
5882 return;
5883 }
5884
5885 if (session->bss_color_changing == 1) {
5886 pe_warn("%d: color change in progress", session->smeSessionId);
5887 /* Continue color collision detection */
5888 lim_send_obss_color_collision_cfg(mac_ctx, session,
5889 OBSS_COLOR_COLLISION_DETECTION);
5890 return;
5891 }
5892
5893 if (session->he_op.bss_col_disabled == 1) {
5894 pe_warn("%d: bss color already disabled",
5895 session->smeSessionId);
5896 /* Continue free color detection */
5897 lim_send_obss_color_collision_cfg(mac_ctx, session,
5898 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5899 return;
5900 }
5901
5902 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5903 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5904 session->he_op.bss_col_disabled = 1;
Arif Hussain05fb4872018-01-03 16:02:55 -08005905 beacon_params.bss_color_disabled = 1;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005906 beacon_params.bss_color = session->he_op.bss_color;
Arif Hussain05fb4872018-01-03 16:02:55 -08005907
5908 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005909 QDF_STATUS_SUCCESS) {
Arif Hussain05fb4872018-01-03 16:02:55 -08005910 pe_err("Unable to set op mode IE in beacon");
5911 return;
5912 }
5913
5914 lim_send_beacon_params(mac_ctx, &beacon_params, session);
5915 lim_send_obss_color_collision_cfg(mac_ctx, session,
5916 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5917}
5918
5919/**
5920 * obss_color_collision_process_color_change() - Process bss color change
5921 * @mac_ctx: Pointer to Global MAC structure
5922 * @session: pointer to session
5923 * @obss_color_info: obss color collision/free slot indication info
5924 *
5925 * This function selects new color ib case of bss color collision.
5926 *
5927 * Return: None
5928 */
5929static void obss_color_collision_process_color_change(tpAniSirGlobal mac_ctx,
5930 tpPESession session,
5931 struct wmi_obss_color_collision_info *obss_color_info)
5932{
5933 int i, num_bss_color = 0;
5934 uint32_t bss_color_bitmap;
5935 uint8_t bss_color_index_array[MAX_BSS_COLOR_VALUE];
5936 uint32_t rand_byte = 0;
5937 struct sir_set_he_bss_color he_bss_color;
5938 bool is_color_collision = false;
5939
5940
5941 if (session->bss_color_changing == 1) {
5942 pe_err("%d: color change in progress", session->smeSessionId);
5943 return;
5944 }
5945
5946 if (!session->he_op.bss_col_disabled) {
5947 if (session->he_op.bss_color < 32)
5948 is_color_collision = (obss_color_info->
5949 obss_color_bitmap_bit0to31 >>
5950 session->he_op.bss_color) & 0x01;
5951 else
5952 is_color_collision = (obss_color_info->
5953 obss_color_bitmap_bit32to63 >>
5954 (session->he_op.bss_color -
Arif Hussain9e8c5612018-04-12 16:35:48 -07005955 32)) & 0x01;
Arif Hussain05fb4872018-01-03 16:02:55 -08005956 if (!is_color_collision) {
5957 pe_err("%d: color collision not found, curr_color: %d",
5958 session->smeSessionId,
5959 session->he_op.bss_color);
5960 return;
5961 }
5962 }
5963
5964 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit0to31;
5965
5966 /* Skip color zero */
5967 bss_color_bitmap = bss_color_bitmap >> 1;
5968 for (i = 0; (i < 31) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5969 if (!(bss_color_bitmap & 0x01)) {
5970 bss_color_index_array[num_bss_color] = i + 1;
5971 num_bss_color++;
5972 }
5973 bss_color_bitmap = bss_color_bitmap >> 1;
5974 }
5975
5976 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit32to63;
5977 for (i = 0; (i < 32) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5978 if (!(bss_color_bitmap & 0x01)) {
5979 bss_color_index_array[num_bss_color] = i + 32;
5980 num_bss_color++;
5981 }
5982 bss_color_bitmap = bss_color_bitmap >> 1;
5983 }
5984
5985 if (num_bss_color) {
5986 qdf_get_random_bytes((void *) &rand_byte, 1);
5987 i = (rand_byte + qdf_mc_timer_get_system_ticks()) %
5988 num_bss_color;
5989 pe_debug("New bss color = %d", bss_color_index_array[i]);
5990 he_bss_color.session_id = obss_color_info->vdev_id;
5991 he_bss_color.bss_color = bss_color_index_array[i];
5992 lim_process_set_he_bss_color(mac_ctx,
5993 (uint32_t *)&he_bss_color);
5994 } else {
5995 pe_err("Unable to find bss color from bitmasp");
5996 if (obss_color_info->evt_type ==
5997 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY &&
5998 session->obss_color_collision_dec_evt ==
5999 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6000 /* In dot11BSSColorCollisionAPPeriod and
6001 * timer expired, time to disable bss color.
6002 */
6003 obss_color_collision_process_color_disable(mac_ctx,
6004 session);
6005 else
6006 /*
6007 * Enter dot11BSSColorCollisionAPPeriod period.
6008 */
6009 lim_send_obss_color_collision_cfg(mac_ctx, session,
6010 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY);
6011 }
6012}
6013
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006014void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6015{
6016 struct sir_set_he_bss_color *bss_color;
6017 tpPESession session_entry = NULL;
6018 tUpdateBeaconParams beacon_params;
6019
6020 if (!msg_buf) {
6021 pe_err("Buffer is Pointing to NULL");
6022 return;
6023 }
6024
6025 bss_color = (struct sir_set_he_bss_color *)msg_buf;
6026 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
6027 bss_color->session_id);
6028 if (!session_entry) {
6029 pe_err("Session not found for given session_id %d",
6030 bss_color->session_id);
6031 return;
6032 }
6033
6034 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6035 pe_err("Invalid SystemRole %d",
6036 GET_LIM_SYSTEM_ROLE(session_entry));
6037 return;
6038 }
6039
6040 if (bss_color->bss_color == session_entry->he_op.bss_color) {
6041 pe_err("No change in BSS color, current BSS color %d",
6042 bss_color->bss_color);
6043 return;
6044 }
6045 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
6046 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
6047 session_entry->he_op.bss_col_disabled = 1;
6048 session_entry->he_bss_color_change.countdown =
6049 BSS_COLOR_SWITCH_COUNTDOWN;
6050 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08006051 beacon_params.bss_color_disabled = 1;
6052 beacon_params.bss_color = session_entry->he_op.bss_color;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006053 session_entry->bss_color_changing = 1;
6054
6055 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006056 QDF_STATUS_SUCCESS) {
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006057 pe_err("Unable to set op mode IE in beacon");
6058 return;
6059 }
6060
6061 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
Arif Hussain05fb4872018-01-03 16:02:55 -08006062 lim_send_obss_color_collision_cfg(mac_ctx, session_entry,
6063 OBSS_COLOR_COLLISION_DETECTION_DISABLE);
6064}
6065
6066void lim_send_obss_color_collision_cfg(tpAniSirGlobal mac_ctx,
6067 tpPESession session,
6068 enum wmi_obss_color_collision_evt_type
6069 event_type)
6070{
6071 struct wmi_obss_color_collision_cfg_param *cfg_param;
6072 struct scheduler_msg msg = {0};
6073
6074 if (!session) {
6075 pe_err("Invalid session");
6076 return;
6077 }
6078
6079 if (!session->he_capable ||
6080 !session->is_session_obss_color_collision_det_enabled) {
6081 pe_debug("%d: obss color det not enabled, he_cap:%d, sup:%d:%d",
6082 session->smeSessionId, session->he_capable,
6083 session->is_session_obss_color_collision_det_enabled,
6084 mac_ctx->lim.global_obss_color_collision_det_offload);
6085 return;
6086 }
6087
6088 cfg_param = qdf_mem_malloc(sizeof(*cfg_param));
6089 if (!cfg_param) {
6090 pe_err("Failed to allocate memory");
6091 return;
6092 }
6093
6094 pe_debug("%d: sending event:%d", session->smeSessionId, event_type);
6095 qdf_mem_zero(cfg_param, sizeof(*cfg_param));
6096 cfg_param->vdev_id = session->smeSessionId;
6097 cfg_param->evt_type = event_type;
6098 if (LIM_IS_AP_ROLE(session))
6099 cfg_param->detection_period_ms =
6100 OBSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS;
6101 else
6102 cfg_param->detection_period_ms =
6103 OBSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS;
6104
6105 cfg_param->scan_period_ms = OBSS_COLOR_COLLISION_SCAN_PERIOD_MS;
6106 if (event_type == OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6107 cfg_param->free_slot_expiry_time_ms =
6108 OBSS_COLOR_COLLISION_FREE_SLOT_EXPIRY_MS;
6109
6110 msg.type = WMA_OBSS_COLOR_COLLISION_REQ;
6111 msg.bodyptr = cfg_param;
6112 msg.reserved = 0;
6113
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05306114 if (QDF_IS_STATUS_ERROR(scheduler_post_message(QDF_MODULE_ID_PE,
6115 QDF_MODULE_ID_WMA,
6116 QDF_MODULE_ID_WMA,
6117 &msg))) {
Arif Hussain05fb4872018-01-03 16:02:55 -08006118 pe_err("Failed to post WMA_OBSS_COLOR_COLLISION_REQ to WMA");
6119 qdf_mem_free(cfg_param);
6120 } else {
6121 session->obss_color_collision_dec_evt = event_type;
6122 }
6123}
6124
6125void lim_process_obss_color_collision_info(tpAniSirGlobal mac_ctx,
6126 uint32_t *msg_buf)
6127{
6128 struct wmi_obss_color_collision_info *obss_color_info;
6129 tpPESession session;
6130
6131 if (!msg_buf) {
6132 pe_err("Buffer is Pointing to NULL");
6133 return;
6134 }
6135
6136 obss_color_info = (struct wmi_obss_color_collision_info *)msg_buf;
6137 session = pe_find_session_by_sme_session_id(mac_ctx,
6138 obss_color_info->vdev_id);
6139 if (!session) {
6140 pe_err("Session not found for given session_id %d",
6141 obss_color_info->vdev_id);
6142 return;
6143 }
6144
6145 pe_debug("vdev_id:%d, evt:%d:%d, 0to31:0x%x, 32to63:0x%x, cap:%d:%d:%d",
6146 obss_color_info->vdev_id,
6147 obss_color_info->evt_type,
6148 session->obss_color_collision_dec_evt,
6149 obss_color_info->obss_color_bitmap_bit0to31,
6150 obss_color_info->obss_color_bitmap_bit32to63,
6151 session->he_capable,
6152 session->is_session_obss_color_collision_det_enabled,
6153 mac_ctx->lim.global_obss_color_collision_det_offload);
6154
6155 if (!session->he_capable ||
6156 !session->is_session_obss_color_collision_det_enabled) {
6157 return;
6158 }
6159
6160 switch (obss_color_info->evt_type) {
6161 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
6162 pe_err("%d: FW disabled obss color det. he_cap:%d, sup:%d:%d",
6163 session->smeSessionId, session->he_capable,
6164 session->is_session_obss_color_collision_det_enabled,
6165 mac_ctx->lim.global_obss_color_collision_det_offload);
6166 session->is_session_obss_color_collision_det_enabled = false;
6167 return;
6168 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
6169 case OBSS_COLOR_COLLISION_DETECTION:
6170 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
6171 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6172 pe_debug("Invalid System Role %d",
6173 GET_LIM_SYSTEM_ROLE(session));
6174 return;
6175 }
6176
6177 if (session->obss_color_collision_dec_evt !=
6178 obss_color_info->evt_type) {
6179 pe_debug("%d: Wrong event: %d, skiping",
6180 obss_color_info->vdev_id,
6181 obss_color_info->evt_type);
6182 return;
6183 }
6184 obss_color_collision_process_color_change(mac_ctx, session,
6185 obss_color_info);
6186 break;
6187 default:
6188 pe_err("%d: Invalid event type %d",
6189 obss_color_info->vdev_id, obss_color_info->evt_type);
6190 return;
6191 }
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006192}
6193#endif
Abhishek Singh20a8e442018-09-12 15:50:44 +05306194
6195#ifdef CONFIG_VDEV_SM
6196void lim_send_csa_restart_req(tpAniSirGlobal mac_ctx, uint8_t vdev_id)
6197{
6198 tpPESession session;
6199
6200 session = pe_find_session_by_sme_session_id(mac_ctx, vdev_id);
6201
6202 if (!session) {
6203 pe_err("session not found for vdev id %d", vdev_id);
6204 return;
6205 }
6206
6207 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
6208 WLAN_VDEV_SM_EV_CSA_RESTART,
6209 sizeof(*session), session);
6210}
6211#endif