blob: 9f2c437a2ebf761e7b164749e950a6e4f0676b02 [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#include "sap_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080053#include <lim_ft.h>
Naveen Rawat3b6068c2016-04-14 19:01:06 -070054#include "cds_regdomain.h"
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053055#include "lim_process_fils.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070056#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080057
58/*
59 * This overhead is time for sending NOA start to host in case of GO/sending
60 * NULL data & receiving ACK in case of P2P Client and starting actual scanning
61 * with init scan req/rsp plus in case of concurrency, taking care of sending
62 * null data and receiving ACK to/from AP/Also SetChannel with calibration
63 * is taking around 7ms .
64 */
65#define SCAN_MESSAGING_OVERHEAD 20 /* in msecs */
66#define JOIN_NOA_DURATION 2000 /* in msecs */
67#define OEM_DATA_NOA_DURATION 60 /* in msecs */
68#define DEFAULT_PASSIVE_MAX_CHANNEL_TIME 110 /* in msecs */
69
70#define CONV_MS_TO_US 1024 /* conversion factor from ms to us */
71
Paul Zhangd2315472017-02-22 10:02:50 +080072#define BEACON_INTERVAL_THRESHOLD 50 /* in msecs */
73#define STA_BURST_SCAN_DURATION 120 /* in msecs */
74
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080075/* SME REQ processing function templates */
76static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080077static bool __lim_process_sme_start_bss_req(tpAniSirGlobal,
78 struct scheduler_msg *pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080079static void __lim_process_sme_join_req(tpAniSirGlobal, uint32_t *);
80static void __lim_process_sme_reassoc_req(tpAniSirGlobal, uint32_t *);
81static void __lim_process_sme_disassoc_req(tpAniSirGlobal, uint32_t *);
82static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal, uint32_t *);
83static void __lim_process_sme_deauth_req(tpAniSirGlobal, uint32_t *);
84static void __lim_process_sme_set_context_req(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080085static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal,
86 struct scheduler_msg *pMsg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053087static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
88 uint32_t *msg_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080089static void lim_process_sme_channel_change_request(tpAniSirGlobal pMac,
90 uint32_t *pMsg);
91static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg);
92static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal pMac, uint32_t *pMsg);
93static void lim_process_nss_update_request(tpAniSirGlobal pMac, uint32_t *pMsg);
94static void lim_process_set_ie_req(tpAniSirGlobal pMac, uint32_t *pMsg);
95
96static void lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
97 uint8_t **pDstData_buff,
98 uint16_t *pDstDataLen,
99 uint8_t *pSrcData_buff,
100 uint16_t srcDataLen);
101
102static void lim_update_add_ie_buffer(tpAniSirGlobal pMac,
103 uint8_t **pDstData_buff,
104 uint16_t *pDstDataLen,
105 uint8_t *pSrcData_buff, uint16_t srcDataLen);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800106static bool lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac,
107 uint8_t **pDstData_buff,
108 uint16_t *pDstDataLen,
109 tSirModifyIE *pModifyIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800110static void lim_process_modify_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
111
112static void lim_process_update_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
113
Abhishek Singh518323d2015-10-19 17:42:01 +0530114static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
115 uint32_t *msg);
116
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800117/**
118 * lim_process_set_hw_mode() - Send set HW mode command to WMA
119 * @mac: Globacl MAC pointer
120 * @msg: Message containing the hw mode index
121 *
122 * Send the set HW mode command to WMA
123 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530124 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800125 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530126static QDF_STATUS lim_process_set_hw_mode(tpAniSirGlobal mac, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800127{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530128 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700129 struct scheduler_msg message = {0};
Tushnim Bhattacharyya66348bd2017-03-09 15:02:10 -0800130 struct policy_mgr_hw_mode *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800131 uint32_t len;
132 struct s_sir_set_hw_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700133 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800134 struct sir_set_hw_mode_resp *param;
135
136 buf = (struct s_sir_set_hw_mode *) msg;
137 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700138 pe_err("Set HW mode param is NULL");
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530139 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800140 /* To free the active command list */
141 goto fail;
142 }
143
144 len = sizeof(*req_msg);
145
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530146 req_msg = qdf_mem_malloc(len);
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530147 if (!req_msg) {
148 pe_debug("failed to allocate memory");
149 status = QDF_STATUS_E_NOMEM;
150 goto fail;
151 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800153 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530154 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800155 /* Other parameters are not needed for WMA */
156
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800157 message.bodyptr = req_msg;
158 message.type = SIR_HAL_PDEV_SET_HW_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700160 pe_debug("Posting SIR_HAL_SOC_SET_HW_MOD to WMA");
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530161 status = scheduler_post_message(QDF_MODULE_ID_PE,
162 QDF_MODULE_ID_WMA,
163 QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530164 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700165 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530167 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168 goto fail;
169 }
170 return status;
171fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530172 param = qdf_mem_malloc(sizeof(*param));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700173 if (!param)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530174 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800175 param->status = SET_HW_MODE_STATUS_ECANCELED;
176 param->cfgd_hw_mode_index = 0;
177 param->num_vdev_mac_entries = 0;
178 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
179 resp_msg.bodyptr = param;
180 resp_msg.bodyval = 0;
181 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530182 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800183}
184
185/**
186 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
187 * @mac: Global MAC pointer
188 * @msg: Message containing the dual mac config parameter
189 *
190 * Send the set dual mac config command to WMA
191 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530192 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800193 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530194static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800195 uint32_t *msg)
196{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530197 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700198 struct scheduler_msg message = {0};
Srinivas Girigowdaeb6ecf32018-02-15 17:04:22 -0800199 struct policy_mgr_dual_mac_config *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800200 uint32_t len;
201 struct sir_set_dual_mac_cfg *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700202 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203 struct sir_dual_mac_config_resp *param;
204
205 buf = (struct sir_set_dual_mac_cfg *) msg;
206 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700207 pe_err("Set Dual mac config is NULL");
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530208 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800209 /* To free the active command list */
210 goto fail;
211 }
212
213 len = sizeof(*req_msg);
214
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530215 req_msg = qdf_mem_malloc(len);
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530216 if (!req_msg) {
217 pe_debug("failed to allocate memory");
218 status = QDF_STATUS_E_NOMEM;
219 goto fail;
220 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800221
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800222 req_msg->scan_config = buf->set_dual_mac.scan_config;
223 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
224 /* Other parameters are not needed for WMA */
225
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800226 message.bodyptr = req_msg;
227 message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800228
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700229 pe_debug("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800230 req_msg->scan_config, req_msg->fw_mode_config);
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530231 status = scheduler_post_message(QDF_MODULE_ID_PE,
232 QDF_MODULE_ID_WMA,
233 QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530234 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700235 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800236 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530237 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800238 goto fail;
239 }
240 return status;
241fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530242 param = qdf_mem_malloc(sizeof(*param));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700243 if (!param)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530244 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800245 param->status = SET_HW_MODE_STATUS_ECANCELED;
246 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
247 resp_msg.bodyptr = param;
248 resp_msg.bodyval = 0;
249 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530250 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800251}
252
253/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800254 * lim_process_set_antenna_mode_req() - Set antenna mode command
255 * to WMA
256 * @mac: Global MAC pointer
257 * @msg: Message containing the antenna mode parameter
258 *
259 * Send the set antenna mode command to WMA
260 *
261 * Return: QDF_STATUS_SUCCESS if message posting is successful
262 */
263static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
264 uint32_t *msg)
265{
266 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700267 struct scheduler_msg message = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800268 struct sir_antenna_mode_param *req_msg;
269 struct sir_set_antenna_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700270 struct scheduler_msg resp_msg = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800271 struct sir_antenna_mode_resp *param;
272
273 buf = (struct sir_set_antenna_mode *) msg;
274 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700275 pe_err("Set antenna mode is NULL");
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530276 status = QDF_STATUS_E_INVAL;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800277 /* To free the active command list */
278 goto fail;
279 }
280
281 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530282 if (!req_msg) {
283 pe_debug("failed to allocate memory");
284 status = QDF_STATUS_E_NOMEM;
285 goto fail;
286 }
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800287
288 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
289 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
290
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800291 message.bodyptr = req_msg;
292 message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800293
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700294 pe_debug("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800295 req_msg->num_rx_chains,
296 req_msg->num_tx_chains);
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530297 status = scheduler_post_message(QDF_MODULE_ID_PE,
298 QDF_MODULE_ID_WMA,
299 QDF_MODULE_ID_WMA, &message);
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800300 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700301 pe_err("scheduler_post_msg failed!(err=%d)",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800302 status);
303 qdf_mem_free(req_msg);
304 goto fail;
305 }
306 return status;
307fail:
308 param = qdf_mem_malloc(sizeof(*param));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700309 if (!param)
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800310 return QDF_STATUS_E_NOMEM;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800311 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
312 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
313 resp_msg.bodyptr = param;
314 resp_msg.bodyval = 0;
315 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530316 return status;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800317}
318
319/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800320 * __lim_is_sme_assoc_cnf_valid()
321 *
322 ***FUNCTION:
323 * This function is called by __lim_process_sme_assoc_cnf_new() upon
324 * receiving SME_ASSOC_CNF.
325 *
326 ***LOGIC:
327 * Message validity checks are performed in this function
328 *
329 ***ASSUMPTIONS:
330 *
331 ***NOTE:
332 *
333 * @param pMeasReq Pointer to Received ASSOC_CNF message
334 * @return true When received SME_ASSOC_CNF is formatted
335 * correctly
336 * false otherwise
337 */
338
339static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
340{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530341 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800342 return false;
343 else
344 return true;
345} /*** end __lim_is_sme_assoc_cnf_valid() ***/
346
347/**
348 * __lim_get_sme_join_req_size_for_alloc()
349 *
350 ***FUNCTION:
351 * This function is called in various places to get IE length
352 * from tSirBssDescription structure
353 * number being scanned.
354 *
355 ***PARAMS:
356 *
357 ***LOGIC:
358 *
359 ***ASSUMPTIONS:
360 * NA
361 *
362 ***NOTE:
363 * NA
364 *
365 * @param pBssDescr
366 * @return Total IE length
367 */
368
369static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
370{
371 uint16_t len = 0;
372
373 if (!pBuf)
374 return len;
375
376 pBuf += sizeof(uint16_t);
377 len = lim_get_u16(pBuf);
Arif Hussainc9651922017-04-16 14:08:23 -0700378 return len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800379}
380
381/**
382 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
383 * @pMac: Global MAC context
384 * @pMsg: Pointer to message posted from SME to LIM.
385 *
386 * Has role only if 11h is enabled. Not used on STA side.
387 * Defers the message if SME is in learn state and brings
388 * the LIM back to normal mode.
389 *
390 * Return: true - If defered false - Otherwise
391 */
392
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800393static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac,
394 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800395{
396 if (lim_is_system_in_scan_state(pMac)) {
397 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700398 pe_err("Could not defer Msg: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800399 return false;
400 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700401 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800402 pMsg->type);
403 return true;
404 }
405 return false;
406}
407
408/**
409 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
410 * @mac_ctx: Pointer to Global MAC structure
411 * @message: Pointer to message posted from SME to LIM.
412 *
413 * Has role only if 11h is enabled. Not used on STA side.
414 * Defers the message if radar is detected.
415 *
416 * Return: true, if defered otherwise return false.
417 */
418static bool
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800419__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx,
420 struct scheduler_msg *message)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800421{
422 /*
423 * fRadarDetCurOperChan will be set only if we
424 * detect radar in current operating channel and
425 * System Role == AP ROLE
426 *
427 * TODO: Need to take care radar detection.
428 *
429 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
430 */
431 if (0) {
432 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700433 pe_err("Could not defer Msg: %d", message->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800434 return false;
435 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700436 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437 message->type);
438 return true;
439 }
440 return false;
441}
442
443/**
444 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
445 * @pMac: Global MAC context
446 * @pMsgBuf: Message from WMA
447 *
448 * handles the notification from HDD. PE just forwards this message to HAL.
449 *
450 * Return: true-Posting to HAL failed, so PE will consume the buffer.
451 * false-Posting to HAL successful, so HAL will consume the buffer.
452 */
453
454static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
455{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700456 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800457 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
458
459 msg.type = WMA_SYS_READY_IND;
460 msg.reserved = 0;
461 msg.bodyptr = pMsgBuf;
462 msg.bodyval = 0;
463
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700464 if (ANI_DRIVER_TYPE(pMac) != QDF_DRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800465 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +0530466 pe_register_mgmt_rx_frm_callback(pMac);
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700467 pe_register_callbacks_with_wma(pMac, ready_req);
Sandeep Puligilla1426d612017-04-12 18:22:06 -0700468 pMac->lim.sme_msg_callback = ready_req->sme_msg_cb;
Vignesh Viswanathan3d478032018-08-02 20:18:53 +0530469 pMac->lim.stop_roaming_callback = ready_req->stop_roaming_cb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800470 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700471
472 pe_debug("sending WMA_SYS_READY_IND msg to HAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800473 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
474
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700475 if (QDF_STATUS_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700476 pe_err("wma_post_ctrl_msg failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800477 return true;
478 }
479 return false;
480}
481
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800482/**
483 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
484 *@mac_ctx: Pointer to Global MAC structure
485 *@session: A pointer to session entry
486 *@sme_start_bss_req: Start BSS Request from upper layers.
487 *
488 * This function is used to configure the start bss parameters
489 * in to the session.
490 *
491 * Return: None.
492 */
493static void
494lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
495 tpSirSmeStartBssReq sme_start_bss_req)
496{
497 session->limSystemRole = eLIM_AP_ROLE;
498 session->privacy = sme_start_bss_req->privacy;
499 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
500 session->authType = sme_start_bss_req->authType;
501 /* Store the DTIM period */
502 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
503 /* Enable/disable UAPSD */
504 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530505 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800506 session->proxyProbeRspEn = 0;
507 } else {
508 /*
509 * To detect PBC overlap in SAP WPS mode,
510 * Host handles Probe Requests.
511 */
512 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
513 session->proxyProbeRspEn = 1;
514 else
515 session->proxyProbeRspEn = 0;
516 }
517 session->ssidHidden = sme_start_bss_req->ssidHidden;
518 session->wps_state = sme_start_bss_req->wps_state;
519 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530520 session->vendor_vht_sap =
521 sme_start_bss_req->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800522 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
523 &session->shortSlotTimeSupported);
524 session->isCoalesingInIBSSAllowed =
525 sme_start_bss_req->isCoalesingInIBSSAllowed;
526
Jiachao Wu712d4fd2017-08-23 16:52:34 +0800527 session->beacon_tx_rate = sme_start_bss_req->beacon_tx_rate;
528
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800529}
530
531/**
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530532 * lim_send_start_vdev_req() - send vdev start request
533 *@session: pe session
534 *@mlm_start_req: vdev start req
535 *
536 * Return: QDF_STATUS
537 */
Abhishek Singh3d30a3b2018-09-12 15:49:18 +0530538#ifdef CONFIG_VDEV_SM
539static QDF_STATUS
540lim_send_start_vdev_req(tpPESession session, tLimMlmStartReq *mlm_start_req)
541{
542 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
543 WLAN_VDEV_SM_EV_START,
544 sizeof(*mlm_start_req),
545 mlm_start_req);
546}
547#else
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530548static QDF_STATUS
549lim_send_start_vdev_req(tpPESession session, tLimMlmStartReq *mlm_start_req)
550{
551 lim_process_mlm_start_req(session->mac_ctx, mlm_start_req);
552
553 return QDF_STATUS_SUCCESS;
554}
Abhishek Singh3d30a3b2018-09-12 15:49:18 +0530555#endif
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530556
557/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800558 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
559 *@mac_ctx: Pointer to Global MAC structure
560 *@msg_buf: A pointer to the SME message buffer
561 *
562 * This function is called to process SME_START_BSS_REQ message
563 * from HDD or upper layer application.
564 *
565 * Return: None
566 */
567static void
568__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
569{
570 uint16_t size;
571 uint32_t val = 0;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700572 QDF_STATUS ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800573 tSirMacChanNum channel_number;
574 tLimMlmStartReq *mlm_start_req = NULL;
575 tpSirSmeStartBssReq sme_start_bss_req = NULL;
576 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
577 /* Flag Used in case of IBSS to Auto generate BSSID. */
578 uint32_t auto_gen_bssid = false;
579 uint8_t session_id;
580 tpPESession session = NULL;
Krunal Sonib37bb352016-12-20 14:12:21 -0800581 uint8_t sme_session_id = 0xFF;
582 uint16_t sme_transaction_id = 0xFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800583 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700584 struct vdev_type_nss *vdev_type_nss;
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530585 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800586
587/* FEATURE_WLAN_DIAG_SUPPORT */
588#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
589 /*
590 * Since the session is not created yet, sending NULL.
591 * The response should have the correct state.
592 */
593 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
594 NULL, 0, 0);
595#endif /* FEATURE_WLAN_DIAG_SUPPORT */
596
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700597 pe_debug("Received START_BSS_REQ");
Krunal Sonib37bb352016-12-20 14:12:21 -0800598 size = sizeof(tSirSmeStartBssReq);
599 sme_start_bss_req = qdf_mem_malloc(size);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700600 if (!sme_start_bss_req) {
Krunal Sonib37bb352016-12-20 14:12:21 -0800601 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
602 goto free;
603 }
604 qdf_mem_copy(sme_start_bss_req, msg_buf, sizeof(tSirSmeStartBssReq));
605 sme_session_id = sme_start_bss_req->sessionId;
606 sme_transaction_id = sme_start_bss_req->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800607
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800608 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
609 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800610 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
611 sme_start_bss_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700612 pe_warn("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800613 ret_code = eSIR_SME_INVALID_PARAMETERS;
614 goto free;
615 }
616
617 /*
618 * This is the place where PE is going to create a session.
619 * If session is not existed, then create a new session
620 */
621 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800622 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800623 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700624 pe_warn("Session Already exists for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800625 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
626 session = NULL;
627 goto free;
628 } else {
629 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800630 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800631 &session_id, mac_ctx->lim.maxStation,
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +0530632 sme_start_bss_req->bssType,
633 sme_start_bss_req->sessionId);
634 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700635 pe_warn("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800636 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
637 goto free;
638 }
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +0530639
640 /* Update the beacon/probe filter in mac_ctx */
641 lim_set_bcn_probe_filter(mac_ctx, session,
642 &sme_start_bss_req->ssId,
643 sme_start_bss_req->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800644 }
645
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700646 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
647 /* Probe resp add ie */
648 lim_start_bss_update_add_ie_buffer(mac_ctx,
649 &session->addIeParams.probeRespData_buff,
650 &session->addIeParams.probeRespDataLen,
651 sme_start_bss_req->addIeParams.
652 probeRespData_buff,
653 sme_start_bss_req->addIeParams.
654 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800655
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700656 /* Probe Beacon add ie */
657 lim_start_bss_update_add_ie_buffer(mac_ctx,
658 &session->addIeParams.probeRespBCNData_buff,
659 &session->addIeParams.probeRespBCNDataLen,
660 sme_start_bss_req->addIeParams.
661 probeRespBCNData_buff,
662 sme_start_bss_req->addIeParams.
663 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800664
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700665 /* Assoc resp IE */
666 lim_start_bss_update_add_ie_buffer(mac_ctx,
667 &session->addIeParams.assocRespData_buff,
668 &session->addIeParams.assocRespDataLen,
669 sme_start_bss_req->addIeParams.
670 assocRespData_buff,
671 sme_start_bss_req->addIeParams.
672 assocRespDataLen);
673 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800674 /* Store the session related params in newly created session */
675 session->pLimStartBssReq = sme_start_bss_req;
676
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800677 session->transactionId = sme_start_bss_req->transactionId;
678
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530679 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800680 &(sme_start_bss_req->htConfig),
681 sizeof(session->htConfig));
682
Sandeep Puligilla98917432016-06-10 13:50:28 -0700683 qdf_mem_copy(&(session->vht_config),
684 &(sme_start_bss_req->vht_config),
685 sizeof(session->vht_config));
686
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800687 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800688 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800689
690 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530691 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800692 (uint8_t *) &sme_start_bss_req->ssId,
693 (sme_start_bss_req->ssId.length + 1));
694
695 session->bssType = sme_start_bss_req->bssType;
696
697 session->nwType = sme_start_bss_req->nwType;
698
699 session->beaconParams.beaconInterval =
700 sme_start_bss_req->beaconInterval;
701
702 /* Store the channel number in session Table */
703 session->currentOperChannel =
704 sme_start_bss_req->channelId;
705
706 /* Store Persona */
707 session->pePersona = sme_start_bss_req->bssPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +0530708 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800709 FL("PE PERSONA=%d"), session->pePersona);
710
711 /* Update the phymode */
712 session->gLimPhyMode = sme_start_bss_req->nwType;
713
714 session->maxTxPower =
715 cfg_get_regulatory_max_transmit_power(mac_ctx,
716 session->currentOperChannel);
717 /* Store the dot 11 mode in to the session Table */
718 session->dot11mode = sme_start_bss_req->dot11mode;
719#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
720 session->cc_switch_mode =
721 sme_start_bss_req->cc_switch_mode;
722#endif
723 session->htCapability =
724 IS_DOT11_MODE_HT(session->dot11mode);
725 session->vhtCapability =
726 IS_DOT11_MODE_VHT(session->dot11mode);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800727
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700728 pe_debug("HT[%d], VHT[%d]",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800729 session->htCapability, session->vhtCapability);
730
731 if (IS_DOT11_MODE_HE(session->dot11mode)) {
732 lim_update_session_he_capable(mac_ctx, session);
733 lim_copy_bss_he_cap(session, sme_start_bss_req);
734 }
735
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800736 session->txLdpcIniFeatureEnabled =
737 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738#ifdef WLAN_FEATURE_11W
739 session->limRmfEnabled =
740 sme_start_bss_req->pmfCapable ? 1 : 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700741 pe_debug("Session RMF enabled: %d", session->limRmfEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800742#endif
743
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530744 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800745 (void *)&sme_start_bss_req->operationalRateSet,
746 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530747 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800748 (void *)&sme_start_bss_req->extendedRateSet,
749 sizeof(tSirMacRateSet));
750
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700751 if (IS_5G_CH(session->currentOperChannel))
752 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
753 else
754 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
755
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800756 switch (sme_start_bss_req->bssType) {
757 case eSIR_INFRA_AP_MODE:
758 lim_configure_ap_start_bss_session(mac_ctx, session,
759 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700760 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700761 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700762 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700763 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800764 break;
765 case eSIR_IBSS_MODE:
766 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
767 lim_get_short_slot_from_phy_mode(mac_ctx, session,
768 session->gLimPhyMode,
769 &session->shortSlotTimeSupported);
770
771 /*
772 * initialize to "OPEN".
773 * will be updated upon key installation
774 */
775 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700776 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800777
778 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700779 case eSIR_NDI_MODE:
780 session->limSystemRole = eLIM_NDI_ROLE;
781 break;
782
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800783
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800784 /*
785 * There is one more mode called auto mode.
786 * which is used no where
787 */
788
789 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
790
791 default:
792 /* not used anywhere...used in scan function */
793 break;
794 }
795
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700796 pe_debug("persona - %d, nss - %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700797 session->pePersona, session->vdev_nss);
798 session->nss = session->vdev_nss;
Abhinav Kumarb074f2f2018-09-15 15:32:11 +0530799 if (!mac_ctx->mlme_cfg->vht_caps.vht_cap_info.enable2x2)
Kiran Kumar Lokerebc6fb2f2018-05-09 19:04:11 -0700800 session->nss = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800801 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700802 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803 * parsed (Re)Assoc request structure
804 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700805 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800806 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530807 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700808 size * sizeof(tpSirAssocReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700809 if (!session->parsedAssocReq) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800810 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
811 goto free;
812 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813 }
814
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700815 if (!sme_start_bss_req->channelId &&
816 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700817 pe_err("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800818 ret_code = eSIR_SME_INVALID_PARAMETERS;
819 goto free;
820 }
821 channel_number = sme_start_bss_req->channelId;
822#ifdef QCA_HT_2040_COEX
823 if (sme_start_bss_req->obssEnabled)
824 session->htSupportedChannelWidthSet =
825 session->htCapability;
826 else
827#endif
828 session->htSupportedChannelWidthSet =
829 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
830 session->htSecondaryChannelOffset =
831 sme_start_bss_req->sec_ch_offset;
832 session->htRecommendedTxWidthSet =
833 (session->htSecondaryChannelOffset) ? 1 : 0;
Abhishek Singh4294f802017-08-10 16:37:07 +0530834 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835 FL("cbMode %u"), sme_start_bss_req->cbMode);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800836 if (lim_is_session_he_capable(session) ||
837 session->vhtCapability || session->htCapability) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838 chanwidth = sme_start_bss_req->vht_channel_width;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700839 pe_debug("vht_channel_width %u htSupportedChannelWidthSet %d",
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800840 sme_start_bss_req->vht_channel_width,
841 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800842 session->ch_width = chanwidth;
843 if (session->htSupportedChannelWidthSet) {
844 session->ch_center_freq_seg0 =
845 sme_start_bss_req->center_freq_seg0;
846 session->ch_center_freq_seg1 =
847 sme_start_bss_req->center_freq_seg1;
848 } else {
849 session->ch_center_freq_seg0 = 0;
850 session->ch_center_freq_seg1 = 0;
851 }
852 }
Gaurank Kathpalia511634b2018-10-23 03:41:16 -0700853
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854 if (session->vhtCapability &&
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800855 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800856 session->nss = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700857 pe_debug("nss set to [%d]", session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700859 pe_debug("vht su tx bformer %d",
Krunal Soni53993f72016-07-08 18:20:03 -0700860 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800861
862 /* Delete pre-auth list if any */
863 lim_delete_pre_auth_list(mac_ctx);
864
865 /*
866 * keep the RSN/WPA IE information in PE Session Entry
867 * later will be using this to check when received (Re)Assoc req
868 */
869 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
870 &sme_start_bss_req->rsnIE, session);
871
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700872 if (LIM_IS_AP_ROLE(session) ||
873 LIM_IS_IBSS_ROLE(session) ||
874 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800875 session->gLimProtectionControl =
876 sme_start_bss_req->protEnabled;
877 /*
878 * each byte will have the following info
879 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
880 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
881 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530882 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800883 (void *)&sme_start_bss_req->ht_capab,
884 sizeof(uint16_t));
885 /* Initialize WPS PBC session link list */
886 session->pAPWPSPBCSession = NULL;
887 }
888 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530889 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700890 if (!mlm_start_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800891 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
892 goto free;
893 }
894
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800895 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530896 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800897 (uint8_t *) &sme_start_bss_req->ssId,
898 sme_start_bss_req->ssId.length + 1);
899 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
900 mlm_start_req->obssProtEnabled =
901 sme_start_bss_req->obssProtEnabled;
902
903 mlm_start_req->bssType = session->bssType;
904
905 /* Fill PE session Id from the session Table */
906 mlm_start_req->sessionId = session->peSessionId;
907
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700908 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
909 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800910 /*
911 * Copy the BSSId from sessionTable to
912 * mlmStartReq struct
913 */
914 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
915 } else {
916 /* ibss mode */
917 mac_ctx->lim.gLimIbssCoalescingHappened = false;
918
919 ret_status = wlan_cfg_get_int(mac_ctx,
920 WNI_CFG_IBSS_AUTO_BSSID,
921 &auto_gen_bssid);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700922 if (ret_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700923 pe_err("Get Auto Gen BSSID fail,Status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800924 ret_status);
Abhishek Singh4294f802017-08-10 16:37:07 +0530925 ret_code = eSIR_LOGE_EXCEPTION;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800926 goto free;
927 }
928
929 if (!auto_gen_bssid) {
930 /*
931 * We're not auto generating BSSID.
932 * Instead, get it from session entry
933 */
934 sir_copy_mac_addr(mlm_start_req->bssId,
935 session->bssId);
936 /*
937 * Start IBSS group BSSID
938 * Auto Generating BSSID.
939 */
940 auto_gen_bssid = ((mlm_start_req->bssId[0] &
941 0x01) ? true : false);
942 }
943
944 if (auto_gen_bssid) {
945 /*
946 * if BSSID is not any uc id.
947 * then use locally generated BSSID.
948 * Autogenerate the BSSID
949 */
950 lim_get_random_bssid(mac_ctx,
951 mlm_start_req->bssId);
952 mlm_start_req->bssId[0] = 0x02;
953
954 /*
955 * Copy randomly generated BSSID
956 * to the session Table
957 */
958 sir_copy_mac_addr(session->bssId,
959 mlm_start_req->bssId);
960 }
961 }
962 /* store the channel num in mlmstart req structure */
963 mlm_start_req->channelNumber = session->currentOperChannel;
964 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
965 mlm_start_req->beaconPeriod =
966 session->beaconParams.beaconInterval;
Arif Hussain671a1902017-03-17 09:08:32 -0700967 mlm_start_req->cac_duration_ms =
968 sme_start_bss_req->cac_duration_ms;
969 mlm_start_req->dfs_regdomain =
970 sme_start_bss_req->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800971 if (LIM_IS_AP_ROLE(session)) {
972 mlm_start_req->dtimPeriod = session->dtimPeriod;
973 mlm_start_req->wps_state = session->wps_state;
974
975 } else {
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530976 val = mac_ctx->mlme_cfg->sap_cfg.dtim_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800977 mlm_start_req->dtimPeriod = (uint8_t) val;
978 }
979
Karthik Kantamneni22dd0f62018-08-07 14:53:50 +0530980 mlm_start_req->cfParamSet.cfpPeriod =
981 mac_ctx->mlme_cfg->rates.cfp_period;
982 mlm_start_req->cfParamSet.cfpMaxDuration =
983 mac_ctx->mlme_cfg->rates.cfp_max_duration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800984
985 /*
986 * this may not be needed anymore now,
987 * as rateSet is now included in the
988 * session entry and MLM has session context.
989 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530990 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800991 (void *)&session->rateSet,
992 sizeof(tSirMacRateSet));
993
994 /* Now populate the 11n related parameters */
995 mlm_start_req->nwType = session->nwType;
996 mlm_start_req->htCapable = session->htCapability;
997
998 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
999 /* Unused */
1000 mlm_start_req->dualCTSProtection =
1001 mac_ctx->lim.gHTDualCTSProtection;
1002 mlm_start_req->txChannelWidthSet =
1003 session->htRecommendedTxWidthSet;
1004
1005 session->limRFBand = lim_get_rf_band(channel_number);
1006
1007 /* Initialize 11h Enable Flag */
1008 session->lim11hEnable = 0;
gaolez76d2a162017-03-21 19:23:58 +08001009 if (mlm_start_req->bssType != eSIR_IBSS_MODE &&
1010 (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001011 BAND_5G == session->limRFBand)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012 if (wlan_cfg_get_int(mac_ctx,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001013 WNI_CFG_11H_ENABLED, &val) != QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001014 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001015 else
1016 session->lim11hEnable = val;
1017
1018 if (session->lim11hEnable &&
1019 (eSIR_INFRA_AP_MODE ==
1020 mlm_start_req->bssType)) {
Arif Hussain88d1fdd2018-09-26 16:12:24 -07001021 session->lim11hEnable =
1022 mac_ctx->mlme_cfg->
1023 dfs_cfg.dfs_master_capable;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001024 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001025 }
1026
1027 if (!session->lim11hEnable) {
1028 if (cfg_set_int(mac_ctx,
1029 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001030 QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001031 /*
1032 * Failed to set the CFG param
1033 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1034 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001035 pe_err("Set LOCAL_POWER_CONSTRAINT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001036 }
1037
Jiachao Wu712d4fd2017-08-23 16:52:34 +08001038 mlm_start_req->beacon_tx_rate = session->beacon_tx_rate;
1039
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 session->limPrevSmeState = session->limSmeState;
1041 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1042 MTRACE(mac_trace
1043 (mac_ctx, TRACE_CODE_SME_STATE,
1044 session->peSessionId,
1045 session->limSmeState));
1046
Abhishek Singhdfa69c32018-08-30 15:39:34 +05301047 qdf_status = lim_send_start_vdev_req(session, mlm_start_req);
1048 if (QDF_IS_STATUS_ERROR(qdf_status))
1049 goto free;
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05301050 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051 return;
1052 } else {
1053
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001054 pe_err("Received unexpected START_BSS_REQ, in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055 mac_ctx->lim.gLimSmeState);
1056 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001057 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001058 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1059
1060free:
1061 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001062 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063 session->pLimStartBssReq = NULL;
1064 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001065 if (NULL != sme_start_bss_req)
1066 qdf_mem_free(sme_start_bss_req);
1067 if (NULL != mlm_start_req)
1068 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001069 if (NULL != session) {
1070 pe_delete_session(mac_ctx, session);
1071 session = NULL;
1072 }
1073 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1074 session, sme_session_id, sme_transaction_id);
1075}
1076
1077/**
1078 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1079 *
1080 * @pMac: Global MAC context
1081 * @pMsg: Message pointer
1082 *
1083 * Wrapper for the function __lim_handle_sme_start_bss_request
1084 * This message will be defered until softmac come out of
1085 * scan mode or if we have detected radar on the current
1086 * operating channel.
1087 *
1088 * return true - If we consumed the buffer
1089 * false - If have defered the message.
1090 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001091static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1092 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001093{
1094 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1095 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1096 /**
1097 * If message defered, buffer is not consumed yet.
1098 * So return false
1099 */
1100 return false;
1101 }
1102
1103 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1104 return true;
1105}
1106
1107/**
1108 * lim_get_random_bssid()
1109 *
1110 * FUNCTION:This function is called to process generate the random number for bssid
1111 * This function is called to process SME_SCAN_REQ message
1112 * from HDD or upper layer application.
1113 *
1114 * LOGIC:
1115 *
1116 * ASSUMPTIONS:
1117 *
1118 * NOTE:
1119 * 1. geneartes the unique random number for bssid in ibss
1120 *
1121 * @param pMac Pointer to Global MAC structure
1122 * @param *data Pointer to bssid buffer
1123 * @return None
1124 */
1125void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1126{
1127 uint32_t random[2];
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001128
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001129 random[0] = tx_time_get();
1130 random[0] |= (random[0] << 15);
1131 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301132 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001133}
1134
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001135/**
1136 * __lim_process_clear_dfs_channel_list()
1137 *
1138 ***FUNCTION:
Jeff Johnsonc00ae5b2018-05-06 16:06:35 -07001139 ***Clear DFS channel list when country is changed/acquired.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001140 .*This message is sent from SME.
1141 *
1142 ***LOGIC:
1143 *
1144 ***ASSUMPTIONS:
1145 *
1146 ***NOTE:
1147 *
1148 * @param pMac Pointer to Global MAC structure
1149 * @param *pMsgBuf A pointer to the SME message buffer
1150 * @return None
1151 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001152static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1153 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001154{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301155 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001156}
1157
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301158#ifdef WLAN_FEATURE_SAE
1159
1160/**
1161 * lim_update_sae_config()- This API update SAE session info to csr config
1162 * from join request.
1163 * @session: PE session
1164 * @sme_join_req: pointer to join request
1165 *
1166 * Return: None
1167 */
1168static void lim_update_sae_config(tpPESession session,
1169 tpSirSmeJoinReq sme_join_req)
1170{
1171 session->sae_pmk_cached = sme_join_req->sae_pmk_cached;
1172
1173 pe_debug("pmk_cached %d for BSSID=" MAC_ADDRESS_STR,
1174 session->sae_pmk_cached,
1175 MAC_ADDR_ARRAY(sme_join_req->bssDescription.bssId));
1176}
1177#else
1178static inline void lim_update_sae_config(tpPESession session,
1179 tpSirSmeJoinReq sme_join_req)
1180{}
1181#endif
1182
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001183/**
Jianmin Zhu09236602018-10-15 15:36:10 +08001184 * lim_send_join_req() - send vdev start request for assoc
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001185 *@session: pe session
1186 *@mlm_join_req: join req
1187 *
1188 * Return: QDF_STATUS
1189 */
1190
1191#ifdef CONFIG_VDEV_SM
1192static QDF_STATUS lim_send_join_req(tpPESession session,
1193 tLimMlmJoinReq *mlm_join_req)
1194{
Abhishek Singh254d5512018-10-30 12:17:05 +05301195 QDF_STATUS status;
1196
1197 status = mlme_set_assoc_type(session->vdev, VDEV_ASSOC);
1198 if (QDF_IS_STATUS_ERROR(status))
1199 return status;
1200
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001201 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
1202 WLAN_VDEV_SM_EV_START,
1203 sizeof(*mlm_join_req),
1204 mlm_join_req);
1205}
1206#else
1207static QDF_STATUS lim_send_join_req(tpPESession session,
1208 tLimMlmJoinReq *mlm_join_req)
1209{
1210 lim_process_mlm_join_req(session->mac_ctx, mlm_join_req);
1211
1212 return QDF_STATUS_SUCCESS;
1213}
1214#endif
1215
Jianmin Zhu09236602018-10-15 15:36:10 +08001216/**
1217 * lim_send_reassoc_req() - send vdev start request for reassoc
1218 *@session: pe session
1219 *@mlm_join_req: join req
1220 *
1221 * Return: QDF_STATUS
1222 */
1223
1224#ifdef CONFIG_VDEV_SM
1225static QDF_STATUS lim_send_reassoc_req(tpPESession session,
1226 tLimMlmReassocReq *reassoc_req)
1227{
Abhishek Singh254d5512018-10-30 12:17:05 +05301228 QDF_STATUS status;
1229
1230 status = mlme_set_assoc_type(session->vdev, VDEV_REASSOC);
1231 if (QDF_IS_STATUS_ERROR(status))
1232 return status;
1233
Jianmin Zhu09236602018-10-15 15:36:10 +08001234 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
1235 WLAN_VDEV_SM_EV_START,
1236 sizeof(*reassoc_req),
1237 reassoc_req);
1238}
1239#else
1240static QDF_STATUS lim_send_reassoc_req(tpPESession session,
1241 tLimMlmReassocReq *reassoc_req)
1242{
1243 lim_process_mlm_reassoc_req(session->mac_ctx, reassoc_req);
1244
1245 return QDF_STATUS_SUCCESS;
1246}
1247#endif
1248
1249/**
1250 * lim_send_ft_reassoc_req() - send vdev start request for ft_reassoc
1251 *@session: pe session
1252 *@mlm_join_req: join req
1253 *
1254 * Return: QDF_STATUS
1255 */
1256
1257#ifdef CONFIG_VDEV_SM
Abhishek Singh254d5512018-10-30 12:17:05 +05301258static QDF_STATUS lim_send_ft_reassoc_req(tpPESession session,
1259 tLimMlmReassocReq *reassoc_req)
Jianmin Zhu09236602018-10-15 15:36:10 +08001260{
Abhishek Singh254d5512018-10-30 12:17:05 +05301261 QDF_STATUS status;
1262
1263 status = mlme_set_assoc_type(session->vdev, VDEV_FT_REASSOC);
1264 if (QDF_IS_STATUS_ERROR(status))
1265 return status;
1266
Jianmin Zhu09236602018-10-15 15:36:10 +08001267 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
1268 WLAN_VDEV_SM_EV_START,
Abhishek Singh254d5512018-10-30 12:17:05 +05301269 sizeof(*reassoc_req),
1270 reassoc_req);
Jianmin Zhu09236602018-10-15 15:36:10 +08001271}
1272#else
Abhishek Singh254d5512018-10-30 12:17:05 +05301273static QDF_STATUS lim_send_ft_reassoc_req(tpPESession session,
1274 tLimMlmReassocReq *reassoc_req)
Jianmin Zhu09236602018-10-15 15:36:10 +08001275{
Abhishek Singh254d5512018-10-30 12:17:05 +05301276 lim_process_mlm_ft_reassoc_req(session->mac_ctx, reassoc_req);
Jianmin Zhu09236602018-10-15 15:36:10 +08001277
1278 return QDF_STATUS_SUCCESS;
1279}
1280#endif
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301281
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001282/**
1283 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1284 * @mac_ctx: Pointer to Global MAC structure
1285 * @msg_buf: A pointer to the SME message buffer
1286 *
1287 * This function is called to process SME_JOIN_REQ message
1288 * from HDD or upper layer application.
1289 *
1290 * Return: None
1291 */
1292static void
1293__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1294{
1295 tpSirSmeJoinReq sme_join_req = NULL;
1296 tLimMlmJoinReq *mlm_join_req;
1297 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1298 uint32_t val = 0;
1299 uint16_t n_size;
1300 uint8_t session_id;
1301 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301302 uint8_t sme_session_id = 0;
1303 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001304 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001305 uint16_t ie_len;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001306 const uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001307 tSirBssDescription *bss_desc;
Abhishek Singh254d5512018-10-30 12:17:05 +05301308 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001309
Arif Hussain995fcaf2016-07-18 11:28:22 -07001310 if (!mac_ctx || !msg_buf) {
1311 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1312 FL("JOIN REQ with invalid data"));
1313 return;
1314 }
1315
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001316/* FEATURE_WLAN_DIAG_SUPPORT */
1317#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1318 /*
1319 * Not sending any session, since it is not created yet.
1320 * The response whould have correct state.
1321 */
1322 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1323#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1324
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325 /*
1326 * Expect Join request in idle state.
1327 * Reassociate request is expected in link established state.
1328 */
1329
1330 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1331 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1332 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1333 msg_buf);
1334
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301335 sme_join_req = qdf_mem_malloc(n_size);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001336 if (!sme_join_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001337 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301338 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301340 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341 n_size);
1342
1343 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1344 /* Received invalid eWNI_SME_JOIN_REQ */
1345 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001346 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001347 sme_join_req->sessionId);
1348 ret_code = eSIR_SME_INVALID_PARAMETERS;
1349 goto end;
1350 }
1351
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001352 /*
1353 * Update the capability here itself as this is used in
1354 * lim_extract_ap_capability() below. If not updated issues
1355 * like not honoring power constraint on 1st association after
1356 * driver loading might occur.
1357 */
1358 lim_update_rrm_capability(mac_ctx, sme_join_req);
1359
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001360 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001361 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001362 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001363 &session_id);
1364
1365 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001366 pe_err("Session(%d) Already exists for BSSID: "
1367 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001368 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001369 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001370 session->limSmeState);
1371
1372 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1373 session->smeSessionId == sme_join_req->sessionId) {
1374 /*
1375 * Received eWNI_SME_JOIN_REQ for same
1376 * BSS as currently associated.
1377 * Log the event and send success
1378 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001379 pe_warn("SessionId: %d", session_id);
1380 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381 /* Send Join success response to host */
1382 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1383 session = NULL;
1384 goto end;
1385 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001386 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387 ret_code = eSIR_SME_REFUSED;
1388 session = NULL;
1389 goto end;
1390 }
1391 } else {
1392 /*
1393 * Session Entry does not exist for given BSSId
1394 * Try to Create a new session
1395 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001396 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001397 &session_id, mac_ctx->lim.maxStation,
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +05301398 eSIR_INFRASTRUCTURE_MODE,
1399 sme_join_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001400 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001401 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001402 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1403 goto end;
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301404 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001405 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001406 session_id);
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301407 }
1408
1409 /* Update the beacon/probe filter in mac_ctx */
1410 lim_set_bcn_probe_filter(mac_ctx, session,
1411 &sme_join_req->ssId,
1412 bss_desc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001413 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001414 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Arif Hussain6686c0b2018-08-21 18:21:05 -07001415 session->enable_session_twt_support =
1416 sme_join_req->enable_session_twt_support;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001417 /*
1418 * Store Session related parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001419 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001420
1421 /* store the smejoin req handle in session table */
1422 session->pLimJoinReq = sme_join_req;
1423
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001424 /* Store SME transaction Id in session Table */
1425 session->transactionId = sme_join_req->transactionId;
1426
1427 /* Store beaconInterval */
1428 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001429 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001430
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301431 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001432 sizeof(session->htConfig));
1433
Sandeep Puligilla98917432016-06-10 13:50:28 -07001434 qdf_mem_copy(&(session->vht_config),
1435 &(sme_join_req->vht_config),
1436 sizeof(session->vht_config));
1437
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001438 /* Copying of bssId is already done, while creating session */
1439 sir_copy_mac_addr(session->selfMacAddr,
1440 sme_join_req->selfMacAddr);
1441 session->bssType = sme_join_req->bsstype;
1442
1443 session->statypeForBss = STA_ENTRY_PEER;
1444 session->limWmeEnabled = sme_join_req->isWMEenabled;
1445 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301446 session->wps_registration = sme_join_req->wps_registration;
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001447 session->he_with_wep_tkip = sme_join_req->he_with_wep_tkip;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001448
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301449 session->enable_bcast_probe_rsp =
1450 sme_join_req->enable_bcast_probe_rsp;
1451
Jeff Johnson179fd8a2018-05-11 14:20:05 -07001452 /* Store vendor specific IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001453 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001454 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1455
Naveen Rawat08db88f2017-09-08 15:07:48 -07001456 vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001457 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001458 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001459
1460 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001461 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001462 session->isCiscoVendorAP = true;
1463 } else {
1464 session->isCiscoVendorAP = false;
1465 }
1466
1467 /* Copy the dot 11 mode in to the session table */
1468
1469 session->dot11mode = sme_join_req->dot11mode;
1470#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1471 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1472#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001473 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001474 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1475 session->enableHtSmps = sme_join_req->enableHtSmps;
1476 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001477 session->send_smps_action =
1478 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001479 /*
1480 * By default supported NSS 1x1 is set to true
1481 * and later on updated while determining session
1482 * supported rates which is the intersection of
1483 * self and peer rates
1484 */
1485 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301486 /*Store Persona */
1487 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001488 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 -08001489 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001490 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001491 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301492 session->supported_nss_1x1,
1493 session->pePersona,
1494 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001495
1496 /*Store Persona */
1497 session->pePersona = sme_join_req->staPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +05301498 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301499 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d force_24ghz_in_ht20 %d"),
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001500 session->pePersona, sme_join_req->cbMode,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301501 session->nwType, session->dot11mode,
1502 sme_join_req->force_24ghz_in_ht20);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001503
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001504 /* Copy The channel Id to the session Table */
1505 session->currentOperChannel = bss_desc->channelId;
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301506
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001507 session->vhtCapability =
1508 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001509 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301510 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001511 session->vht_config.su_beam_formee =
1512 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001513 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001514 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001515 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001516 session->enableVhtpAid =
1517 sme_join_req->enableVhtpAid;
1518 session->enableVhtGid =
1519 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001520 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001521 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001522 }
Krunal Soni53993f72016-07-08 18:20:03 -07001523
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001524 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301525 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001526 session->vht_config.su_beam_formee,
1527 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001528 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001529 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001530 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301532 session->force_24ghz_in_ht20 =
1533 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001534 /* cbMode is already merged value of peer and self -
1535 * done by csr in csr_get_cb_mode_from_ies */
1536 session->htSupportedChannelWidthSet =
1537 (sme_join_req->cbMode) ? 1 : 0;
1538 session->htRecommendedTxWidthSet =
1539 session->htSupportedChannelWidthSet;
1540 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1541
1542 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1543 session->ch_center_freq_seg0 =
1544 session->currentOperChannel - 2;
1545 session->ch_width = CH_WIDTH_40MHZ;
1546 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1547 sme_join_req->cbMode) {
1548 session->ch_center_freq_seg0 =
1549 session->currentOperChannel + 2;
1550 session->ch_width = CH_WIDTH_40MHZ;
1551 } else {
1552 session->ch_center_freq_seg0 = 0;
1553 session->ch_width = CH_WIDTH_20MHZ;
1554 }
1555
Naveen Rawataeca1b92017-10-16 16:55:31 -07001556 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1557 lim_update_session_he_capable(mac_ctx, session);
1558 lim_copy_join_req_he_cap(session, sme_join_req);
1559 }
1560
1561
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001562 /* Record if management frames need to be protected */
1563#ifdef WLAN_FEATURE_11W
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +05301564 if ((eSIR_ED_AES_128_CMAC ==
1565 sme_join_req->MgmtEncryptionType) ||
1566 (eSIR_ED_AES_GMAC_128 == sme_join_req->MgmtEncryptionType) ||
1567 (eSIR_ED_AES_GMAC_256 == sme_join_req->MgmtEncryptionType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001568 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001569 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001570 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001571#endif
1572
1573#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001574 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001575#endif
1576
1577 /* Copy the SSID from smejoinreq to session entry */
1578 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301579 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001580 session->ssId.length);
1581
1582 /*
1583 * Determin 11r or ESE connection based on input from SME
1584 * which inturn is dependent on the profile the user wants
1585 * to connect to, So input is coming from supplicant
1586 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001587 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001588#ifdef FEATURE_WLAN_ESE
1589 session->isESEconnection = sme_join_req->isESEconnection;
1590#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001591 session->isFastTransitionEnabled =
1592 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001593
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001594 session->isFastRoamIniFeatureEnabled =
1595 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001596 session->txLdpcIniFeatureEnabled =
1597 sme_join_req->txLdpcIniFeatureEnabled;
1598
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301599 lim_update_fils_config(session, sme_join_req);
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301600 lim_update_sae_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001601 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1602 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001603 } else {
1604 /*
1605 * Throw an error and return and make
1606 * sure to delete the session.
1607 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001608 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001609 session->bssType);
1610 ret_code = eSIR_SME_INVALID_PARAMETERS;
1611 goto end;
1612 }
1613
1614 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301615 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001616 &sme_join_req->addIEScan, sizeof(tSirAddie));
1617
1618 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301619 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001620 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1621
1622 val = sizeof(tLimMlmJoinReq) +
1623 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301624 mlm_join_req = qdf_mem_malloc(val);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001625 if (!mlm_join_req) {
Nitesh Shah0102cac2016-07-13 14:38:30 +05301626 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1627 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001628 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001629
1630 /* PE SessionId is stored as a part of JoinReq */
1631 mlm_join_req->sessionId = session->peSessionId;
1632
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001633 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301634 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001635 (void *)&sme_join_req->operationalRateSet,
1636 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301637 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001638 (void *)&sme_join_req->extendedRateSet,
1639 sizeof(tSirMacRateSet));
1640 /*
1641 * this may not be needed anymore now, as rateSet is now
1642 * included in the session entry and MLM has session context.
1643 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301644 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001645 (void *)&session->rateSet,
1646 sizeof(tSirMacRateSet));
1647
1648 session->encryptType = sme_join_req->UCEncryptionType;
1649
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301650 session->supported_nss_1x1 = sme_join_req->supported_nss_1x1;
1651 session->vdev_nss = sme_join_req->vdev_nss;
1652 session->nss = sme_join_req->nss;
1653 session->nss_forced_1x1 = sme_join_req->nss_forced_1x1;
1654
1655 pe_debug("nss %d, vdev_nss %d, supported_nss_1x1 %d",
1656 session->nss,
1657 session->vdev_nss,
1658 session->supported_nss_1x1);
1659
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001660 mlm_join_req->bssDescription.length =
1661 session->pLimJoinReq->bssDescription.length;
1662
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301663 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001664 (uint8_t *)
1665 &session->pLimJoinReq->bssDescription.bssId,
1666 session->pLimJoinReq->bssDescription.length + 2);
1667
1668 session->limCurrentBssCaps =
1669 session->pLimJoinReq->bssDescription.capabilityInfo;
1670
1671 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1672 session->currentOperChannel);
1673 local_power_constraint = reg_max;
1674
1675 lim_extract_ap_capability(mac_ctx,
1676 (uint8_t *)
1677 session->pLimJoinReq->bssDescription.ieFields,
1678 lim_get_ielen_from_bss_description(
1679 &session->pLimJoinReq->bssDescription),
1680 &session->limCurrentBssQosCaps,
1681 &session->limCurrentBssPropCap,
1682 &session->gLimCurrentBssUapsd,
1683 &local_power_constraint, session);
1684
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001685 session->maxTxPower = lim_get_max_tx_power(reg_max,
1686 local_power_constraint,
1687 mac_ctx->roam.configParam.nTxPowerCap);
Abhinav Kumard528d192018-03-09 17:31:12 +05301688 session->def_max_tx_pwr = session->maxTxPower;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301689
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001690 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301691 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301693 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1694 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1695 pe_debug("Update MaxTxPower in join Req to %d",
1696 sme_join_req->powerCap.maxTxPower);
1697 }
1698
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001699 if (session->gLimCurrentBssUapsd) {
1700 session->gUapsdPerAcBitmask =
1701 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001702 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001703 session->gUapsdPerAcBitmask);
1704
1705 /* resetting the dynamic uapsd mask */
1706 session->gUapsdPerAcDeliveryEnableMask = 0;
1707 session->gUapsdPerAcTriggerEnableMask = 0;
1708 }
1709
1710 session->limRFBand =
1711 lim_get_rf_band(session->currentOperChannel);
1712
1713 /* Initialize 11h Enable Flag */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001714 if (BAND_5G == session->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001715 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001716 &val) != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001717 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718 session->lim11hEnable =
1719 WNI_CFG_11H_ENABLED_STADEF;
1720 } else {
1721 session->lim11hEnable = val;
1722 }
1723 } else {
1724 session->lim11hEnable = 0;
1725 }
1726
1727 /*
1728 * To care of the scenario when STA transitions from
1729 * IBSS to Infrastructure mode.
1730 */
1731 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1732
1733 session->limPrevSmeState = session->limSmeState;
1734 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1735 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1736 session->peSessionId,
1737 session->limSmeState));
1738
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001739 /* Indicate whether spectrum management is enabled */
1740 session->spectrumMgtEnabled =
1741 sme_join_req->spectrumMgtIndicator;
1742
1743 /* Enable the spectrum management if this is a DFS channel */
1744 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001745 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001746 session->currentOperChannel))
1747 session->spectrumMgtEnabled = true;
1748
1749 session->isOSENConnection = sme_join_req->isOSENConnection;
1750
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001751 /* Issue LIM_MLM_JOIN_REQ to MLM */
Abhishek Singh254d5512018-10-30 12:17:05 +05301752 status = lim_send_join_req(session, mlm_join_req);
1753 if (QDF_IS_STATUS_ERROR(status)) {
1754 qdf_mem_free(mlm_join_req);
1755 ret_code = eSIR_SME_REFUSED;
1756 goto end;
1757 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758 return;
1759
1760 } else {
1761 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001762 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001763 mac_ctx->lim.gLimSmeState);
1764 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1765 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1766 session = NULL;
1767 goto end;
1768 }
1769
1770end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301771 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1772 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001773
1774 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301775 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001776 sme_join_req = NULL;
1777 if (NULL != session)
1778 session->pLimJoinReq = NULL;
1779 }
1780 if (ret_code != eSIR_SME_SUCCESS) {
1781 if (NULL != session) {
1782 pe_delete_session(mac_ctx, session);
1783 session = NULL;
1784 }
1785 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001786 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787 sme_session_id, ret_code);
1788 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1789 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1790 sme_transaction_id);
1791}
1792
Amar Singhala297bfa2015-10-15 15:07:29 -07001793uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001794 uint8_t iniTxPower)
1795{
1796 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301797 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001798
Anurag Chouhan6d760662016-02-20 16:05:43 +05301799 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001800 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1801 maxTxPower = txPower;
1802 else if (txPower < MIN_TX_PWR_CAP)
1803 maxTxPower = MIN_TX_PWR_CAP;
1804 else
1805 maxTxPower = MAX_TX_PWR_CAP;
1806
1807 return maxTxPower;
1808}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809
1810/**
1811 * __lim_process_sme_reassoc_req() - process reassoc req
1812 *
1813 * @mac_ctx: Pointer to Global MAC structure
1814 * @msg_buf: pointer to the SME message buffer
1815 *
1816 * This function is called to process SME_REASSOC_REQ message
1817 * from HDD or upper layer application.
1818 *
1819 * Return: None
1820 */
1821
1822static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
1823 uint32_t *msg_buf)
1824{
1825 uint16_t caps;
1826 uint32_t val;
1827 tpSirSmeJoinReq reassoc_req = NULL;
1828 tLimMlmReassocReq *mlm_reassoc_req;
1829 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1830 tpPESession session_entry = NULL;
1831 uint8_t session_id;
1832 uint8_t sme_session_id;
1833 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001834 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001835 uint32_t tele_bcn_en = 0;
1836 uint16_t size;
Abhishek Singh254d5512018-10-30 12:17:05 +05301837 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001838
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001839 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301840 reassoc_req = qdf_mem_malloc(size);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001841 if (!reassoc_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001842 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1843 goto end;
1844 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301845 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001846
1847 if (!lim_is_sme_join_req_valid(mac_ctx,
1848 (tpSirSmeJoinReq)reassoc_req)) {
1849 /*
1850 * Received invalid eWNI_SME_REASSOC_REQ
1851 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001852 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853
1854 ret_code = eSIR_SME_INVALID_PARAMETERS;
1855 goto end;
1856 }
Jianmin Zhu09236602018-10-15 15:36:10 +08001857 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
1858 &sme_session_id, &transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001859
1860 session_entry = pe_find_session_by_bssid(mac_ctx,
1861 reassoc_req->bssDescription.bssId,
1862 &session_id);
1863 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001864 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001865 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
1866 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001867 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001868 session_entry =
1869 pe_find_session_by_sme_session_id(mac_ctx,
1870 sme_session_id);
1871 if (session_entry != NULL)
1872 lim_handle_sme_join_result(mac_ctx,
1873 eSIR_SME_INVALID_PARAMETERS,
1874 eSIR_MAC_UNSPEC_FAILURE_STATUS,
1875 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001876 goto end;
1877 }
1878#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
1879 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001880 session_entry, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001881#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1882 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
1883
1884 /* Store the reassoc handle in the session Table */
1885 session_entry->pLimReAssocReq = reassoc_req;
1886
1887 session_entry->dot11mode = reassoc_req->dot11mode;
1888 session_entry->vhtCapability =
1889 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001890
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301891 if (session_entry->vhtCapability) {
1892 if (session_entry->pePersona == QDF_STA_MODE) {
1893 session_entry->vht_config.su_beam_formee =
1894 reassoc_req->vht_config.su_beam_formee;
1895 } else {
1896 reassoc_req->vht_config.su_beam_formee = 0;
1897 }
1898 session_entry->enableVhtpAid =
1899 reassoc_req->enableVhtpAid;
1900 session_entry->enableVhtGid =
1901 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001902 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301903 }
1904
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301905 session_entry->supported_nss_1x1 = reassoc_req->supported_nss_1x1;
1906 session_entry->vdev_nss = reassoc_req->vdev_nss;
1907 session_entry->nss = reassoc_req->nss;
1908 session_entry->nss_forced_1x1 = reassoc_req->nss_forced_1x1;
1909
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001910 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301911 session_entry->vhtCapability,
1912 session_entry->vht_config.su_beam_formee,
1913 session_entry->vht_config.su_beam_former);
1914
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001915 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
1916 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001917 session_entry->send_smps_action =
1918 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001919 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001920 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001921 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001922 session_entry->send_smps_action,
1923 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001924 /*
1925 * Reassociate request is expected
1926 * in link established state only.
1927 */
1928
1929 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001930 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
1931 /*
1932 * May be from 11r FT pre-auth. So lets check it
1933 * before we bail out
1934 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001935 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001936 session_entry->peSessionId);
1937
1938 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301939 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001940 session_entry->limReAssocbssId,
1941 6)) {
1942 lim_print_mac_addr(mac_ctx,
1943 reassoc_req->bssDescription.
1944 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001945 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001946 ret_code = eSIR_SME_INVALID_PARAMETERS;
1947 goto end;
1948 }
1949
Jianmin Zhu09236602018-10-15 15:36:10 +08001950 session_entry->smeSessionId = sme_session_id;
1951 session_entry->transactionId = transaction_id;
Abhishek Singh254d5512018-10-30 12:17:05 +05301952 mlm_reassoc_req =
1953 qdf_mem_malloc(sizeof(*mlm_reassoc_req));
1954 if (!mlm_reassoc_req) {
1955 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1956 goto end;
1957 }
1958
1959 /* Update PE sessionId */
1960 mlm_reassoc_req->sessionId = session_entry->peSessionId;
1961 status = lim_send_ft_reassoc_req(session_entry,
1962 mlm_reassoc_req);
1963 if (QDF_IS_STATUS_ERROR(status)) {
1964 qdf_mem_free(mlm_reassoc_req);
1965 ret_code = eSIR_SME_REFUSED;
1966 goto end;
1967 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001968 return;
1969 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970 /*
1971 * Should not have received eWNI_SME_REASSOC_REQ
1972 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001973 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001974 session_entry->limSmeState);
1975 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
1976
1977 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1978 goto end;
1979 }
1980
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301981 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001982 session_entry->pLimReAssocReq->bssDescription.bssId,
1983 sizeof(tSirMacAddr));
1984
1985 session_entry->limReassocChannelId =
1986 session_entry->pLimReAssocReq->bssDescription.channelId;
1987
1988 session_entry->reAssocHtSupportedChannelWidthSet =
1989 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
1990 session_entry->reAssocHtRecommendedTxWidthSet =
1991 session_entry->reAssocHtSupportedChannelWidthSet;
1992 session_entry->reAssocHtSecondaryChannelOffset =
1993 session_entry->pLimReAssocReq->cbMode;
1994
1995 session_entry->limReassocBssCaps =
1996 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
1997 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1998 session_entry->currentOperChannel);
1999 local_pwr_constraint = reg_max;
2000
2001 lim_extract_ap_capability(mac_ctx,
2002 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2003 lim_get_ielen_from_bss_description(
2004 &session_entry->pLimReAssocReq->bssDescription),
2005 &session_entry->limReassocBssQosCaps,
2006 &session_entry->limReassocBssPropCap,
2007 &session_entry->gLimCurrentBssUapsd,
2008 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302009 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002010 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302011 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002012 /* Copy the SSID from session entry to local variable */
2013 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302014 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002015 reassoc_req->ssId.ssId,
2016 session_entry->limReassocSSID.length);
2017 if (session_entry->gLimCurrentBssUapsd) {
2018 session_entry->gUapsdPerAcBitmask =
2019 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002020 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002021 session_entry->gUapsdPerAcBitmask);
2022 }
2023
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302024 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002025 if (!mlm_reassoc_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002026 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2027 goto end;
2028 }
2029
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302030 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2032
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002033 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002034 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002035 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302036
2037 lim_update_caps_info_for_bss(mac_ctx, &caps,
2038 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002039 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302040
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002041 mlm_reassoc_req->capabilityInfo = caps;
2042
2043 /* Update PE session_id */
2044 mlm_reassoc_req->sessionId = session_id;
2045
2046 /*
2047 * If telescopic beaconing is enabled, set listen interval to
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05302048 * CFG_TELE_BCN_MAX_LI
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002049 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002050
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05302051 tele_bcn_en = mac_ctx->mlme_cfg->sap_cfg.tele_bcn_wakeup_en;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002052
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05302053 if (tele_bcn_en)
2054 val = mac_ctx->mlme_cfg->sap_cfg.tele_bcn_max_li;
2055 else
2056 val = mac_ctx->mlme_cfg->sap_cfg.listen_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002057
2058 mlm_reassoc_req->listenInterval = (uint16_t) val;
2059
2060 /* Indicate whether spectrum management is enabled */
2061 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2062
2063 /* Enable the spectrum management if this is a DFS channel */
2064 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002065 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002066 session_entry->currentOperChannel))
2067 session_entry->spectrumMgtEnabled = true;
2068
2069 session_entry->limPrevSmeState = session_entry->limSmeState;
2070 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2071
2072 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2073 session_entry->peSessionId,
2074 session_entry->limSmeState));
2075
Abhishek Singh254d5512018-10-30 12:17:05 +05302076 status = lim_send_reassoc_req(session_entry, mlm_reassoc_req);
2077 if (QDF_IS_STATUS_ERROR(status)) {
2078 qdf_mem_free(mlm_reassoc_req);
2079 ret_code = eSIR_SME_REFUSED;
2080 goto end;
2081 }
Jianmin Zhu09236602018-10-15 15:36:10 +08002082
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002083 return;
2084end:
2085 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302086 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002087 if (session_entry)
2088 session_entry->pLimReAssocReq = NULL;
2089 }
2090
2091 if (session_entry) {
2092 /*
2093 * error occurred after we determined the session so extract
2094 * session and transaction info from there
2095 */
2096 sme_session_id = session_entry->smeSessionId;
2097 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002098 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002099 /*
2100 * error occurred before or during the time we determined
2101 * the session so extract the session and transaction info
2102 * from the message
2103 */
2104 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2105 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002106 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002107 /*
2108 * Send Reassoc failure response to host
2109 * (note session_entry may be NULL, but that's OK)
2110 */
2111 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2112 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2113 session_entry, sme_session_id,
2114 transaction_id);
2115}
2116
2117bool send_disassoc_frame = 1;
2118/**
2119 * __lim_process_sme_disassoc_req()
2120 *
2121 ***FUNCTION:
2122 * This function is called to process SME_DISASSOC_REQ message
2123 * from HDD or upper layer application.
2124 *
2125 ***LOGIC:
2126 *
2127 ***ASSUMPTIONS:
2128 *
2129 ***NOTE:
2130 *
2131 * @param pMac Pointer to Global MAC structure
2132 * @param *pMsgBuf A pointer to the SME message buffer
2133 * @return None
2134 */
2135
2136static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2137{
2138 uint16_t disassocTrigger, reasonCode;
2139 tLimMlmDisassocReq *pMlmDisassocReq;
2140 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2141 tSirSmeDisassocReq smeDisassocReq;
2142 tpPESession psessionEntry = NULL;
2143 uint8_t sessionId;
2144 uint8_t smesessionId;
2145 uint16_t smetransactionId;
2146
2147 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002148 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149 return;
2150 }
2151
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302152 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002153 smesessionId = smeDisassocReq.sessionId;
2154 smetransactionId = smeDisassocReq.transactionId;
2155 if (!lim_is_sme_disassoc_req_valid(pMac,
2156 &smeDisassocReq,
2157 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002158 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002159 if (pMac->lim.gLimRspReqd) {
2160 pMac->lim.gLimRspReqd = false;
2161
2162 retCode = eSIR_SME_INVALID_PARAMETERS;
2163 disassocTrigger = eLIM_HOST_DISASSOC;
2164 goto sendDisassoc;
2165 }
2166
2167 return;
2168 }
2169
2170 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002171 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002172 &sessionId);
2173 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002174 pe_err("session does not exist for given bssId "
2175 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002176 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002177 retCode = eSIR_SME_INVALID_PARAMETERS;
2178 disassocTrigger = eLIM_HOST_DISASSOC;
2179 goto sendDisassoc;
2180 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002181 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2182 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002183 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2184 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002185 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002186
2187#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2188 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2189 0, smeDisassocReq.reasonCode);
2190#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2191
2192 /* Update SME session Id and SME transaction ID */
2193
2194 psessionEntry->smeSessionId = smesessionId;
2195 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002196 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002197 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002198
2199 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2200 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002201 switch (psessionEntry->limSmeState) {
2202 case eLIM_SME_ASSOCIATED_STATE:
2203 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002204 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002205 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002206 psessionEntry->limPrevSmeState =
2207 psessionEntry->limSmeState;
2208 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002209 /* Delete all TDLS peers connected before leaving BSS */
2210 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002211 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2212 psessionEntry->peSessionId,
2213 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002214 break;
2215
2216 case eLIM_SME_WT_DEAUTH_STATE:
2217 /* PE shall still process the DISASSOC_REQ and proceed with
2218 * link tear down even if it had already sent a DEAUTH_IND to
2219 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2220 * its been set when PE entered WT_DEAUTH_STATE.
2221 */
2222 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2223 MTRACE(mac_trace
2224 (pMac, TRACE_CODE_SME_STATE,
2225 psessionEntry->peSessionId,
2226 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002227 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002228 break;
2229
2230 case eLIM_SME_WT_DISASSOC_STATE:
Jeff Johnson47d75242018-05-12 15:58:53 -07002231 /* PE Received a Disassoc frame. Normally it gets DISASSOC_CNF but it
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002232 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2233 * PE can continue processing DISASSOC_REQ and send the response instead
2234 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2235 * for disassoc frame.
2236 *
2237 * It will send a disassoc, which is ok. However, we can use the global flag
2238 * sendDisassoc to not send disassoc frame.
2239 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002240 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002241 break;
2242
2243 case eLIM_SME_JOIN_FAILURE_STATE: {
2244 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002245 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002246 if (pMac->lim.gLimRspReqd) {
2247 retCode = eSIR_SME_SUCCESS;
2248 disassocTrigger = eLIM_HOST_DISASSOC;
2249 goto sendDisassoc;
2250 }
2251 }
2252 break;
2253 default:
2254 /**
2255 * STA is not currently associated.
2256 * Log error and send response to host
2257 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002258 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002259 psessionEntry->limSmeState);
2260 lim_print_sme_state(pMac, LOGE,
2261 psessionEntry->limSmeState);
2262
2263 if (pMac->lim.gLimRspReqd) {
2264 if (psessionEntry->limSmeState !=
2265 eLIM_SME_WT_ASSOC_STATE)
2266 pMac->lim.gLimRspReqd = false;
2267
2268 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2269 disassocTrigger = eLIM_HOST_DISASSOC;
2270 goto sendDisassoc;
2271 }
2272
2273 return;
2274 }
2275
2276 break;
2277
2278 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002279 /* Fall through */
2280 break;
2281
2282 case eLIM_STA_IN_IBSS_ROLE:
2283 default:
2284 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002285 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002286 GET_LIM_SYSTEM_ROLE(psessionEntry));
2287
2288 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2289 disassocTrigger = eLIM_HOST_DISASSOC;
2290 goto sendDisassoc;
2291 } /* end switch (pMac->lim.gLimSystemRole) */
2292
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302293 disassocTrigger = eLIM_HOST_DISASSOC;
2294 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002295
2296 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002297 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002298 send_disassoc_frame = 0;
2299 }
2300 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002301 pe_debug("Sending Disasscoc with disassoc Trigger"
2302 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002303 disassocTrigger, reasonCode);
2304
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302305 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002306 if (!pMlmDisassocReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002307 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002308
Anurag Chouhanc5548422016-02-24 18:33:27 +05302309 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002310 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002311
2312 pMlmDisassocReq->reasonCode = reasonCode;
2313 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2314
2315 /* Update PE session ID */
2316 pMlmDisassocReq->sessionId = sessionId;
2317
2318 lim_post_mlm_message(pMac,
2319 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2320 return;
2321
2322sendDisassoc:
2323 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002324 lim_send_sme_disassoc_ntf(pMac,
2325 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002326 retCode,
2327 disassocTrigger,
2328 1, smesessionId, smetransactionId,
2329 psessionEntry);
2330 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002331 lim_send_sme_disassoc_ntf(pMac,
2332 smeDisassocReq.peer_macaddr.bytes,
2333 retCode, disassocTrigger, 1,
2334 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002335
2336} /*** end __lim_process_sme_disassoc_req() ***/
2337
2338/** -----------------------------------------------------------------
2339 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2340
2341 This function is called to process SME_DISASSOC_CNF message
2342 from HDD or upper layer application.
2343
2344 \param pMac - global mac structure
2345 \param pStaDs - station dph hash node
2346 \return none
2347 \sa
2348 ----------------------------------------------------------------- */
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002349void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002350{
2351 tSirSmeDisassocCnf smeDisassocCnf;
2352 uint16_t aid;
2353 tpDphHashNode pStaDs;
2354 tpPESession psessionEntry;
2355 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302356 uint32_t *msg = NULL;
2357 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002358
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302359 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002360 sizeof(struct sSirSmeDisassocCnf));
2361
2362 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002363 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002364 &sessionId);
2365 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002366 pe_err("session does not exist for given bssId");
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302367 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302368 smeDisassocCnf.sme_session_id,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302369 eSIR_SME_INVALID_SESSION,
2370 NULL);
2371 if (QDF_IS_STATUS_SUCCESS(status))
2372 lim_send_sme_disassoc_deauth_ntf(pMac,
2373 QDF_STATUS_SUCCESS,
2374 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002375 return;
2376 }
2377
2378 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002379 pe_err("received invalid SME_DISASSOC_CNF message");
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302380 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2381 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302382 eSIR_SME_INVALID_PARAMETERS,
2383 &smeDisassocCnf.bssid.bytes[0]);
2384 if (QDF_IS_STATUS_SUCCESS(status))
2385 lim_send_sme_disassoc_deauth_ntf(pMac,
2386 QDF_STATUS_SUCCESS,
2387 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002388 return;
2389 }
2390#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2391 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2392 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2393 psessionEntry,
2394 (uint16_t) smeDisassocCnf.statusCode, 0);
2395 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2396 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2397 psessionEntry,
2398 (uint16_t) smeDisassocCnf.statusCode, 0);
2399#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2400
2401 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2402 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002403 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2404 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2405 && (psessionEntry->limSmeState !=
2406 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002407 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 psessionEntry->limSmeState);
2409 lim_print_sme_state(pMac, LOGE,
2410 psessionEntry->limSmeState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302411 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302412 psessionEntry->smeSessionId,
2413 eSIR_SME_INVALID_STATE,
2414 &smeDisassocCnf.bssid.bytes[0]);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302415 if (QDF_IS_STATUS_SUCCESS(status))
2416 lim_send_sme_disassoc_deauth_ntf(pMac,
2417 QDF_STATUS_SUCCESS,
2418 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002419 return;
2420 }
2421 break;
2422
2423 case eLIM_AP_ROLE:
2424 /* Fall through */
2425 break;
2426
2427 case eLIM_STA_IN_IBSS_ROLE:
2428 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002429 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002430 GET_LIM_SYSTEM_ROLE(psessionEntry));
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302431 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2432 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302433 eSIR_SME_INVALID_STATE,
2434 &smeDisassocCnf.bssid.bytes[0]);
2435 if (QDF_IS_STATUS_SUCCESS(status))
2436 lim_send_sme_disassoc_deauth_ntf(pMac,
2437 QDF_STATUS_SUCCESS,
2438 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002439 return;
2440 }
2441
2442 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2443 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2444 LIM_IS_AP_ROLE(psessionEntry)) {
2445 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002446 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002447 &psessionEntry->dph.dphHashTable);
2448 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002449 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2450 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002451 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302452 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302453 psessionEntry->smeSessionId,
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05302454 eSIR_SME_INVALID_PARAMETERS,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302455 &smeDisassocCnf.bssid.bytes[0]);
2456 if (QDF_IS_STATUS_SUCCESS(status))
2457 lim_send_sme_disassoc_deauth_ntf(pMac,
2458 QDF_STATUS_SUCCESS,
2459 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002460 return;
2461 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302462
2463 if ((pStaDs->mlmStaContext.mlmState ==
2464 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2465 (pStaDs->mlmStaContext.mlmState ==
Arif Hussain5fa13782018-05-10 11:29:52 -07002466 eLIM_MLM_WT_DEL_BSS_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002467 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002468 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302469 pStaDs->mlmStaContext.mlmState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302470 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302471 psessionEntry->smeSessionId,
2472 eSIR_SME_SUCCESS,
2473 NULL);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302474 if (QDF_IS_STATUS_SUCCESS(status))
2475 lim_send_sme_disassoc_deauth_ntf(pMac,
2476 QDF_STATUS_SUCCESS,
2477 (uint32_t *)msg);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302478 return;
2479 }
2480
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002481 /* Delete FT session if there exists one */
2482 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002483 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2484
2485 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002486 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002487 }
2488
2489 return;
2490}
2491
2492/**
2493 * __lim_process_sme_deauth_req() - process sme deauth req
2494 * @mac_ctx: Pointer to Global MAC structure
2495 * @msg_buf: pointer to the SME message buffer
2496 *
2497 * This function is called to process SME_DEAUTH_REQ message
2498 * from HDD or upper layer application.
2499 *
2500 * Return: None
2501 */
2502
2503static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2504 uint32_t *msg_buf)
2505{
2506 uint16_t deauth_trigger, reason_code;
2507 tLimMlmDeauthReq *mlm_deauth_req;
2508 tSirSmeDeauthReq sme_deauth_req;
2509 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2510 tpPESession session_entry;
2511 uint8_t session_id; /* PE sessionId */
2512 uint8_t sme_session_id;
2513 uint16_t sme_transaction_id;
2514
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302515 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002516 sme_session_id = sme_deauth_req.sessionId;
2517 sme_transaction_id = sme_deauth_req.transactionId;
2518
2519 /*
2520 * We need to get a session first but we don't even know
2521 * if the message is correct.
2522 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002523 session_entry = pe_find_session_by_bssid(mac_ctx,
2524 sme_deauth_req.bssid.bytes,
2525 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002526 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002527 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002528 ret_code = eSIR_SME_INVALID_PARAMETERS;
2529 deauth_trigger = eLIM_HOST_DEAUTH;
2530 goto send_deauth;
2531 }
2532
2533 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2534 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002535 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002536 mac_ctx->lim.gLimRspReqd = false;
2537
2538 ret_code = eSIR_SME_INVALID_PARAMETERS;
2539 deauth_trigger = eLIM_HOST_DEAUTH;
2540 goto send_deauth;
2541 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002542 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2543 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002544 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2545 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002546 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002547#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2548 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2549 session_entry, 0, sme_deauth_req.reasonCode);
2550#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2551
2552 /* Update SME session ID and Transaction ID */
2553 session_entry->smeSessionId = sme_session_id;
2554 session_entry->transactionId = sme_transaction_id;
2555
2556 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2557 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002558 switch (session_entry->limSmeState) {
2559 case eLIM_SME_ASSOCIATED_STATE:
2560 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302561 /* Delete all TDLS peers connected before leaving BSS */
2562 lim_delete_tdls_peers(mac_ctx, session_entry);
Abhinav Kumarac12c762018-05-02 13:51:02 +05302563 /* fallthrough */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002564 case eLIM_SME_WT_ASSOC_STATE:
2565 case eLIM_SME_JOIN_FAILURE_STATE:
2566 case eLIM_SME_IDLE_STATE:
2567 session_entry->limPrevSmeState =
2568 session_entry->limSmeState;
2569 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2570 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2571 session_entry->peSessionId,
2572 session_entry->limSmeState));
2573 /* Send Deauthentication request to MLM below */
2574 break;
2575 case eLIM_SME_WT_DEAUTH_STATE:
2576 case eLIM_SME_WT_DISASSOC_STATE:
2577 /*
Jeff Johnson47d75242018-05-12 15:58:53 -07002578 * PE Received a Deauth/Disassoc frame. Normally it get
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002579 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2580 * Which means host is also trying to disconnect.
2581 * PE can continue processing DEAUTH_REQ and send
2582 * the response instead of failing the request.
2583 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2584 * was sent for deauth/disassoc frame.
2585 */
2586 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002587 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002588 break;
2589 default:
2590 /*
2591 * STA is not in a state to deauthenticate with
2592 * peer. Log error and send response to host.
2593 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002594 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002595 session_entry->limSmeState);
2596 lim_print_sme_state(mac_ctx, LOGE,
2597 session_entry->limSmeState);
2598
2599 if (mac_ctx->lim.gLimRspReqd) {
2600 mac_ctx->lim.gLimRspReqd = false;
2601
2602 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2603 deauth_trigger = eLIM_HOST_DEAUTH;
2604
wadesong42968e92017-06-08 14:11:21 +08002605 /*
2606 * here we received deauth request from AP so
2607 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2608 * have ISSUED delSta then mlm state should be
2609 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2610 * delBSS rsp then mlm state should be
2611 * eLIM_MLM_IDLE_STATE so the below condition
2612 * captures the state where delSta not done
2613 * and firmware still in connected state.
2614 */
2615 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002616 eLIM_SME_WT_DEAUTH_STATE &&
2617 session_entry->limMlmState !=
2618 eLIM_MLM_IDLE_STATE &&
2619 session_entry->limMlmState !=
2620 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002621 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002622 goto send_deauth;
2623 }
2624 return;
2625 }
2626 break;
2627
2628 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002629 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002630 if (mac_ctx->lim.gLimRspReqd) {
2631 mac_ctx->lim.gLimRspReqd = false;
2632 ret_code = eSIR_SME_INVALID_PARAMETERS;
2633 deauth_trigger = eLIM_HOST_DEAUTH;
2634 goto send_deauth;
2635 }
2636 return;
2637 case eLIM_AP_ROLE:
2638 break;
2639 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002640 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002641 GET_LIM_SYSTEM_ROLE(session_entry));
2642 if (mac_ctx->lim.gLimRspReqd) {
2643 mac_ctx->lim.gLimRspReqd = false;
2644 ret_code = eSIR_SME_INVALID_PARAMETERS;
2645 deauth_trigger = eLIM_HOST_DEAUTH;
2646 goto send_deauth;
2647 }
2648 return;
2649 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2650
Yu Ouyang57c25532018-09-07 17:14:01 +08002651 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH &&
2652 session_entry->limSystemRole == eLIM_STA_ROLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002653 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002654 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002655 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2656 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2657 } else {
2658 deauth_trigger = eLIM_HOST_DEAUTH;
2659 reason_code = sme_deauth_req.reasonCode;
2660 }
2661
2662 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302663 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002664 if (!mlm_deauth_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002665 if (mac_ctx->lim.gLimRspReqd) {
2666 mac_ctx->lim.gLimRspReqd = false;
2667 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2668 deauth_trigger = eLIM_HOST_DEAUTH;
2669 goto send_deauth;
2670 }
2671 return;
2672 }
2673
Anurag Chouhanc5548422016-02-24 18:33:27 +05302674 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002675 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002676
2677 mlm_deauth_req->reasonCode = reason_code;
2678 mlm_deauth_req->deauthTrigger = deauth_trigger;
2679
2680 /* Update PE session Id */
2681 mlm_deauth_req->sessionId = session_id;
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002682 lim_process_mlm_deauth_req(mac_ctx, (uint32_t *)mlm_deauth_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002683
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002684 return;
2685
2686send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002687 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2688 ret_code, deauth_trigger, 1,
2689 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002690}
2691
2692/**
2693 * __lim_process_sme_set_context_req()
2694 *
2695 * @mac_ctx: Pointer to Global MAC structure
2696 * @msg_buf: pointer to the SME message buffer
2697 *
2698 * This function is called to process SME_SETCONTEXT_REQ message
2699 * from HDD or upper layer application.
2700 *
2701 * Return: None
2702 */
2703
2704static void
2705__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2706{
2707 tpSirSmeSetContextReq set_context_req;
2708 tLimMlmSetKeysReq *mlm_set_key_req;
2709 tpPESession session_entry;
2710 uint8_t session_id; /* PE sessionID */
2711 uint8_t sme_session_id;
2712 uint16_t sme_transaction_id;
2713
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002714 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002715 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002716 return;
2717 }
2718
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302719 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002720 if (!set_context_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002721 return;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302722 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002723 sizeof(struct sSirSmeSetContextReq));
2724 sme_session_id = set_context_req->sessionId;
2725 sme_transaction_id = set_context_req->transactionId;
2726
2727 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002728 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002729 goto end;
2730 }
2731
2732 if (set_context_req->keyMaterial.numKeys >
2733 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002734 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002735 set_context_req->keyMaterial.numKeys);
2736 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002737 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002738 eSIR_SME_INVALID_PARAMETERS, NULL,
2739 sme_session_id, sme_transaction_id);
2740 goto end;
2741 }
2742
2743 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002744 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002745 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002746 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002747 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002748 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002749 eSIR_SME_INVALID_PARAMETERS, NULL,
2750 sme_session_id, sme_transaction_id);
2751 goto end;
2752 }
2753#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2754 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2755 session_entry, 0, 0);
2756#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2757
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002758 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002759 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2760 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002761 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002762 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2763 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302764 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002765 if (!mlm_set_key_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002766 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002767 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2768 mlm_set_key_req->numKeys =
2769 set_context_req->keyMaterial.numKeys;
2770 if (mlm_set_key_req->numKeys >
2771 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002772 pe_err("no.of keys exceeded max num of default keys limit");
Jingxiang Ge4168a232018-01-03 18:47:15 +08002773 qdf_mem_free(mlm_set_key_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002774 goto end;
2775 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302776 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002777 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002778
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302779 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002780 (uint8_t *) &set_context_req->keyMaterial.key,
2781 sizeof(tSirKeys) *
2782 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2783 numKeys : 1));
2784
2785 mlm_set_key_req->sessionId = session_id;
2786 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002787 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002788 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002789
2790 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2791 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2792 LIM_IS_AP_ROLE(session_entry)) {
2793 if (set_context_req->keyMaterial.key[0].keyLength) {
2794 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002795
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002796 key_id =
2797 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302798 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002799 &session_entry->WEPKeyMaterial[key_id],
2800 (uint8_t *) &set_context_req->keyMaterial,
2801 sizeof(tSirKeyMaterial));
2802 } else {
2803 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002804
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002805 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2806 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302807 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002808 &mlm_set_key_req->key[i],
2809 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2810 sizeof(tSirKeys));
2811 }
2812 }
2813 }
2814 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2815 (uint32_t *) mlm_set_key_req);
2816 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002817 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002818 GET_LIM_SYSTEM_ROLE(session_entry),
2819 session_entry->limSmeState);
2820 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2821
2822 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002823 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002824 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2825 session_entry, sme_session_id,
2826 sme_transaction_id);
2827 }
2828end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302829 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002830 return;
2831}
2832
2833/**
2834 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2835 *
2836 * @mac_ctx: Pointer to Global MAC structure
2837 * @msg_buf: pointer to the SME message buffer
2838 *
2839 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2840 * from HDD or upper layer application.
2841 *
2842 * Return: None
2843 */
2844
Jeff Johnson801f1532016-10-07 07:54:50 -07002845static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2846 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002847{
2848 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2849 tpDphHashNode sta_ds = NULL;
2850 tpPESession session_entry = NULL;
2851 tSap_Event sap_event;
2852 tpWLAN_SAPEventCB sap_event_cb = NULL;
2853 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2854 uint8_t session_id = CSR_SESSION_ID_INVALID;
2855 uint8_t assoc_id = 0;
2856 uint8_t sta_cnt = 0;
2857
2858 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002859 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002860 return;
2861 }
2862
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302863 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002864 sizeof(struct sSirSmeGetAssocSTAsReq));
2865 /*
2866 * Get Associated stations from PE.
2867 * Find PE session Entry
2868 */
2869 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08002870 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002871 &session_id);
2872 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002873 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002874 goto lim_assoc_sta_end;
2875 }
2876
2877 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002878 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002879 session_entry->limSmeState,
2880 GET_LIM_SYSTEM_ROLE(session_entry));
2881 goto lim_assoc_sta_end;
2882 }
2883 /* Retrieve values obtained in the request message */
2884 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
2885 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2886
2887 if (NULL == assoc_sta_tmp)
2888 goto lim_assoc_sta_end;
2889 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
2890 assoc_id++) {
2891 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
2892 &session_entry->dph.dphHashTable);
2893 if (NULL == sta_ds)
2894 continue;
2895 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302896 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002897 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302898 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002899 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
2900 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
2901
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302902 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002903 (uint8_t *)&sta_ds->supportedRates,
2904 sizeof(tSirSupportedRates));
2905 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
2906 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
2907 assoc_sta_tmp->Support40Mhz =
2908 sta_ds->htDsssCckRate40MHzSupport;
2909
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002910 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002911 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002912 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002913 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002914 pe_debug("Association Id: %d Station Index: %d",
2915 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002916 assoc_sta_tmp++;
2917 sta_cnt++;
2918 }
2919 }
2920lim_assoc_sta_end:
2921 /*
2922 * Call hdd callback with sap event to send the list of
2923 * associated stations from PE
2924 */
2925 if (sap_event_cb != NULL) {
2926 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
2927 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302928 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
2930 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
2931 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2932 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
2933 }
2934}
2935
2936/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002937 * __lim_counter_measures()
2938 *
2939 * FUNCTION:
2940 * This function is called to "implement" MIC counter measure
2941 * and is *temporary* only
2942 *
2943 * LOGIC: on AP, disassoc all STA associated thru TKIP,
2944 * we don't do the proper STA disassoc sequence since the
Jeff Johnsond460e842018-05-11 13:25:53 -07002945 * BSS will be stopped anyway
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002946 *
2947 ***ASSUMPTIONS:
2948 *
2949 ***NOTE:
2950 *
2951 * @param pMac Pointer to Global MAC structure
2952 * @return None
2953 */
2954
2955static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
2956{
Jeff Johnson2b511902018-11-20 09:40:23 -08002957 tSirMacAddr mac_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002958
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002959 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002960 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
Jeff Johnson2b511902018-11-20 09:40:23 -08002961 mac_addr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962};
2963
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05302964void lim_send_stop_bss_failure_resp(tpAniSirGlobal mac_ctx,
2965 tpPESession session)
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302966{
2967 session->limSmeState = session->limPrevSmeState;
2968
2969 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE, session->peSessionId,
2970 session->limSmeState));
2971
2972 lim_send_sme_rsp(mac_ctx, eWNI_SME_STOP_BSS_RSP,
2973 eSIR_SME_STOP_BSS_FAILURE, session->smeSessionId,
2974 session->transactionId);
2975}
2976
2977void lim_delete_all_peers(tpPESession session)
2978{
2979 uint8_t i = 0;
2980 tpAniSirGlobal mac_ctx = session->mac_ctx;
2981 tpDphHashNode sta_ds = NULL;
2982 QDF_STATUS status;
2983
2984 for (i = 1; i < session->dph.dphHashTable.size; i++) {
2985 sta_ds = dph_get_hash_entry(mac_ctx, i,
2986 &session->dph.dphHashTable);
2987 if (!sta_ds)
2988 continue;
2989 status = lim_del_sta(mac_ctx, sta_ds, false, session);
2990 if (QDF_STATUS_SUCCESS == status) {
2991 lim_delete_dph_hash_entry(mac_ctx, sta_ds->staAddr,
2992 sta_ds->assocId, session);
2993 lim_release_peer_idx(mac_ctx, sta_ds->assocId, session);
2994 } else {
2995 pe_err("lim_del_sta failed with Status: %d", status);
2996 QDF_ASSERT(0);
2997 }
2998 }
Abhishek Singhcaa61852018-09-12 15:50:04 +05302999
3000#ifdef CONFIG_VDEV_SM
3001 status =
3002 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3003 WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE,
3004 sizeof(*session), session);
3005 if (QDF_IS_STATUS_ERROR(status)) {
3006 pe_err("failed to post WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE for vdevid %d",
3007 session->smeSessionId);
3008 lim_send_stop_bss_failure_resp(mac_ctx, session);
3009 }
3010#endif
3011
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303012}
3013
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07003014QDF_STATUS lim_sta_send_del_bss(tpPESession session)
3015{
3016 tpAniSirGlobal mac_ctx = session->mac_ctx;
3017 QDF_STATUS status = QDF_STATUS_E_FAILURE;
3018 tpDphHashNode sta_ds = NULL;
3019
3020 sta_ds = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3021 &session->dph.dphHashTable);
3022 if (!sta_ds) {
3023 pe_err("DPH Entry for STA is missing, failed to send delbss");
3024 goto end;
3025 }
3026
3027 status = lim_del_bss(mac_ctx, sta_ds, 0, session);
3028 if (QDF_IS_STATUS_ERROR(status))
3029 pe_err("delBss failed for bss %d", session->bssIdx);
3030
3031end:
3032 return status;
3033}
3034
Abhishek Singhcaa61852018-09-12 15:50:04 +05303035QDF_STATUS lim_send_vdev_stop(tpPESession session)
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303036{
3037 tpAniSirGlobal mac_ctx = session->mac_ctx;
3038 QDF_STATUS status;
3039
3040 status = lim_del_bss(mac_ctx, NULL, session->bssIdx, session);
3041
3042 if (QDF_IS_STATUS_ERROR(status)) {
3043 pe_err("delBss failed for bss %d", session->bssIdx);
3044 lim_send_stop_bss_failure_resp(mac_ctx, session);
3045 }
Abhishek Singhcaa61852018-09-12 15:50:04 +05303046
3047 return status;
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303048}
3049
3050/**
3051 * lim_delete_peers_and_send_vdev_stop() -delete peers and send vdev stop
3052 * @session: session pointer
3053 *
3054 * Return None
3055 */
Abhishek Singhcaa61852018-09-12 15:50:04 +05303056#ifdef CONFIG_VDEV_SM
3057static void lim_delete_peers_and_send_vdev_stop(tpPESession session)
3058{
3059 tpAniSirGlobal mac_ctx = session->mac_ctx;
3060 QDF_STATUS status;
3061
Abhishek Singhc5a54082018-09-12 16:08:03 +05303062 if (wlan_vdev_mlme_get_substate(session->vdev) ==
3063 WLAN_VDEV_SS_START_RESTART_PROGRESS)
3064 status =
3065 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3066 WLAN_VDEV_SM_EV_RESTART_REQ_FAIL,
Abhishek Singhcaa61852018-09-12 15:50:04 +05303067 sizeof(*session), session);
Abhishek Singhc5a54082018-09-12 16:08:03 +05303068 else
3069 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3070 WLAN_VDEV_SM_EV_DOWN,
3071 sizeof(*session),
3072 session);
Abhishek Singhcaa61852018-09-12 15:50:04 +05303073 if (QDF_IS_STATUS_ERROR(status)) {
3074 pe_err("failed to post WLAN_VDEV_SM_EV_DOWN for vdevid %d",
3075 session->smeSessionId);
3076 lim_send_stop_bss_failure_resp(mac_ctx, session);
3077 }
3078}
3079#else
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303080static void lim_delete_peers_and_send_vdev_stop(tpPESession session)
3081{
3082 lim_delete_all_peers(session);
3083 /* send a delBss to HAL and wait for a response */
3084 lim_send_vdev_stop(session);
3085}
Abhishek Singhcaa61852018-09-12 15:50:04 +05303086#endif
3087
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003088static void
3089__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3090{
3091 tSirSmeStopBssReq stopBssReq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003092 tLimSmeStates prevState;
3093 tpPESession psessionEntry;
3094 uint8_t smesessionId;
3095 uint8_t sessionId;
3096 uint16_t smetransactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003097
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303098 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003099 smesessionId = stopBssReq.sessionId;
3100 smetransactionId = stopBssReq.transactionId;
3101
3102 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003103 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003104 /* Send Stop BSS response to host */
3105 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3106 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3107 smetransactionId);
3108 return;
3109 }
3110
3111 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003112 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003113 &sessionId);
3114 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003115 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003116 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3117 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3118 smetransactionId);
3119 return;
3120 }
3121#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3122 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3123 0, 0);
3124#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3125
3126 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3127 LIM_IS_STA_ROLE(psessionEntry)) {
3128 /**
3129 * Should not have received STOP_BSS_REQ in states
3130 * other than 'normal' state or on STA in Infrastructure
3131 * mode. Log error and return response to host.
3132 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003133 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003134 psessionEntry->limSmeState,
3135 GET_LIM_SYSTEM_ROLE(psessionEntry));
3136 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3137 /* / Send Stop BSS response to host */
3138 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3139 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3140 smetransactionId);
3141 return;
3142 }
3143
3144 if (LIM_IS_AP_ROLE(psessionEntry))
3145 lim_wpspbc_close(pMac, psessionEntry);
3146
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003147 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003148 stopBssReq.reasonCode);
3149
3150 prevState = psessionEntry->limSmeState;
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303151 psessionEntry->limPrevSmeState = prevState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003152
3153 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3154 MTRACE(mac_trace
3155 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3156 psessionEntry->limSmeState));
3157
3158 /* Update SME session Id and Transaction Id */
3159 psessionEntry->smeSessionId = smesessionId;
3160 psessionEntry->transactionId = smetransactionId;
3161
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003162 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3163 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3164 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003165 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003166
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003167 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3168 /* Send disassoc all stations associated thru TKIP */
3169 __lim_counter_measures(pMac, psessionEntry);
3170 else
3171 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003172 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3173 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003174 }
3175
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003176 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3177 /* Free the buffer allocated in START_BSS_REQ */
3178 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3179 psessionEntry->addIeParams.probeRespDataLen = 0;
3180 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003181
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003182 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3183 psessionEntry->addIeParams.assocRespDataLen = 0;
3184 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003185
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003186 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3187 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3188 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003189
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003190 /*
3191 * lim_del_bss is also called as part of coalescing,
3192 * when we send DEL BSS followed by Add Bss msg.
3193 */
3194 pMac->lim.gLimIbssCoalescingHappened = false;
3195 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003196
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303197 lim_delete_peers_and_send_vdev_stop(psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003198
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003199}
3200
3201/**
3202 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3203 * @pMac: Global MAC context
3204 * @pMsg: Message from SME
3205 *
3206 * Wrapper for the function __lim_handle_sme_stop_bss_request
3207 * This message will be defered until softmac come out of
3208 * scan mode. Message should be handled even if we have
3209 * detected radar in the current operating channel.
3210 *
3211 * Return: true - If we consumed the buffer
3212 * false - If have defered the message.
3213 */
3214
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003215static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3216 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003217{
3218 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3219 /**
3220 * If message defered, buffer is not consumed yet.
3221 * So return false
3222 */
3223 return false;
3224 }
3225 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3226 return true;
3227} /*** end __lim_process_sme_stop_bss_req() ***/
3228
3229void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3230 uint32_t body, tpPESession psessionEntry)
3231{
3232
3233 (void)body;
3234 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3235 lim_ibss_delete(pMac, psessionEntry);
3236 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3237 lim_delete_pre_auth_list(pMac);
3238 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3239 psessionEntry->smeSessionId,
3240 psessionEntry->transactionId);
3241 return;
3242}
3243
3244/**
3245 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3246 *
3247 * @mac_ctx: pointer to mac context
3248 * @msg_type: message type
3249 * @msg_buf: pointer to the SME message buffer
3250 *
3251 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3252 * in BTAMP AP.
3253 *
3254 * Return: None
3255 */
3256
3257void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3258 uint32_t *msg_buf)
3259{
3260 tSirSmeAssocCnf assoc_cnf;
3261 tpDphHashNode sta_ds = NULL;
3262 tpPESession session_entry = NULL;
3263 uint8_t session_id;
3264 tpSirAssocReq assoc_req;
3265
3266 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003267 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003268 goto end;
3269 }
3270
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303271 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003272 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003273 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003274 goto end;
3275 }
3276
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003277 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003278 &session_id);
3279 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003280 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003281 goto end;
3282 }
3283
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003284 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003285 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3286 (session_entry->limSmeState !=
3287 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003288 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003289 msg_type, session_entry->limSmeState,
3290 GET_LIM_SYSTEM_ROLE(session_entry));
3291 goto end;
3292 }
3293 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3294 &session_entry->dph.dphHashTable);
3295 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003296 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003297 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303298 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003299
3300 /*
3301 * send a DISASSOC_IND message to WSM to make sure
3302 * the state in WSM and LIM is the same
3303 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003304 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003305 eSIR_SME_STA_NOT_ASSOCIATED,
3306 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3307 session_entry->smeSessionId,
3308 session_entry->transactionId,
3309 session_entry);
3310 goto end;
3311 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303312 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003313 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303314 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003315 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003316 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303317 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003318 goto end;
3319 }
3320
3321 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3322 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3323 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3324 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3325 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003326 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3327 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003328 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303329 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330 goto end;
3331 }
3332 /*
3333 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3334 * has been received
3335 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003336 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003337 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3338 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3339
3340 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3341 /*
3342 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3343 * when it had received Assoc Request frame. Now, PE just needs
3344 * to send association rsp frame to the requesting BTAMP-STA.
3345 */
3346 sta_ds->mlmStaContext.mlmState =
3347 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003348 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003349 sta_ds->assocId);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003350 lim_send_assoc_rsp_mgmt_frame(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003351 sta_ds->assocId, sta_ds->staAddr,
3352 sta_ds->mlmStaContext.subType, sta_ds,
3353 session_entry);
3354 goto end;
3355 } else {
3356 /*
3357 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3358 * to be associated since the HAL sta entry is created for
3359 * denied STA we need to remove this HAL entry.
3360 * So to do that set updateContext to 1
3361 */
3362 if (!sta_ds->mlmStaContext.updateContext)
3363 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003364 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003365 assoc_cnf.statusCode, sta_ds->assocId);
3366 lim_reject_association(mac_ctx, sta_ds->staAddr,
3367 sta_ds->mlmStaContext.subType,
3368 true, sta_ds->mlmStaContext.authType,
3369 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003370 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003371 session_entry);
3372 }
3373end:
3374 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3375 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3376 assoc_req = (tpSirAssocReq)
3377 session_entry->parsedAssocReq[sta_ds->assocId];
3378 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303379 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003380 assoc_req->assocReqFrame = NULL;
3381 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303382 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003383 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3384 }
3385}
3386
3387static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3388{
3389 tpDphHashNode pStaDs;
3390 tSirMacAddr peerMac;
3391 tpSirAddtsReq pSirAddts;
3392 uint32_t timeout;
3393 tpPESession psessionEntry;
3394 uint8_t sessionId; /* PE sessionId */
3395 uint8_t smesessionId;
3396 uint16_t smetransactionId;
3397
3398 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003399 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003400 return;
3401 }
3402
3403 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3404 &smetransactionId);
3405
3406 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3407
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003408 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3409 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003410 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003411 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003412 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303413 NULL, pSirAddts->req.tspec,
3414 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003415 return;
3416 }
3417#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3418 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3419 0);
3420#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3421
3422 /* if sta
3423 * - verify assoc state
3424 * - send addts request to ap
3425 * - wait for addts response from ap
3426 * if ap, just ignore with error log
3427 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003428 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3429 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3430 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003431
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003432 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003433 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303434 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003435 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436
3437 pStaDs =
3438 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3439 &psessionEntry->dph.dphHashTable);
3440
3441 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003442 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303443 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003444 }
3445
3446 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3447 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003448 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303449 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003450 }
3451
3452 pSirAddts->req.wsmTspecPresent = 0;
3453 pSirAddts->req.wmeTspecPresent = 0;
3454 pSirAddts->req.lleTspecPresent = 0;
3455
3456 if ((pStaDs->wsmEnabled) &&
3457 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3458 SIR_MAC_ACCESSPOLICY_EDCA))
3459 pSirAddts->req.wsmTspecPresent = 1;
3460 else if (pStaDs->wmeEnabled)
3461 pSirAddts->req.wmeTspecPresent = 1;
3462 else if (pStaDs->lleEnabled)
3463 pSirAddts->req.lleTspecPresent = 1;
3464 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003465 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303466 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003467 }
3468
3469 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3470 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003471 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003472 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303473 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003474 }
3475
3476 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003477 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003478 pMac->lim.gLimAddtsReq.req.dialogToken,
3479 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3480 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3481 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303482 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003483 }
3484
3485 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3486
3487 /* save the addts request */
3488 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303489 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003490 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3491
3492 /* ship out the message now */
3493 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3494 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303495 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496 /* start a timer to wait for the response */
3497 if (pSirAddts->timeout)
3498 timeout = pSirAddts->timeout;
Arif Hussain43e09712018-09-18 19:31:57 -07003499 else
3500 timeout = pMac->mlme_cfg->timeouts.addts_rsp_timeout;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003501
3502 timeout = SYS_MS_TO_TICKS(timeout);
3503 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3504 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003505 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303506 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003507 }
3508 pMac->lim.gLimAddtsRspTimerCount++;
3509 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3510 pMac->lim.gLimAddtsRspTimerCount) !=
3511 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003512 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303513 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003514 }
3515 MTRACE(mac_trace
3516 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3517 eLIM_ADDTS_RSP_TIMER));
3518
3519 /* add the sessionId to the timer object */
3520 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3521 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3522 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003523 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303524 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003525 }
3526 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303527
3528send_failure_addts_rsp:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003529 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303530 psessionEntry, pSirAddts->req.tspec,
3531 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003532}
3533
3534static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3535{
3536 tSirMacAddr peerMacAddr;
3537 uint8_t ac;
3538 tSirMacTSInfo *pTsinfo;
3539 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3540 tpDphHashNode pStaDs = NULL;
3541 tpPESession psessionEntry;
3542 uint8_t sessionId;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003543 uint32_t status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003544 uint8_t smesessionId;
3545 uint16_t smetransactionId;
3546
3547 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3548 &smetransactionId);
3549
3550 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003551 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003552 &sessionId);
3553 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003554 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003555 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003556 goto end;
3557 }
3558#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3559 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3560 0);
3561#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3562
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003563 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003564 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003565 pe_err("lim_validate_delts_req failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003566 status = QDF_STATUS_E_FAILURE;
3567 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_E_FAILURE, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003568 smesessionId, smetransactionId);
3569 return;
3570 }
3571
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003572 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3573 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003574 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3575
3576 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3577 pDeltsReq->req.wmeTspecPresent,
3578 &pDeltsReq->req.tsinfo,
3579 &pDeltsReq->req.tspec, psessionEntry);
3580
3581 pTsinfo =
3582 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3583 tsinfo : &pDeltsReq->req.tsinfo;
3584
3585 /* We've successfully send DELTS frame to AP. Update the
3586 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3587 * is no longer trigger enabled or delivery enabled
3588 */
3589 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3590 pTsinfo, CLEAR_UAPSD_MASK);
3591
3592 /* We're deleting the TSPEC, so this particular AC is no longer
3593 * admitted. PE needs to downgrade the EDCA
3594 * parameters(for the AC for which TS is being deleted) to the
3595 * next best AC for which ACM is not enabled, and send the
3596 * updated values to HAL.
3597 */
3598 ac = upToAc(pTsinfo->traffic.userPrio);
3599
3600 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3601 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3602 ~(1 << ac);
3603 } else if (pTsinfo->traffic.direction ==
3604 SIR_MAC_DIRECTION_DNLINK) {
3605 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3606 ~(1 << ac);
3607 } else if (pTsinfo->traffic.direction ==
3608 SIR_MAC_DIRECTION_BIDIR) {
3609 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3610 ~(1 << ac);
3611 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3612 ~(1 << ac);
3613 }
3614
3615 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3616 psessionEntry);
3617
3618 pStaDs =
3619 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3620 &psessionEntry->dph.dphHashTable);
3621 if (pStaDs != NULL) {
3622 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003623 pStaDs->bssId, false);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003624 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003625 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003626 pe_err("Self entry missing in Hash Table");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003627 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003628 }
3629#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003630 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003631#endif
3632
3633 /* send an sme response back */
3634end:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003635 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_SUCCESS, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003636 smesessionId, smetransactionId);
3637}
3638
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303639void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003640{
3641 /* fetch the sessionEntry based on the sessionId */
3642 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003643
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003644 psessionEntry = pe_find_session_by_session_id(pMac,
3645 pMac->lim.limTimers.gLimAddtsRspTimer.
3646 sessionId);
3647 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003648 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003649 return;
3650 }
3651
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003652 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003653 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003654 GET_LIM_SYSTEM_ROLE(psessionEntry));
3655 pMac->lim.gLimAddtsSent = false;
3656 return;
3657 }
3658
3659 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003660 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003661 return;
3662 }
3663
3664 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003665 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666 pMac->lim.gLimAddtsRspTimerCount);
3667 return;
3668 }
3669 /* this a real response timeout */
3670 pMac->lim.gLimAddtsSent = false;
3671 pMac->lim.gLimAddtsRspTimerCount++;
3672
3673 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3674 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3675 psessionEntry->smeSessionId,
3676 psessionEntry->transactionId);
3677}
3678
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003679#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003680/**
3681 * __lim_process_sme_get_statistics_request()
3682 *
3683 ***FUNCTION:
3684 *
3685 *
3686 ***NOTE:
3687 *
3688 * @param pMac Pointer to Global MAC structure
3689 * @param *pMsgBuf A pointer to the SME message buffer
3690 * @return None
3691 */
3692static void
3693__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3694{
3695 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003696 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003697
3698 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3699
3700 msgQ.type = WMA_GET_STATISTICS_REQ;
3701
3702 msgQ.reserved = 0;
3703 msgQ.bodyptr = pMsgBuf;
3704 msgQ.bodyval = 0;
3705 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3706
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003707 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303708 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003709 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003710 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003711 return;
3712 }
3713
3714 return;
3715}
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003716#else
3717static void __lim_process_sme_get_statistics_request(
Jeff Johnson009c40f2018-11-05 09:54:37 -08003718 struct mac_context *mac_ctx, uint32_t *pMsgBuf) {}
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003719#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003720
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003721#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003722/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003723 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003724 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003725 * @pMac: Pointer to Global MAC structure
3726 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003727 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003728 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003729 */
3730static void
3731__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3732{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003733 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003734
3735 msgQ.type = WMA_TSM_STATS_REQ;
3736 msgQ.reserved = 0;
3737 msgQ.bodyptr = pMsgBuf;
3738 msgQ.bodyval = 0;
3739 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3740
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003741 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303742 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003743 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003744 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003745 return;
3746 }
3747}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003748#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003749
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08003750static void lim_process_sme_set_addba_accept(tpAniSirGlobal mac_ctx,
3751 struct sme_addba_accept *msg)
3752{
3753 if (!msg) {
3754 pe_err("Msg Buffer is NULL");
3755 return;
3756 }
3757 if (!msg->addba_accept)
3758 mac_ctx->reject_addba_req = 1;
3759 else
3760 mac_ctx->reject_addba_req = 0;
3761}
3762
Arif Hussaineb8ba362018-03-07 19:15:13 -08003763static void lim_process_sme_update_edca_params(tpAniSirGlobal mac_ctx,
3764 uint32_t sme_session_id)
3765{
3766 tpPESession pe_session;
3767 tpDphHashNode sta_ds_ptr;
3768
3769 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3770 if (!pe_session) {
3771 pe_err("Session does not exist: sme_id %d", sme_session_id);
3772 return;
3773 }
3774 pe_session->gLimEdcaParamsActive[EDCA_AC_BE].no_ack =
3775 mac_ctx->no_ack_policy_cfg[EDCA_AC_BE];
3776 pe_session->gLimEdcaParamsActive[EDCA_AC_BK].no_ack =
3777 mac_ctx->no_ack_policy_cfg[EDCA_AC_BK];
3778 pe_session->gLimEdcaParamsActive[EDCA_AC_VI].no_ack =
3779 mac_ctx->no_ack_policy_cfg[EDCA_AC_VI];
3780 pe_session->gLimEdcaParamsActive[EDCA_AC_VO].no_ack =
3781 mac_ctx->no_ack_policy_cfg[EDCA_AC_VO];
3782 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3783 &pe_session->dph.dphHashTable);
3784 if (sta_ds_ptr)
3785 lim_send_edca_params(mac_ctx,
3786 pe_session->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003787 sta_ds_ptr->bssId, false);
Arif Hussaineb8ba362018-03-07 19:15:13 -08003788 else
3789 pe_err("Self entry missing in Hash Table");
3790}
3791
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07003792static void lim_process_sme_update_mu_edca_params(tpAniSirGlobal mac_ctx,
3793 uint32_t sme_session_id)
3794{
3795 tpPESession pe_session;
3796 tpDphHashNode sta_ds_ptr;
3797
3798 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3799 if (!pe_session) {
3800 pe_err("Session does not exist: sme_id %d", sme_session_id);
3801 return;
3802 }
3803 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3804 &pe_session->dph.dphHashTable);
3805 if (sta_ds_ptr)
3806 lim_send_edca_params(mac_ctx, mac_ctx->usr_mu_edca_params,
3807 sta_ds_ptr->bssId, true);
3808 else
3809 pe_err("Self entry missing in Hash Table");
3810}
3811
Kiran Kumar Lokereee205772018-09-27 00:27:27 -07003812static void
3813lim_process_sme_cfg_action_frm_in_tb_ppdu(struct mac_context *mac_ctx,
3814 struct sir_cfg_action_frm_tb_ppdu
3815 *msg)
3816{
3817 if (!msg) {
3818 pe_err("Buffer is NULL");
3819 return;
3820 }
3821
3822 lim_send_action_frm_tb_ppdu_cfg(mac_ctx, msg->session_id, msg->cfg);
3823}
3824
Naveen Rawat8029a402017-06-01 10:54:19 -07003825static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3826 struct update_config *msg)
3827{
3828 tpPESession pe_session;
3829
3830 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3831 if (msg == NULL) {
3832 pe_err("Buffer is Pointing to NULL");
3833 return;
3834 }
3835
3836 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3837 msg->sme_session_id);
3838 if (pe_session == NULL) {
3839 pe_warn("Session does not exist for given BSSID");
3840 return;
3841 }
3842
3843 switch (msg->capab) {
3844 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3845 pe_session->htConfig.ht_rx_ldpc = msg->value;
3846 break;
3847 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3848 pe_session->htConfig.ht_tx_stbc = msg->value;
3849 break;
3850 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3851 pe_session->htConfig.ht_rx_stbc = msg->value;
3852 break;
3853 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3854 pe_session->htConfig.ht_sgi20 = msg->value;
3855 break;
3856 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3857 pe_session->htConfig.ht_sgi40 = msg->value;
3858 break;
3859 }
3860
3861 if (LIM_IS_AP_ROLE(pe_session)) {
3862 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
Abhishek Singhfc740be2018-10-12 11:34:26 +05303863 lim_send_beacon_ind(mac_ctx, pe_session, REASON_CONFIG_UPDATE);
Naveen Rawat8029a402017-06-01 10:54:19 -07003864 }
3865}
3866
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003867void
3868lim_send_vdev_restart(tpAniSirGlobal pMac,
3869 tpPESession psessionEntry, uint8_t sessionId)
3870{
3871 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003872 struct scheduler_msg msgQ = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003873 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003874
3875 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003876 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003877 return;
3878 }
3879
3880 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303881 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Arif Hussainf5b6c412018-10-10 19:41:09 -07003882 if (!pHalHiddenSsidVdevRestart)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003883 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003884
3885 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3886 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003887 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003888
3889 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3890 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3891 msgQ.bodyval = 0;
3892
3893 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003894 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003895 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303896 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003897 }
3898}
3899
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303900/**
3901 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3902 * @mac_ctx: Pointer to Global MAC structure
3903 * @msg_buf: Pointer to SME message buffer
3904 *
3905 * Return: None
3906 */
3907static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3908 uint32_t *msg_buf)
3909{
3910 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003911 struct scheduler_msg wma_msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003912 QDF_STATUS status;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303913 tSirRoamOffloadScanReq *req_buffer;
3914 uint16_t local_ie_len;
3915 uint8_t *local_ie_buf;
3916
3917 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3918 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3919 req_buffer->sessionId);
3920
3921 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3922 if (!local_ie_buf) {
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303923 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303924 return;
3925 }
3926
3927 local_ie_len = req_buffer->assoc_ie.length;
3928 /* Update ext cap IE if present */
3929 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003930 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3931 local_ie_buf, &local_ie_len)) {
3932 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003933 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3934 req_buffer->assoc_ie.length = local_ie_len;
3935 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3936 local_ie_buf, local_ie_len);
3937 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303938 }
3939 qdf_mem_free(local_ie_buf);
3940
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303941 if (pe_session)
3942 lim_update_fils_rik(pe_session, req_buffer);
3943
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303944 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3945 wma_msg.bodyptr = req_buffer;
3946
3947 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003948 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003949 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303950 qdf_mem_free(req_buffer);
3951 }
3952}
3953
Paul Zhang624f88d2018-11-07 15:29:45 +08003954#ifdef WLAN_FEATURE_ROAM_OFFLOAD
3955/**
3956 * lim_process_roam_invoke() - process the Roam Invoke req
3957 * @mac_ctx: Pointer to Global MAC structure
3958 * @msg_buf: Pointer to the SME message buffer
3959 *
3960 * This function is called by limProcessMessageQueue(). This function sends the
3961 * ROAM_INVOKE command to WMA.
3962 *
3963 * Return: None
3964 */
3965static void lim_process_roam_invoke(tpAniSirGlobal mac_ctx,
3966 uint32_t *msg_buf)
3967{
3968 struct scheduler_msg msg = {0};
3969 QDF_STATUS status;
3970
3971 msg.type = SIR_HAL_ROAM_INVOKE;
3972 msg.bodyptr = msg_buf;
3973 msg.reserved = 0;
3974
3975 status = wma_post_ctrl_msg(mac_ctx, &msg);
3976 if (QDF_STATUS_SUCCESS != status)
3977 pe_err("Not able to post SIR_HAL_ROAM_INVOKE to WMA");
3978}
3979#else
3980static void lim_process_roam_invoke(tpAniSirGlobal mac_ctx,
3981 uint32_t *msg_buf)
3982{
3983 qdf_mem_free(msg_buf);
3984}
3985#endif
3986
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303987/*
3988 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3989 * @mac_ctx: Pointer to global mac context
3990 * @session: Pointer to PE session
3991 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3992 * 1 - Disable broadcast SSID
3993 *
3994 * Return: None
3995 */
3996static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3997 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003998{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003999 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004000 session->ssidHidden, ssid_hidden);
4001
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004002 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304003 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004004 } else {
4005 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05304006 return;
4007 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004008
Abhishek Singh6c681f42018-09-12 15:52:36 +05304009#ifdef CONFIG_VDEV_SM
4010 ap_mlme_set_hidden_ssid_restart_in_progress(session->vdev, true);
4011 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4012 WLAN_VDEV_SM_EV_FW_VDEV_RESTART,
4013 sizeof(*session), session);
4014#else
4015
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004016 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304017 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Abhishek Singh6c681f42018-09-12 15:52:36 +05304018#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004019
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004020 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304021}
4022
4023/**
4024 * __lim_process_sme_session_update - process SME session update msg
4025 *
4026 * @mac_ctx: Pointer to global mac context
4027 * @msg_buf: Pointer to the received message buffer
4028 *
4029 * Return: None
4030 */
4031static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
4032 uint32_t *msg_buf)
4033{
4034 struct sir_update_session_param *msg;
4035 tpPESession session;
4036
4037 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004038 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304039 return;
4040 }
4041
4042 msg = (struct sir_update_session_param *) msg_buf;
4043
4044 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
4045 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004046 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304047 msg->session_id);
4048 return;
4049 }
4050
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004051 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304052 msg->param_type, msg->param_val);
4053 switch (msg->param_type) {
4054 case SIR_PARAM_SSID_HIDDEN:
4055 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
4056 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05304057 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
4058 session->ignore_assoc_disallowed = msg->param_val;
4059 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304060 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004061 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304062 break;
4063 }
4064}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004065
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004066/*
4067 Update the beacon Interval dynamically if beaconInterval is different in MCC
4068 */
4069static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4070{
4071 tpSirChangeBIParams pChangeBIParams;
4072 tpPESession psessionEntry;
4073 uint8_t sessionId = 0;
4074 tUpdateBeaconParams beaconParams;
4075
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004076 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004077
4078 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004079 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004080 return;
4081 }
4082
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304083 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004084 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4085
4086 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004087 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004088 &sessionId);
4089 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004090 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004091 return;
4092 }
4093
4094 /*Update sessionEntry Beacon Interval */
4095 if (psessionEntry->beaconParams.beaconInterval !=
4096 pChangeBIParams->beaconInterval) {
4097 psessionEntry->beaconParams.beaconInterval =
4098 pChangeBIParams->beaconInterval;
4099 }
4100
4101 /*Update sch beaconInterval */
4102 if (pMac->sch.schObject.gSchBeaconInterval !=
4103 pChangeBIParams->beaconInterval) {
4104 pMac->sch.schObject.gSchBeaconInterval =
4105 pChangeBIParams->beaconInterval;
4106
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004107 pe_debug("LIM send update BeaconInterval Indication: %d",
4108 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004109
4110 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4111 /* Update beacon */
4112 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4113
4114 beaconParams.bssIdx = psessionEntry->bssIdx;
4115 /* Set change in beacon Interval */
4116 beaconParams.beaconInterval =
4117 pChangeBIParams->beaconInterval;
4118 beaconParams.paramChangeBitmap =
4119 PARAM_BCN_INTERVAL_CHANGED;
4120 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4121 }
4122 }
4123
4124 return;
4125} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4126
4127#ifdef QCA_HT_2040_COEX
4128static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4129 uint32_t *pMsgBuf)
4130{
4131 tpSirSetHT2040Mode pSetHT2040Mode;
4132 tpPESession psessionEntry;
4133 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004134 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004135 tUpdateVHTOpMode *pHtOpMode = NULL;
4136 uint16_t staId = 0;
4137 tpDphHashNode pStaDs = NULL;
4138
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004139 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004140 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004141 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004142 return;
4143 }
4144
4145 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4146
4147 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004148 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004149 &sessionId);
4150 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004151 pe_debug("Session does not exist for given BSSID");
4152 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004153 return;
4154 }
4155
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004156 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004157 pSetHT2040Mode->cbMode);
4158 /*Update sessionEntry HT related fields */
4159 switch (pSetHT2040Mode->cbMode) {
4160 case PHY_SINGLE_CHANNEL_CENTERED:
4161 psessionEntry->htSecondaryChannelOffset =
4162 PHY_SINGLE_CHANNEL_CENTERED;
4163 psessionEntry->htRecommendedTxWidthSet = 0;
4164 if (pSetHT2040Mode->obssEnabled)
4165 psessionEntry->htSupportedChannelWidthSet
4166 = eHT_CHANNEL_WIDTH_40MHZ;
4167 else
4168 psessionEntry->htSupportedChannelWidthSet
4169 = eHT_CHANNEL_WIDTH_20MHZ;
4170 break;
4171 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4172 psessionEntry->htSecondaryChannelOffset =
4173 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4174 psessionEntry->htRecommendedTxWidthSet = 1;
4175 break;
4176 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4177 psessionEntry->htSecondaryChannelOffset =
4178 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4179 psessionEntry->htRecommendedTxWidthSet = 1;
4180 break;
4181 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004182 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004183 return;
4184 }
4185
4186 /* Update beacon */
4187 sch_set_fixed_beacon_fields(pMac, psessionEntry);
Abhishek Singhfc740be2018-10-12 11:34:26 +05304188 lim_send_beacon_ind(pMac, psessionEntry, REASON_SET_HT2040);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004189
4190 /* update OP Mode for each associated peer */
4191 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4192 pStaDs = dph_get_hash_entry(pMac, staId,
4193 &psessionEntry->dph.dphHashTable);
4194 if (NULL == pStaDs)
4195 continue;
4196
4197 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304198 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004199 if (!pHtOpMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004200 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201 pHtOpMode->opMode =
4202 (psessionEntry->htSecondaryChannelOffset ==
4203 PHY_SINGLE_CHANNEL_CENTERED) ?
4204 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4205 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304206 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004207 sizeof(tSirMacAddr));
4208 pHtOpMode->smesessionId = sessionId;
4209
4210 msg.type = WMA_UPDATE_OP_MODE;
4211 msg.reserved = 0;
4212 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004213 if (!QDF_IS_STATUS_SUCCESS
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05304214 (scheduler_post_message(QDF_MODULE_ID_PE,
4215 QDF_MODULE_ID_WMA,
4216 QDF_MODULE_ID_WMA,
4217 &msg))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004218 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304219 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004220 return;
4221 }
Jeff Johnson47d75242018-05-12 15:58:53 -07004222 pe_debug("Notified FW about OP mode: %d for staId=%d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004223 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004224
4225 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004226 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004227 }
4228
4229 return;
4230}
4231#endif
4232
4233/* -------------------------------------------------------------------- */
4234/**
4235 * __lim_process_report_message
4236 *
4237 * FUNCTION: Processes the next received Radio Resource Management message
4238 *
4239 * LOGIC:
4240 *
4241 * ASSUMPTIONS:
4242 *
4243 * NOTE:
4244 *
4245 * @param None
4246 * @return None
4247 */
4248
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004249static void __lim_process_report_message(tpAniSirGlobal pMac,
4250 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004251{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004252 switch (pMsg->type) {
4253 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4254 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4255 break;
4256 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004257 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004258 break;
4259 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004260 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004261 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004262}
4263
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004264/* -------------------------------------------------------------------- */
4265/**
4266 * lim_send_set_max_tx_power_req
4267 *
4268 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4269 *
4270 * LOGIC:
4271 *
4272 * ASSUMPTIONS:
4273 *
4274 * NOTE:
4275 *
4276 * @param txPower txPower to be set.
4277 * @param pSessionEntry session entry.
4278 * @return None
4279 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004280QDF_STATUS
Amar Singhala297bfa2015-10-15 15:07:29 -07004281lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004282 tpPESession pSessionEntry)
4283{
4284 tpMaxTxPowerParams pMaxTxParams = NULL;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004285 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004286 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004287
4288 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004289 pe_err("Invalid parameters");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004290 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004291 }
4292
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304293 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004294 if (!pMaxTxParams)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004295 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004296 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304297 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304298 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304299 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004300 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304301 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004302
4303 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4304 msgQ.bodyptr = pMaxTxParams;
4305 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004306 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004307 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4308 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004309 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004310 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304311 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004312 }
4313 return retCode;
4314}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004315
4316/**
4317 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4318 *
4319 * @mac_ctx: Pointer to Global MAC structure
4320 * @msg_buf: pointer to the SME message buffer
4321 *
4322 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4323 * from SME. It Register this information within PE.
4324 *
4325 * Return: None
4326 */
4327static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4328 uint32_t *msg_buf)
4329{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304330 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004331 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4332 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4333 struct mgmt_frm_reg_info *next = NULL;
4334 bool match = false;
4335
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004336 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004337 sme_req->registerFrame, sme_req->frameType,
4338 sme_req->matchLen);
4339 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304340 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304341 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4342 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304343 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004344
4345 while (lim_mgmt_regn != NULL) {
4346 if (lim_mgmt_regn->frameType != sme_req->frameType)
4347 goto skip_match;
4348 if (sme_req->matchLen) {
4349 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304350 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004351 sme_req->matchData,
4352 lim_mgmt_regn->matchLen))) {
4353 /* found match! */
4354 match = true;
4355 break;
4356 }
4357 } else {
4358 /* found match! */
4359 match = true;
4360 break;
4361 }
4362skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304363 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304364 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004365 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304366 (qdf_list_node_t *)lim_mgmt_regn,
4367 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304368 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004369 lim_mgmt_regn = next;
4370 next = NULL;
4371 }
4372 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304373 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004374 if (QDF_STATUS_SUCCESS ==
4375 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004376 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004377 (qdf_list_node_t *)lim_mgmt_regn))
4378 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304379 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004380 }
4381
4382 if (sme_req->registerFrame) {
4383 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304384 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004385 sme_req->matchLen);
4386 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004387 lim_mgmt_regn->frameType = sme_req->frameType;
4388 lim_mgmt_regn->matchLen = sme_req->matchLen;
4389 lim_mgmt_regn->sessionId = sme_req->sessionId;
4390 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304391 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004392 sme_req->matchData,
4393 sme_req->matchLen);
4394 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304395 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004396 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304397 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004398 gLimMgmtFrameRegistratinQueue,
4399 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304400 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004401 &mac_ctx->lim.lim_frame_register_lock);
4402 }
4403 }
4404 return;
4405}
4406
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004407static void
4408__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4409{
4410 tpSirResetAPCapsChange pResetCapsChange;
4411 tpPESession psessionEntry;
4412 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004413
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004414 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004415 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004416 return;
4417 }
4418
4419 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4420 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004421 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4422 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004423 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004424 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004425 return;
4426 }
4427
4428 psessionEntry->limSentCapsChangeNtf = false;
4429 return;
4430}
4431
4432/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304433 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4434 * indication callback in PE.
4435 * @mac_ptr: Mac pointer
4436 * @msg_buf: Msg pointer containing the callback
4437 *
4438 * This function is used save the Management frame
4439 * indication callback in PE.
4440 *
4441 * Return: None
4442 */
4443static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4444 uint32_t *msg_buf)
4445{
4446 struct sir_sme_mgmt_frame_cb_req *sme_req =
4447 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4448
4449 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004450 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304451 return;
4452 }
4453 if (sme_req->callback)
4454 mac_ctx->mgmt_frame_ind_cb =
4455 (sir_mgmt_frame_ind_callback)sme_req->callback;
4456 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004457 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304458}
4459
4460/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304461 *__lim_process_send_disassoc_frame: function processes disassoc frame
4462 * @mac_ctx: pointer to mac context
4463 * @msg_buf: message buffer
4464 *
4465 * function processes disassoc request received from SME
4466 *
4467 * return: none
4468 */
4469static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4470 uint32_t *msg_buf)
4471{
4472 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004473 QDF_STATUS status;
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304474 tpPESession session_entry = NULL;
4475 uint8_t sme_session_id;
4476 uint16_t sme_trans_id;
4477
4478 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004479 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304480 return;
4481 }
4482
4483 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4484 &sme_trans_id);
4485
4486 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4487 &sme_send_disassoc_frame_req,
4488 (uint8_t *)msg_buf);
4489
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004490 if ((QDF_STATUS_E_FAILURE == status) ||
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304491 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4492 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004493 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304494 return;
4495 }
4496
4497 session_entry = pe_find_session_by_sme_session_id(
4498 mac_ctx, sme_session_id);
4499 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004500 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304501 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4502 return;
4503 }
4504
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004505 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 +05304506 sme_send_disassoc_frame_req.msg_type,
4507 sme_send_disassoc_frame_req.length,
4508 sme_send_disassoc_frame_req.session_id,
4509 sme_send_disassoc_frame_req.trans_id,
4510 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4511 sme_send_disassoc_frame_req.reason,
4512 sme_send_disassoc_frame_req.wait_for_ack);
4513
4514 lim_send_disassoc_mgmt_frame(mac_ctx,
4515 sme_send_disassoc_frame_req.reason,
4516 sme_send_disassoc_frame_req.peer_mac,
4517 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4518}
4519
4520/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004521 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4522 * @mac_ctx: Pointer to Global MAC structure
4523 * @pdev_id: pdev id to set the IE.
4524 * @nss: Nss values to prepare the HT IE.
4525 *
4526 * Prepares the HT IE with self capabilities for different
4527 * Nss values and sends the set HT IE req to FW.
4528 *
4529 * Return: None
4530 */
4531static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4532 uint8_t nss)
4533{
4534 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004535 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004536 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004537 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004538 tHtCaps *p_ht_cap;
4539 int i;
4540
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004541 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004542 ie_params = qdf_mem_malloc(sizeof(*ie_params));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004543 if (!ie_params)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004544 return;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004545 ie_params->nss = i;
4546 ie_params->pdev_id = pdev_id;
4547 ie_params->ie_type = DOT11_HT_IE;
4548 /* 2 for IE len and EID */
4549 ie_params->ie_len = 2 + sizeof(tHtCaps);
4550 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -07004551 if (!ie_params->ie_ptr) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004552 qdf_mem_free(ie_params);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004553 return;
4554 }
4555 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4556 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4557 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4558 ie_params->ie_len);
4559
4560 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004561 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4562 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004563 if (NULL == p_ie) {
4564 qdf_mem_free(ie_params->ie_ptr);
4565 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004566 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004567 return;
4568 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004569 p_ht_cap = (tHtCaps *)&p_ie[2];
4570 p_ht_cap->supportedMCSSet[1] = 0;
4571 p_ht_cap->txSTBC = 0;
4572 }
4573
4574 msg.type = WMA_SET_PDEV_IE_REQ;
4575 msg.bodyptr = ie_params;
4576 msg.bodyval = 0;
4577
4578 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004579 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004580 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004581 qdf_mem_free(ie_params->ie_ptr);
4582 qdf_mem_free(ie_params);
4583 return;
4584 }
4585 }
4586}
4587
4588/**
4589 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4590 * @mac_ctx: Pointer to Global MAC structure
4591 * @pdev_id: pdev id to set the IE.
4592 * @nss: Nss values to prepare the VHT IE.
4593 *
4594 * Prepares the VHT IE with self capabilities for different
4595 * Nss values and sends the set VHT IE req to FW.
4596 *
4597 * Return: None
4598 */
4599static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4600 uint8_t nss)
4601{
4602 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004603 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004604 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004605 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004606 tSirMacVHTCapabilityInfo *vht_cap;
4607 int i;
4608 tSirVhtMcsInfo *vht_mcs;
4609
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004610 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004611 ie_params = qdf_mem_malloc(sizeof(*ie_params));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004612 if (!ie_params)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004613 return;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004614 ie_params->nss = i;
4615 ie_params->pdev_id = pdev_id;
4616 ie_params->ie_type = DOT11_VHT_IE;
4617 /* 2 for IE len and EID */
4618 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4619 sizeof(tSirVhtMcsInfo);
4620 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -07004621 if (!ie_params->ie_ptr) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004622 qdf_mem_free(ie_params);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004623 return;
4624 }
4625 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4626 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4627 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4628 ie_params->ie_len);
4629
4630 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004631 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4632 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004633 if (NULL == p_ie) {
4634 qdf_mem_free(ie_params->ie_ptr);
4635 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004636 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004637 return;
4638 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004639 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4640 vht_cap->txSTBC = 0;
4641 vht_mcs =
4642 (tSirVhtMcsInfo *)&p_ie[2 +
4643 sizeof(tSirMacVHTCapabilityInfo)];
4644 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4645 vht_mcs->rxHighest =
4646 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4647 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4648 vht_mcs->txHighest =
4649 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4650 }
4651 msg.type = WMA_SET_PDEV_IE_REQ;
4652 msg.bodyptr = ie_params;
4653 msg.bodyval = 0;
4654
4655 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004656 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004657 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004658 qdf_mem_free(ie_params->ie_ptr);
4659 qdf_mem_free(ie_params);
4660 return;
4661 }
4662 }
4663}
4664
4665/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004666 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4667 * @mac_ctx: Pointer to Global MAC structure
4668 * @msg_buf: Pointer to the SME message buffer
4669 *
4670 * This function is called by limProcessMessageQueue(). This function sets the
4671 * VDEV IEs to the FW.
4672 *
4673 * Return: None
4674 */
4675static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4676 uint32_t *msg_buf)
4677{
4678 struct sir_set_vdev_ies_per_band *p_msg =
4679 (struct sir_set_vdev_ies_per_band *)msg_buf;
4680
4681 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004682 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004683 return;
4684 }
4685
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004686 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004687 p_msg->vdev_id);
4688 /* intentionally using NULL here so that self capabilty are sent */
4689 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4690 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004691 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004692}
4693
4694/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004695 * lim_process_set_pdev_IEs() - process the set pdev IE req
4696 * @mac_ctx: Pointer to Global MAC structure
4697 * @msg_buf: Pointer to the SME message buffer
4698 *
4699 * This function is called by limProcessMessageQueue(). This
4700 * function sets the PDEV IEs to the FW.
4701 *
4702 * Return: None
4703 */
4704static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4705{
4706 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4707
4708 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4709
4710 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004711 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004712 return;
4713 }
4714
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004715 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004716 ht_vht_cfg->nss);
4717 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4718
4719 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4720 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4721 ht_vht_cfg->nss);
4722}
4723
4724/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304725 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4726 *
4727 * access policy
4728 * @mac_ctx: pointer to mac context
4729 * @msg: message buffer
4730 *
4731 * function processes vendor IE and access policy from SME and updates PE
4732 *
4733 * session entry
4734 *
4735 * return: none
4736*/
4737static void lim_process_sme_update_access_policy_vendor_ie(
4738 tpAniSirGlobal mac_ctx,
4739 uint32_t *msg)
4740{
4741 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
Jeff Johnson0f99bd82018-11-18 18:42:12 -08004742 struct pe_session *pe_session_entry;
Pragaspathi Thilagaraj9b7a1162018-05-07 16:28:13 +05304743 uint16_t num_bytes;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304744
4745 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004746 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304747 return;
4748 }
4749 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4750 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4751 update_vendor_ie->sme_session_id);
4752
4753 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004754 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304755 update_vendor_ie->sme_session_id);
4756 return;
4757 }
4758 if (pe_session_entry->access_policy_vendor_ie)
4759 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4760
4761 num_bytes = update_vendor_ie->ie[1] + 2;
4762 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
Arif Hussainf5b6c412018-10-10 19:41:09 -07004763 if (!pe_session_entry->access_policy_vendor_ie)
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304764 return;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304765 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4766 &update_vendor_ie->ie[0], num_bytes);
4767
4768 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4769}
4770
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004771#ifdef CONFIG_VDEV_SM
4772QDF_STATUS lim_sta_mlme_vdev_disconnect_bss(struct vdev_mlme_obj *vdev_mlme,
4773 uint16_t data_len, void *data)
4774{
4775 tpAniSirGlobal mac_ctx;
4776 struct scheduler_msg *msg = (struct scheduler_msg *)data;
4777
4778 mac_ctx = cds_get_context(QDF_MODULE_ID_PE);
4779 if (!mac_ctx) {
4780 pe_err("mac_ctx is NULL");
4781 if (data)
4782 qdf_mem_free(data);
4783 return QDF_STATUS_E_INVAL;
4784 }
4785 pe_debug("VDEV Manager disconnect bss callback type:(%d)", msg->type);
4786
4787 switch (msg->type) {
4788 case eWNI_SME_DEAUTH_REQ:
4789 __lim_process_sme_deauth_req(mac_ctx,
4790 (uint32_t *)msg->bodyptr);
4791 break;
4792 case eWNI_SME_DISASSOC_CNF:
4793 case eWNI_SME_DEAUTH_CNF:
4794 __lim_process_sme_disassoc_cnf(mac_ctx,
4795 (uint32_t *)msg->bodyptr);
4796 break;
4797 case eWNI_SME_DISASSOC_REQ:
4798 __lim_process_sme_disassoc_req(mac_ctx,
4799 (uint32_t *)msg->bodyptr);
4800 break;
4801 default:
4802 pe_debug("Wrong message type received %d", msg->type);
4803 }
4804 return QDF_STATUS_SUCCESS;
4805}
4806#endif
4807
4808static void lim_process_sme_disassoc_cnf(tpAniSirGlobal mac_ctx,
4809 struct scheduler_msg *msg)
4810{
4811#ifdef CONFIG_VDEV_SM
4812 tSirSmeDisassocCnf sme_disassoc_cnf;
4813 tpPESession session;
4814 uint8_t session_id;
4815 QDF_STATUS status;
4816
4817 qdf_mem_copy(&sme_disassoc_cnf, msg->bodyptr,
4818 sizeof(struct sSirSmeDisassocCnf));
4819
4820 session = pe_find_session_by_bssid(mac_ctx,
4821 sme_disassoc_cnf.bssid.bytes,
4822 &session_id);
4823
4824 if (LIM_IS_STA_ROLE(session)) {
4825 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4826 WLAN_VDEV_SM_EV_DOWN,
4827 sizeof(*msg),
4828 msg);
4829 } else {
4830 __lim_process_sme_disassoc_cnf(mac_ctx,
4831 (uint32_t *)msg->bodyptr);
4832 }
4833#else
4834 __lim_process_sme_disassoc_cnf(mac_ctx, (uint32_t *)msg->bodyptr);
4835#endif
4836}
4837
4838static void lim_process_sme_disassoc_req(tpAniSirGlobal mac_ctx,
4839 struct scheduler_msg *msg)
4840{
4841#ifdef CONFIG_VDEV_SM
4842 tSirSmeDisassocReq disassoc_req;
4843 tpPESession session;
4844 uint8_t session_id;
4845 QDF_STATUS status;
4846
4847 qdf_mem_copy(&disassoc_req, msg->bodyptr, sizeof(tSirSmeDisassocReq));
4848
4849 session = pe_find_session_by_bssid(mac_ctx,
4850 disassoc_req.bssid.bytes,
4851 &session_id);
4852 if (LIM_IS_STA_ROLE(session)) {
4853 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4854 WLAN_VDEV_SM_EV_DOWN,
4855 sizeof(*msg),
4856 msg);
4857 } else {
4858 __lim_process_sme_disassoc_req(mac_ctx,
4859 (uint32_t *)msg->bodyptr);
4860 }
4861#else
4862 __lim_process_sme_disassoc_req(mac_ctx, (uint32_t *)msg->bodyptr);
4863#endif
4864}
4865
4866static void lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
4867 struct scheduler_msg *msg)
4868{
4869#ifdef CONFIG_VDEV_SM
4870 tSirSmeDeauthReq sme_deauth_req;
4871 tpPESession session;
4872 uint8_t session_id;
4873 QDF_STATUS status;
4874
4875 qdf_mem_copy(&sme_deauth_req, msg->bodyptr, sizeof(tSirSmeDeauthReq));
4876
4877 session = pe_find_session_by_bssid(mac_ctx,
4878 sme_deauth_req.bssid.bytes,
4879 &session_id);
4880 if (LIM_IS_STA_ROLE(session)) {
4881 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4882 WLAN_VDEV_SM_EV_DOWN,
4883 sizeof(*msg),
4884 msg);
4885 } else {
4886 __lim_process_sme_deauth_req(mac_ctx,
4887 (uint32_t *)msg->bodyptr);
4888 }
4889#else
4890 __lim_process_sme_deauth_req(mac_ctx, (uint32_t *)msg->bodyptr);
4891#endif
4892}
4893
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304894/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004895 * lim_process_sme_req_messages()
4896 *
4897 ***FUNCTION:
4898 * This function is called by limProcessMessageQueue(). This
4899 * function processes SME request messages from HDD or upper layer
4900 * application.
4901 *
4902 ***LOGIC:
4903 *
4904 ***ASSUMPTIONS:
4905 *
4906 ***NOTE:
4907 *
4908 * @param pMac Pointer to Global MAC structure
4909 * @param msgType Indicates the SME message type
4910 * @param *pMsgBuf A pointer to the SME message buffer
4911 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4912 * false - if pMsgBuf is not to be freed.
4913 */
4914
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004915bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4916 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004917{
Jeff Johnson33142e62018-05-06 17:58:36 -07004918 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 -08004919 uint32_t *pMsgBuf = pMsg->bodyptr;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004920
4921 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004922 lim_msg_str(pMsg->type), pMsg->type,
4923 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4924 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004925
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004926 /* If no insert NOA required then execute the code below */
4927
4928 switch (pMsg->type) {
4929 case eWNI_SME_SYS_READY_IND:
4930 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4931 break;
4932
4933 case eWNI_SME_START_BSS_REQ:
4934 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4935 break;
4936
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004937 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4938 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4939 break;
4940 case eWNI_SME_JOIN_REQ:
4941 __lim_process_sme_join_req(pMac, pMsgBuf);
4942 break;
4943
4944 case eWNI_SME_REASSOC_REQ:
4945 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4946 break;
4947
4948 case eWNI_SME_DISASSOC_REQ:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004949 lim_process_sme_disassoc_req(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004950 break;
4951
4952 case eWNI_SME_DISASSOC_CNF:
4953 case eWNI_SME_DEAUTH_CNF:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004954 lim_process_sme_disassoc_cnf(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004955 break;
4956
4957 case eWNI_SME_DEAUTH_REQ:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004958 lim_process_sme_deauth_req(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004959 break;
4960
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304961 case eWNI_SME_SEND_DISASSOC_FRAME:
4962 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4963 break;
4964
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004965 case eWNI_SME_SETCONTEXT_REQ:
4966 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4967 break;
4968
4969 case eWNI_SME_STOP_BSS_REQ:
4970 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4971 break;
4972
4973 case eWNI_SME_ASSOC_CNF:
4974 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004975 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004976 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4977 pMsgBuf);
4978 break;
4979
4980 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004981 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004982 __lim_process_sme_addts_req(pMac, pMsgBuf);
4983 break;
4984
4985 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004986 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004987 __lim_process_sme_delts_req(pMac, pMsgBuf);
4988 break;
4989
4990 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004991 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004992 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4993 break;
4994
4995 case eWNI_SME_GET_STATISTICS_REQ:
4996 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4997 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4998 bufConsumed = false;
4999 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005000#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005001 case eWNI_SME_GET_TSM_STATS_REQ:
5002 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5003 bufConsumed = false;
5004 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005005#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005006 case eWNI_SME_GET_ASSOC_STAS_REQ:
5007 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5008 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05305009 case eWNI_SME_SESSION_UPDATE_PARAM:
5010 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005011 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05305012 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
5013 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
5014 bufConsumed = false;
5015 break;
Paul Zhang624f88d2018-11-07 15:29:45 +08005016 case eWNI_SME_ROAM_INVOKE:
5017 lim_process_roam_invoke(pMac, pMsgBuf);
5018 bufConsumed = false;
5019 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005020 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5021 /* Update the beaconInterval */
5022 __lim_process_sme_change_bi(pMac, pMsgBuf);
5023 break;
5024
5025#ifdef QCA_HT_2040_COEX
5026 case eWNI_SME_SET_HT_2040_MODE:
5027 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5028 break;
5029#endif
5030
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005031 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5032 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5033 __lim_process_report_message(pMac, pMsg);
5034 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005035
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005036 case eWNI_SME_FT_PRE_AUTH_REQ:
5037 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5038 break;
5039 case eWNI_SME_FT_UPDATE_KEY:
5040 lim_process_ft_update_key(pMac, pMsgBuf);
5041 break;
5042
5043 case eWNI_SME_FT_AGGR_QOS_REQ:
5044 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5045 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005046
5047 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5048 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5049 break;
5050#ifdef FEATURE_WLAN_TDLS
5051 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5052 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5053 break;
5054 case eWNI_SME_TDLS_ADD_STA_REQ:
5055 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5056 break;
5057 case eWNI_SME_TDLS_DEL_STA_REQ:
5058 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5059 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005060#endif
5061 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5062 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5063 break;
5064
5065 case eWNI_SME_CHANNEL_CHANGE_REQ:
5066 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5067 break;
5068
5069 case eWNI_SME_START_BEACON_REQ:
5070 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5071 break;
5072
5073 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5074 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5075 break;
5076
5077 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5078 lim_process_update_add_ies(pMac, pMsgBuf);
5079 break;
5080
5081 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5082 lim_process_modify_add_ies(pMac, pMsgBuf);
5083 break;
5084 case eWNI_SME_SET_HW_MODE_REQ:
5085 lim_process_set_hw_mode(pMac, pMsgBuf);
5086 break;
5087 case eWNI_SME_NSS_UPDATE_REQ:
5088 lim_process_nss_update_request(pMac, pMsgBuf);
5089 break;
5090 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5091 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5092 break;
5093 case eWNI_SME_SET_IE_REQ:
5094 lim_process_set_ie_req(pMac, pMsgBuf);
5095 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305096 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5097 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5098 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305099 case eWNI_SME_EXT_CHANGE_CHANNEL:
5100 lim_process_ext_change_channel(pMac, pMsgBuf);
5101 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005102 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5103 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5104 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005105 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5106 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005107 break;
5108 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5109 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5110 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305111 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5112 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5113 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07005114 case eWNI_SME_UPDATE_CONFIG:
5115 lim_process_sme_update_config(pMac,
5116 (struct update_config *)pMsgBuf);
5117 break;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08005118 case eWNI_SME_SET_ADDBA_ACCEPT:
5119 lim_process_sme_set_addba_accept(pMac,
5120 (struct sme_addba_accept *)pMsgBuf);
5121 break;
Arif Hussaineb8ba362018-03-07 19:15:13 -08005122 case eWNI_SME_UPDATE_EDCA_PROFILE:
5123 lim_process_sme_update_edca_params(pMac, pMsg->bodyval);
5124 break;
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07005125 case WNI_SME_UPDATE_MU_EDCA_PARAMS:
5126 lim_process_sme_update_mu_edca_params(pMac, pMsg->bodyval);
5127 break;
Kiran Kumar Lokereee205772018-09-27 00:27:27 -07005128 case WNI_SME_CFG_ACTION_FRM_HE_TB_PPDU:
5129 lim_process_sme_cfg_action_frm_in_tb_ppdu(pMac,
5130 (struct sir_cfg_action_frm_tb_ppdu *)pMsgBuf);
5131 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005132 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305133 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005134 pMsg->bodyptr = NULL;
5135 break;
5136 } /* switch (msgType) */
5137
5138 return bufConsumed;
5139} /*** end lim_process_sme_req_messages() ***/
5140
5141/**
5142 * lim_process_sme_start_beacon_req()
5143 *
5144 ***FUNCTION:
5145 * This function is called by limProcessMessageQueue(). This
5146 * function processes SME request messages from HDD or upper layer
5147 * application.
5148 *
5149 ***LOGIC:
5150 *
5151 ***ASSUMPTIONS:
5152 *
5153 ***NOTE:
5154 *
5155 * @param pMac Pointer to Global MAC structure
5156 * @param msgType Indicates the SME message type
5157 * @param *pMsgBuf A pointer to the SME message buffer
5158 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5159 * false - if pMsgBuf is not to be freed.
5160 */
5161static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5162{
5163 tpSirStartBeaconIndication pBeaconStartInd;
5164 tpPESession psessionEntry;
5165 uint8_t sessionId; /* PE sessionID */
5166
5167 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005168 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005169 return;
5170 }
5171
5172 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5173 psessionEntry = pe_find_session_by_bssid(pMac,
5174 pBeaconStartInd->bssid,
5175 &sessionId);
5176 if (psessionEntry == NULL) {
5177 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005178 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005179 return;
5180 }
5181
5182 if (pBeaconStartInd->beaconStartStatus == true) {
5183 /*
5184 * Currently this Indication comes from SAP
5185 * to start Beacon Tx on a DFS channel
5186 * since beaconing has to be done on DFS
5187 * channel only after CAC WAIT is completed.
5188 * On a DFS Channel LIM does not start beacon
5189 * Tx right after the WMA_ADD_BSS_RSP.
5190 */
5191 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05305192 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005193 FL("Start Beacon with ssid %s Ch %d"),
5194 psessionEntry->ssId.ssId,
5195 psessionEntry->currentOperChannel);
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05305196 lim_send_beacon(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08005197 lim_enable_obss_detection_config(pMac, psessionEntry);
Arif Hussain05fb4872018-01-03 16:02:55 -08005198 lim_send_obss_color_collision_cfg(pMac, psessionEntry,
5199 OBSS_COLOR_COLLISION_DETECTION);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005200 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005201 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005202 return;
5203 }
5204}
5205
5206/**
5207 * lim_process_sme_channel_change_request() - process sme ch change req
5208 *
5209 * @mac_ctx: Pointer to Global MAC structure
5210 * @msg_buf: pointer to the SME message buffer
5211 *
5212 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5213 *
5214 * Return: None
5215 */
5216static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5217 uint32_t *msg_buf)
5218{
5219 tpSirChanChangeRequest ch_change_req;
5220 tpPESession session_entry;
5221 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005222 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005223 uint32_t val = 0;
5224
5225 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005226 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005227 return;
5228 }
5229 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5230
5231 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5232 ch_change_req->targetChannel);
5233
5234 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5235 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005236 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005237 return;
5238 }
5239
5240 session_entry = pe_find_session_by_bssid(mac_ctx,
5241 ch_change_req->bssid, &session_id);
5242 if (session_entry == NULL) {
5243 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005244 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005245 return;
5246 }
5247
Manjunathappa Prakash34fda792018-02-07 18:23:42 -08005248 if ((session_entry->currentOperChannel ==
5249 ch_change_req->targetChannel) &&
5250 (session_entry->ch_width == ch_change_req->ch_width)) {
5251 pe_err("Target channel and mode is same as current channel and mode channel %d and mode %d",
5252 session_entry->currentOperChannel, session_entry->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005253 return;
5254 }
5255
5256 if (LIM_IS_AP_ROLE(session_entry))
5257 session_entry->channelChangeReasonCode =
5258 LIM_SWITCH_CHANNEL_SAP_DFS;
5259 else
5260 session_entry->channelChangeReasonCode =
5261 LIM_SWITCH_CHANNEL_OPERATION;
5262
Bala Venkateshb39ed152017-12-26 19:35:27 +05305263 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d, nw_type %d, dot11mode %d",
5264 session_entry->currentOperChannel,
5265 ch_change_req->targetChannel,
5266 ch_change_req->ch_width,
5267 ch_change_req->nw_type,
5268 ch_change_req->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005269
5270 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005271 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005272 session_entry->ch_center_freq_seg0 =
5273 ch_change_req->center_freq_seg_0;
5274 session_entry->ch_center_freq_seg1 =
5275 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005276 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005277 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005278 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005279 session_entry->htRecommendedTxWidthSet =
5280 session_entry->htSupportedChannelWidthSet;
5281 session_entry->currentOperChannel =
5282 ch_change_req->targetChannel;
5283 session_entry->limRFBand =
5284 lim_get_rf_band(session_entry->currentOperChannel);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305285 session_entry->cac_duration_ms = ch_change_req->cac_duration_ms;
5286 session_entry->dfs_regdomain = ch_change_req->dfs_regdomain;
5287 session_entry->maxTxPower = max_tx_pwr;
Vignesh Viswanathan153ae932018-04-11 14:24:13 +05305288
5289 /* Update the global beacon filter */
5290 lim_update_bcn_probe_filter(mac_ctx, session_entry);
5291
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005292 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08005293 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005294 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005295 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005296 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005297 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005298 }
5299
5300 session_entry->lim11hEnable = val;
5301 session_entry->dot11mode = ch_change_req->dot11mode;
Bala Venkateshb39ed152017-12-26 19:35:27 +05305302 session_entry->nwType = ch_change_req->nw_type;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305303 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005304 &ch_change_req->operational_rateset,
5305 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305306 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005307 &ch_change_req->extended_rateset,
5308 sizeof(session_entry->extRateSet));
Abhishek Singh20a8e442018-09-12 15:50:44 +05305309
5310#ifdef CONFIG_VDEV_SM
Abhishek Singha063f1c2018-09-19 11:37:51 +05305311 mlme_set_chan_switch_in_progress(session_entry->vdev, true);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305312 if (wlan_vdev_mlme_get_state(session_entry->vdev) ==
5313 WLAN_VDEV_S_DFS_CAC_WAIT)
5314 wlan_vdev_mlme_sm_deliver_evt(session_entry->vdev,
5315 WLAN_VDEV_SM_EV_RADAR_DETECTED,
5316 sizeof(*session_entry),
5317 session_entry);
5318 else
5319 wlan_vdev_mlme_sm_deliver_evt(session_entry->vdev,
5320 WLAN_VDEV_SM_EV_CSA_COMPLETE,
5321 sizeof(*session_entry),
5322 session_entry);
5323
5324
5325#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005326 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5327 session_entry->ch_center_freq_seg0,
5328 session_entry->ch_center_freq_seg1,
5329 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07005330 max_tx_pwr, session_entry->peSessionId,
5331 ch_change_req->cac_duration_ms,
5332 ch_change_req->dfs_regdomain);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305333#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005334}
5335
5336/******************************************************************************
5337* lim_start_bss_update_add_ie_buffer()
5338*
5339***FUNCTION:
5340* This function checks the src buffer and its length and then malloc for
5341* dst buffer update the same
5342*
5343***LOGIC:
5344*
5345***ASSUMPTIONS:
5346*
5347***NOTE:
5348*
5349* @param pMac Pointer to Global MAC structure
5350* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5351* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5352* @param *pSrcData_buff A pointer of uint8_t src buffer
5353* @param srcDataLen src buffer length
5354******************************************************************************/
5355
5356static void
5357lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5358 uint8_t **pDstData_buff,
5359 uint16_t *pDstDataLen,
5360 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5361{
5362
5363 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5364 *pDstDataLen = srcDataLen;
5365
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305366 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -07005367 if (!*pDstData_buff)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005368 return;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305369 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005370 } else {
5371 *pDstData_buff = NULL;
5372 *pDstDataLen = 0;
5373 }
5374}
5375
5376/******************************************************************************
5377* lim_update_add_ie_buffer()
5378*
5379***FUNCTION:
5380* This function checks the src buffer and length if src buffer length more
5381* than dst buffer length then free the dst buffer and malloc for the new src
5382* length, and update the dst buffer and length. But if dst buffer is bigger
5383* than src buffer length then it just update the dst buffer and length
5384*
5385***LOGIC:
5386*
5387***ASSUMPTIONS:
5388*
5389***NOTE:
5390*
5391* @param pMac Pointer to Global MAC structure
5392* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5393* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5394* @param *pSrcData_buff A pointer of uint8_t src buffer
5395* @param srcDataLen src buffer length
5396******************************************************************************/
5397
5398static void
5399lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5400 uint8_t **pDstData_buff,
5401 uint16_t *pDstDataLen,
5402 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5403{
5404
5405 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005406 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005407 return;
5408 }
5409
5410 if (srcDataLen > *pDstDataLen) {
5411 *pDstDataLen = srcDataLen;
5412 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305413 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005414 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305415 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -07005416 if (!*pDstData_buff) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005417 *pDstDataLen = 0;
5418 return;
5419 }
5420 }
5421
5422 /* copy the content of buffer into dst buffer
5423 */
5424 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305425 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005426
5427}
5428
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005429/**
5430 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5431 * @pMac : Pointer to Global MAC structure
5432 * @pDstData_buff : A pointer to pointer of dst buffer
5433 * @pDstDataLen : A pointer to pointer of dst buffer length
5434 * @pModifyIE : A pointer to tSirModifyIE
5435 *
5436 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5437 *
5438 * Return:
5439 * True or false depending upon whether IE is updated or not
5440 */
5441static bool
5442lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5443 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5444{
Hong Shi1553d692016-09-28 12:16:19 +08005445 int32_t oui_length;
5446 uint8_t *ibss_ie = NULL;
5447 uint8_t *vendor_ie;
5448#define MAC_VENDOR_OUI "\x00\x16\x32"
5449#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005450
5451 ibss_ie = pModifyIE->pIEBuffer;
5452 oui_length = pModifyIE->oui_length;
5453
5454 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005455 pe_err("Invalid set IBSS vendor IE command length %d",
5456 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005457 return false;
5458 }
5459
Hong Shi1553d692016-09-28 12:16:19 +08005460 /*
5461 * Why replace only beacon OUI data here:
5462 * 1. other ie (such as wpa) shall not be overwritten here.
5463 * 2. per spec, beacon oui ie might be set twice and original one
5464 * shall be updated.
5465 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005466 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005467 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5468 if (vendor_ie) {
5469 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5470 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5471 pModifyIE->ieBufferlength);
5472 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005473 uint16_t new_length;
5474 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005475
Naveen Rawat668dee32017-09-29 14:39:40 -07005476 /*
5477 * check for uint16 overflow before using sum of two numbers as
5478 * length of size to malloc
5479 */
5480 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5481 pe_err("U16 overflow due to %d + %d",
5482 pModifyIE->ieBufferlength, *pDstDataLen);
5483 return false;
5484 }
5485
5486 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5487 new_ptr = qdf_mem_malloc(new_length);
Arif Hussainf5b6c412018-10-10 19:41:09 -07005488 if (!new_ptr)
Hong Shi1553d692016-09-28 12:16:19 +08005489 return false;
Hong Shi1553d692016-09-28 12:16:19 +08005490 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5491 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5492 pModifyIE->ieBufferlength);
5493 qdf_mem_free(*pDstData_buff);
5494 *pDstDataLen = new_length;
5495 *pDstData_buff = new_ptr;
5496 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005497 return true;
5498}
5499
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005500/*
5501* lim_process_modify_add_ies() - process modify additional IE req.
5502*
5503* @mac_ctx: Pointer to Global MAC structure
5504* @msg_buf: pointer to the SME message buffer
5505*
5506* This function update the PE buffers for additional IEs.
5507*
5508* Return: None
5509*/
5510static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5511 uint32_t *msg_buf)
5512{
5513 tpSirModifyIEsInd modify_add_ies;
5514 tpPESession session_entry;
5515 uint8_t session_id;
5516 bool ret = false;
5517 tSirAddIeParams *add_ie_params;
5518
5519 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005520 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005521 return;
5522 }
5523
5524 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5525 /* Incoming message has smeSession, use BSSID to find PE session */
5526 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005527 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005528
5529 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005530 pe_err("Session not found for given bssid"
5531 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005532 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005533 goto end;
5534 }
5535 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5536 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5537 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005538 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005539 modify_add_ies->modifyIE.pIEBuffer,
5540 modify_add_ies->modifyIE.ieBufferlength,
5541 modify_add_ies->modifyIE.ieID,
5542 modify_add_ies->modifyIE.ieIDLen,
5543 modify_add_ies->updateType);
5544 goto end;
5545 }
5546 add_ie_params = &session_entry->addIeParams;
5547 switch (modify_add_ies->updateType) {
5548 case eUPDATE_IE_PROBE_RESP:
5549 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005550 if (LIM_IS_IBSS_ROLE(session_entry)) {
5551 lim_update_ibss_prop_add_ies(mac_ctx,
5552 &add_ie_params->probeRespData_buff,
5553 &add_ie_params->probeRespDataLen,
5554 &modify_add_ies->modifyIE);
5555 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005556 break;
5557 case eUPDATE_IE_ASSOC_RESP:
5558 /* assoc resp IE */
5559 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305560 QDF_TRACE(QDF_MODULE_ID_PE,
5561 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005562 "assoc resp add ie not present %d"),
5563 add_ie_params->assocRespDataLen);
5564 }
5565 /* search through the buffer and modify the IE */
5566 break;
5567 case eUPDATE_IE_PROBE_BCN:
5568 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005569 if (LIM_IS_IBSS_ROLE(session_entry)) {
5570 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5571 &add_ie_params->probeRespBCNData_buff,
5572 &add_ie_params->probeRespBCNDataLen,
5573 &modify_add_ies->modifyIE);
5574 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005575 if (ret == true && modify_add_ies->modifyIE.notify) {
5576 lim_handle_param_update(mac_ctx,
5577 modify_add_ies->updateType);
5578 }
5579 break;
5580 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005581 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005582 modify_add_ies->updateType);
5583 break;
5584 }
5585end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305586 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005587 modify_add_ies->modifyIE.pIEBuffer = NULL;
5588}
5589
5590/*
5591* lim_process_update_add_ies() - process additional IE update req
5592*
5593* @mac_ctx: Pointer to Global MAC structure
5594* @msg_buf: pointer to the SME message buffer
5595*
5596* This function update the PE buffers for additional IEs.
5597*
5598* Return: None
5599*/
5600static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5601 uint32_t *msg_buf)
5602{
5603 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5604 uint8_t session_id;
5605 tpPESession session_entry;
5606 tSirAddIeParams *addn_ie;
5607 uint16_t new_length = 0;
5608 uint8_t *new_ptr = NULL;
5609 tSirUpdateIE *update_ie;
5610
5611 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005612 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005613 return;
5614 }
5615 update_ie = &update_add_ies->updateIE;
5616 /* incoming message has smeSession, use BSSID to find PE session */
5617 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005618 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005619
5620 if (NULL == session_entry) {
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05305621 pe_debug("Session not found for given bssid"
5622 MAC_ADDRESS_STR,
5623 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005624 goto end;
5625 }
5626 addn_ie = &session_entry->addIeParams;
5627 /* if len is 0, upper layer requested freeing of buffer */
5628 if (0 == update_ie->ieBufferlength) {
5629 switch (update_add_ies->updateType) {
5630 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305631 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005632 addn_ie->probeRespData_buff = NULL;
5633 addn_ie->probeRespDataLen = 0;
5634 break;
5635 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305636 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005637 addn_ie->assocRespData_buff = NULL;
5638 addn_ie->assocRespDataLen = 0;
5639 break;
5640 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305641 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005642 addn_ie->probeRespBCNData_buff = NULL;
5643 addn_ie->probeRespBCNDataLen = 0;
5644
5645 if (update_ie->notify)
5646 lim_handle_param_update(mac_ctx,
5647 update_add_ies->updateType);
5648 break;
5649 default:
5650 break;
5651 }
5652 return;
5653 }
5654 switch (update_add_ies->updateType) {
5655 case eUPDATE_IE_PROBE_RESP:
5656 if (update_ie->append) {
5657 /*
5658 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005659 * with combined length.
5660 * Multiple back to back append commands
5661 * can lead to a huge length.So, check
5662 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005663 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005664 if (addn_ie->probeRespDataLen >
5665 (USHRT_MAX - update_ie->ieBufferlength)) {
5666 pe_err("IE Length overflow, curr:%d, new:%d",
5667 addn_ie->probeRespDataLen,
5668 update_ie->ieBufferlength);
5669 goto end;
5670 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005671 new_length = update_ie->ieBufferlength +
5672 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305673 new_ptr = qdf_mem_malloc(new_length);
Arif Hussainf5b6c412018-10-10 19:41:09 -07005674 if (!new_ptr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005675 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005676 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305677 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005678 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305679 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005680 update_ie->pAdditionIEBuffer,
5681 update_ie->ieBufferlength);
5682 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305683 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005684 /* adjust length accordingly */
5685 addn_ie->probeRespDataLen = new_length;
5686 /* save refernece of local buffer in PE session */
5687 addn_ie->probeRespData_buff = new_ptr;
5688 goto end;
5689 }
5690 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5691 &addn_ie->probeRespDataLen,
5692 update_ie->pAdditionIEBuffer,
5693 update_ie->ieBufferlength);
5694 break;
5695 case eUPDATE_IE_ASSOC_RESP:
5696 /* assoc resp IE */
5697 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5698 &addn_ie->assocRespDataLen,
5699 update_ie->pAdditionIEBuffer,
5700 update_ie->ieBufferlength);
5701 break;
5702 case eUPDATE_IE_PROBE_BCN:
5703 /* probe resp Bcn IE */
5704 lim_update_add_ie_buffer(mac_ctx,
5705 &addn_ie->probeRespBCNData_buff,
5706 &addn_ie->probeRespBCNDataLen,
5707 update_ie->pAdditionIEBuffer,
5708 update_ie->ieBufferlength);
5709 if (update_ie->notify)
5710 lim_handle_param_update(mac_ctx,
5711 update_add_ies->updateType);
5712 break;
5713 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005714 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005715 break;
5716 }
5717end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305718 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005719 update_ie->pAdditionIEBuffer = NULL;
5720}
5721
5722/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305723 * send_extended_chan_switch_action_frame()- function to send ECSA
5724 * action frame for each sta connected to SAP/GO and AP in case of
5725 * STA .
5726 * @mac_ctx: pointer to global mac structure
5727 * @new_channel: new channel to switch to.
5728 * @ch_bandwidth: BW of channel to calculate op_class
5729 * @session_entry: pe session
5730 *
5731 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5732 *
5733 * Return: void
5734 */
5735
5736static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5737 uint16_t new_channel, uint8_t ch_bandwidth,
5738 tpPESession session_entry)
5739{
5740 uint16_t op_class;
5741 uint8_t switch_mode = 0, i;
5742 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005743 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305744
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005745 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305746 mac_ctx->scan.countryCodeCurrent,
5747 new_channel,
5748 ch_bandwidth);
5749
5750 if (LIM_IS_AP_ROLE(session_entry) &&
5751 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005752 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305753
gaoleze2920bd2017-03-21 17:38:42 +08005754 switch_count = session_entry->gLimChannelSwitch.switchCount;
5755
Abhishek Singh518323d2015-10-19 17:42:01 +05305756 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005757 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305758 psta =
5759 session_entry->dph.dphHashTable.pDphNodeArray + i;
5760 if (psta && psta->added)
5761 lim_send_extended_chan_switch_action_frame(
5762 mac_ctx,
5763 psta->staAddr,
5764 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005765 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305766 }
5767 } else if (LIM_IS_STA_ROLE(session_entry)) {
5768 lim_send_extended_chan_switch_action_frame(mac_ctx,
5769 session_entry->bssId,
5770 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005771 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305772 }
5773
5774}
5775
gaolez76d2a162017-03-21 19:23:58 +08005776void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5777 uint16_t new_channel,
5778 uint8_t ch_bandwidth,
5779 tpPESession session_entry)
5780{
5781 uint16_t op_class;
5782 uint8_t switch_mode = 0, i;
5783 uint8_t switch_count;
5784 tpDphHashNode psta;
5785 tpDphHashNode dph_node_array_ptr;
5786
5787 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5788
5789 op_class = wlan_reg_dmn_get_opclass_from_channel(
5790 mac_ctx->scan.countryCodeCurrent,
5791 new_channel, ch_bandwidth);
5792
5793 if (LIM_IS_AP_ROLE(session_entry) &&
5794 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5795 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5796
5797 switch_count = session_entry->gLimChannelSwitch.switchCount;
5798
5799 if (LIM_IS_AP_ROLE(session_entry)) {
5800 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5801 psta = dph_node_array_ptr + i;
5802 if (!(psta && psta->added))
5803 continue;
5804 if (session_entry->lim_non_ecsa_cap_num == 0)
5805 lim_send_extended_chan_switch_action_frame
5806 (mac_ctx, psta->staAddr, switch_mode,
5807 op_class, new_channel, switch_count,
5808 session_entry);
5809 else
5810 lim_send_channel_switch_mgmt_frame
5811 (mac_ctx, psta->staAddr, switch_mode,
5812 new_channel, switch_count,
5813 session_entry);
5814 }
5815 } else if (LIM_IS_STA_ROLE(session_entry)) {
5816 lim_send_extended_chan_switch_action_frame
5817 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5818 new_channel, switch_count, session_entry);
5819 }
5820}
5821
5822/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005823 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5824 *
5825 * @mac_ctx: Pointer to Global MAC structure
5826 * @msg_buf: pointer to the SME message buffer
5827 *
5828 * This function processes SME request messages from HDD or upper layer
5829 * application.
5830 *
5831 * Return: None
5832 */
5833static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5834 uint32_t *msg_buf)
5835{
5836 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5837 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005838 uint8_t session_id;
5839 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005840 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005841
5842 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005843 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005844 return;
5845 }
5846
5847 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5848 session_entry = pe_find_session_by_bssid(mac_ctx,
5849 dfs_csa_ie_req->bssid, &session_id);
5850 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005851 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005852 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5853 return;
5854 }
5855
5856 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005857 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005858 GET_LIM_SYSTEM_ROLE(session_entry));
5859 return;
5860 }
5861
5862 /* target channel */
5863 session_entry->gLimChannelSwitch.primaryChannel =
5864 dfs_csa_ie_req->targetChannel;
5865
5866 /* Channel switch announcement needs to be included in beacon */
5867 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005868 session_entry->gLimChannelSwitch.switchCount =
5869 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005870 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005871 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305872 session_entry->gLimChannelSwitch.sec_ch_offset =
5873 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005874 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005875 session_entry->gLimChannelSwitch.switchMode =
5876 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005877
5878 /*
5879 * Validate if SAP is operating HT or VHT mode and set the Channel
5880 * Switch Wrapper element with the Wide Band Switch subelement.
5881 */
5882 if (true != session_entry->vhtCapability)
5883 goto skip_vht;
5884
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005885 /* Now encode the Wider Ch BW element depending on the ch width */
5886 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005887 switch (dfs_csa_ie_req->ch_params.ch_width) {
5888 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005889 /*
5890 * Wide channel BW sublement in channel wrapper element is not
5891 * required in case of 20 Mhz operation. Currently It is set
5892 * only set in case of 40/80 Mhz Operation.
5893 */
5894 session_entry->dfsIncludeChanWrapperIe = false;
5895 wider_bw_ch_switch->newChanWidth =
5896 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5897 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005898 case CH_WIDTH_40MHZ:
5899 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005900 wider_bw_ch_switch->newChanWidth =
5901 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5902 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005903 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005904 session_entry->dfsIncludeChanWrapperIe = true;
5905 wider_bw_ch_switch->newChanWidth =
5906 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5907 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005908 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005909 session_entry->dfsIncludeChanWrapperIe = true;
5910 wider_bw_ch_switch->newChanWidth =
5911 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5912 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005913 case CH_WIDTH_80P80MHZ:
5914 session_entry->dfsIncludeChanWrapperIe = true;
5915 wider_bw_ch_switch->newChanWidth =
5916 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005917 /*
5918 * This is not applicable for 20/40/80 Mhz.
5919 * Only used when we support 80+80 Mhz operation.
5920 * In case of 80+80 Mhz, this parameter indicates
5921 * center channel frequency index of 80 Mhz channel of
5922 * frequency segment 1.
5923 */
5924 wider_bw_ch_switch->newCenterChanFreq1 =
5925 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005926 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005927 default:
5928 session_entry->dfsIncludeChanWrapperIe = false;
5929 /*
5930 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5931 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5932 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005933 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005934 break;
5935 }
5936 /* Fetch the center channel based on the channel width */
5937 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005938 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005939skip_vht:
5940 /* Send CSA IE request from here */
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05305941 lim_send_dfs_chan_sw_ie_update(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305942
5943 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5944 ch_offset = BW80;
5945 else
5946 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5947
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005948 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305949 session_entry->gLimChannelSwitch.switchCount,
5950 session_entry->gLimChannelSwitch.primaryChannel,
5951 session_entry->gLimChannelSwitch.ch_width,
5952 session_entry->dfsIncludeChanWrapperIe,
5953 ch_offset);
5954
gaolez76d2a162017-03-21 19:23:58 +08005955 /* Send ECSA/CSA Action frame after updating the beacon */
5956 if (CHAN_HOP_ALL_BANDS_ENABLE)
5957 lim_send_chan_switch_action_frame(mac_ctx,
5958 session_entry->gLimChannelSwitch.primaryChannel,
5959 ch_offset, session_entry);
5960 else
5961 send_extended_chan_switch_action_frame(mac_ctx,
5962 session_entry->gLimChannelSwitch.primaryChannel,
5963 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005964}
5965
5966/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305967 * lim_process_ext_change_channel()- function to send ECSA
5968 * action frame for STA/CLI .
5969 * @mac_ctx: pointer to global mac structure
5970 * @msg: params from sme for new channel.
5971 *
5972 * This function is called to send ECSA frame for STA/CLI.
5973 *
5974 * Return: void
5975 */
5976
5977static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5978 uint32_t *msg)
5979{
5980 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5981 (struct sir_sme_ext_cng_chan_req *) msg;
5982 tpPESession session_entry = NULL;
5983
5984 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005985 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305986 return;
5987 }
5988 session_entry =
5989 pe_find_session_by_sme_session_id(mac_ctx,
5990 ext_chng_channel->session_id);
5991 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005992 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305993 ext_chng_channel->session_id);
5994 return;
5995 }
5996 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005997 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305998 return;
5999 }
6000 send_extended_chan_switch_action_frame(mac_ctx,
6001 ext_chng_channel->new_channel,
6002 0, session_entry);
6003}
6004
6005/**
Abhishek Singhfc740be2018-10-12 11:34:26 +05306006 * lim_nss_update_rsp() - send NSS update response to SME
6007 * @mac_ctx Pointer to Global MAC structure
6008 * @vdev_id: vdev id
6009 * @status: nss update status
6010 *
6011 * Return: None
6012 */
6013static void lim_nss_update_rsp(tpAniSirGlobal mac_ctx,
6014 uint8_t vdev_id, QDF_STATUS status)
6015{
6016 struct scheduler_msg msg = {0};
6017 struct sir_bcn_update_rsp *nss_rsp;
6018 QDF_STATUS qdf_status;
6019
6020 nss_rsp = qdf_mem_malloc(sizeof(*nss_rsp));
6021 if (!nss_rsp) {
6022 pe_err("AllocateMemory failed for nss_rsp");
6023 return;
6024 }
6025
6026 nss_rsp->vdev_id = vdev_id;
6027 nss_rsp->status = status;
6028 nss_rsp->reason = REASON_NSS_UPDATE;
6029
6030 msg.type = eWNI_SME_NSS_UPDATE_RSP;
6031 msg.bodyptr = nss_rsp;
6032 msg.bodyval = 0;
6033 qdf_status = scheduler_post_message(QDF_MODULE_ID_PE, QDF_MODULE_ID_SME,
6034 QDF_MODULE_ID_SME, &msg);
6035 if (QDF_IS_STATUS_ERROR(qdf_status)) {
6036 pe_err("Failed to post eWNI_SME_NSS_UPDATE_RSP");
6037 qdf_mem_free(nss_rsp);
6038 }
6039}
6040
6041void lim_send_bcn_rsp(tpAniSirGlobal mac_ctx, tpSendbeaconParams rsp)
6042{
6043 if (!rsp) {
6044 pe_err("rsp is NULL");
6045 return;
6046 }
6047
6048 pe_debug("Send beacon resp status %d for reason %d",
6049 rsp->status, rsp->reason);
6050
6051 if (rsp->reason == REASON_NSS_UPDATE)
6052 lim_nss_update_rsp(mac_ctx, rsp->vdev_id, rsp->status);
6053}
6054
6055/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006056 * lim_process_nss_update_request() - process sme nss update req
6057 *
6058 * @mac_ctx: Pointer to Global MAC structure
6059 * @msg_buf: pointer to the SME message buffer
6060 *
6061 * This function processes SME request messages from HDD or upper layer
6062 * application.
6063 *
6064 * Return: None
6065 */
6066static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
6067 uint32_t *msg_buf)
6068{
6069 struct sir_nss_update_request *nss_update_req_ptr;
6070 tpPESession session_entry = NULL;
Abhishek Singhfc740be2018-10-12 11:34:26 +05306071 QDF_STATUS status = QDF_STATUS_E_FAILURE;
6072 uint8_t vdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006073
Abhishek Singhfc740be2018-10-12 11:34:26 +05306074 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006075 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006076 return;
6077 }
6078
6079 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Abhishek Singhfc740be2018-10-12 11:34:26 +05306080 vdev_id = nss_update_req_ptr->vdev_id;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05306081 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006082 nss_update_req_ptr->vdev_id);
Abhishek Singhfc740be2018-10-12 11:34:26 +05306083 if (!session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006084 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006085 nss_update_req_ptr->vdev_id);
Abhishek Singhfc740be2018-10-12 11:34:26 +05306086 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006087 }
6088
6089 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006090 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006091 GET_LIM_SYSTEM_ROLE(session_entry));
Abhishek Singhfc740be2018-10-12 11:34:26 +05306092 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006093 }
6094
6095 /* populate nss field in the beacon */
6096 session_entry->gLimOperatingMode.present = 1;
6097 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05306098 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
6099
6100 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
6101 (session_entry->ch_width > CH_WIDTH_80MHZ))
6102 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
6103
Abhishek Singhfc740be2018-10-12 11:34:26 +05306104 pe_debug("ch width %d Rx NSS %d",
6105 session_entry->gLimOperatingMode.chanWidth,
6106 session_entry->gLimOperatingMode.rxNSS);
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05306107
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006108 /* Send nss update request from here */
Abhishek Singhfc740be2018-10-12 11:34:26 +05306109 status = sch_set_fixed_beacon_fields(mac_ctx, session_entry);
6110 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006111 pe_err("Unable to set op mode IE in beacon");
Abhishek Singhfc740be2018-10-12 11:34:26 +05306112 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006113 }
6114
Abhishek Singhfc740be2018-10-12 11:34:26 +05306115 status = lim_send_beacon_ind(mac_ctx, session_entry, REASON_NSS_UPDATE);
6116 if (QDF_IS_STATUS_SUCCESS(status))
6117 return;
6118
6119 pe_err("Unable to send beacon");
6120end:
6121 /*
6122 * send resp only in case of failure,
6123 * success case response will be from wma.
6124 */
6125 lim_nss_update_rsp(mac_ctx, vdev_id, status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006126}
6127
6128/**
6129 * lim_process_set_ie_req() - process sme set IE request
6130 *
6131 * @mac_ctx: Pointer to Global MAC structure
6132 * @msg_buf: pointer to the SME message buffer
6133 *
6134 * This function processes SME request messages from HDD or upper layer
6135 * application.
6136 *
6137 * Return: None
6138 */
6139static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6140{
6141 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306142 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006143
6144 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006145 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006146 return;
6147 }
6148
6149 msg = (struct send_extcap_ie *)msg_buf;
6150 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306151 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006152 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006153
6154}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006155
6156#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Arif Hussain05fb4872018-01-03 16:02:55 -08006157
6158/**
6159 * obss_color_collision_process_color_disable() - Disable bss color
6160 * @mac_ctx: Pointer to Global MAC structure
6161 * @session: pointer to session
6162 *
6163 * This function will disbale bss color.
6164 *
6165 * Return: None
6166 */
6167static void obss_color_collision_process_color_disable(tpAniSirGlobal mac_ctx,
6168 tpPESession session)
6169{
6170 tUpdateBeaconParams beacon_params;
6171
6172 if (!session) {
6173 pe_err("Invalid session");
6174 return;
6175 }
6176
6177 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6178 pe_err("Invalid SystemRole %d",
6179 GET_LIM_SYSTEM_ROLE(session));
6180 return;
6181 }
6182
6183 if (session->bss_color_changing == 1) {
6184 pe_warn("%d: color change in progress", session->smeSessionId);
6185 /* Continue color collision detection */
6186 lim_send_obss_color_collision_cfg(mac_ctx, session,
6187 OBSS_COLOR_COLLISION_DETECTION);
6188 return;
6189 }
6190
6191 if (session->he_op.bss_col_disabled == 1) {
6192 pe_warn("%d: bss color already disabled",
6193 session->smeSessionId);
6194 /* Continue free color detection */
6195 lim_send_obss_color_collision_cfg(mac_ctx, session,
6196 OBSS_COLOR_FREE_SLOT_AVAILABLE);
6197 return;
6198 }
6199
6200 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
6201 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
6202 session->he_op.bss_col_disabled = 1;
Arif Hussain05fb4872018-01-03 16:02:55 -08006203 beacon_params.bss_color_disabled = 1;
Arif Hussain2f2d3512018-03-06 12:37:03 -08006204 beacon_params.bss_color = session->he_op.bss_color;
Arif Hussain05fb4872018-01-03 16:02:55 -08006205
6206 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006207 QDF_STATUS_SUCCESS) {
Arif Hussain05fb4872018-01-03 16:02:55 -08006208 pe_err("Unable to set op mode IE in beacon");
6209 return;
6210 }
6211
6212 lim_send_beacon_params(mac_ctx, &beacon_params, session);
6213 lim_send_obss_color_collision_cfg(mac_ctx, session,
6214 OBSS_COLOR_FREE_SLOT_AVAILABLE);
6215}
6216
6217/**
6218 * obss_color_collision_process_color_change() - Process bss color change
6219 * @mac_ctx: Pointer to Global MAC structure
6220 * @session: pointer to session
6221 * @obss_color_info: obss color collision/free slot indication info
6222 *
6223 * This function selects new color ib case of bss color collision.
6224 *
6225 * Return: None
6226 */
6227static void obss_color_collision_process_color_change(tpAniSirGlobal mac_ctx,
6228 tpPESession session,
6229 struct wmi_obss_color_collision_info *obss_color_info)
6230{
6231 int i, num_bss_color = 0;
6232 uint32_t bss_color_bitmap;
6233 uint8_t bss_color_index_array[MAX_BSS_COLOR_VALUE];
6234 uint32_t rand_byte = 0;
6235 struct sir_set_he_bss_color he_bss_color;
6236 bool is_color_collision = false;
6237
6238
6239 if (session->bss_color_changing == 1) {
6240 pe_err("%d: color change in progress", session->smeSessionId);
6241 return;
6242 }
6243
6244 if (!session->he_op.bss_col_disabled) {
6245 if (session->he_op.bss_color < 32)
6246 is_color_collision = (obss_color_info->
6247 obss_color_bitmap_bit0to31 >>
6248 session->he_op.bss_color) & 0x01;
6249 else
6250 is_color_collision = (obss_color_info->
6251 obss_color_bitmap_bit32to63 >>
6252 (session->he_op.bss_color -
Arif Hussain9e8c5612018-04-12 16:35:48 -07006253 32)) & 0x01;
Arif Hussain05fb4872018-01-03 16:02:55 -08006254 if (!is_color_collision) {
6255 pe_err("%d: color collision not found, curr_color: %d",
6256 session->smeSessionId,
6257 session->he_op.bss_color);
6258 return;
6259 }
6260 }
6261
6262 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit0to31;
6263
6264 /* Skip color zero */
6265 bss_color_bitmap = bss_color_bitmap >> 1;
6266 for (i = 0; (i < 31) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
6267 if (!(bss_color_bitmap & 0x01)) {
6268 bss_color_index_array[num_bss_color] = i + 1;
6269 num_bss_color++;
6270 }
6271 bss_color_bitmap = bss_color_bitmap >> 1;
6272 }
6273
6274 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit32to63;
6275 for (i = 0; (i < 32) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
6276 if (!(bss_color_bitmap & 0x01)) {
6277 bss_color_index_array[num_bss_color] = i + 32;
6278 num_bss_color++;
6279 }
6280 bss_color_bitmap = bss_color_bitmap >> 1;
6281 }
6282
6283 if (num_bss_color) {
6284 qdf_get_random_bytes((void *) &rand_byte, 1);
6285 i = (rand_byte + qdf_mc_timer_get_system_ticks()) %
6286 num_bss_color;
6287 pe_debug("New bss color = %d", bss_color_index_array[i]);
6288 he_bss_color.session_id = obss_color_info->vdev_id;
6289 he_bss_color.bss_color = bss_color_index_array[i];
6290 lim_process_set_he_bss_color(mac_ctx,
6291 (uint32_t *)&he_bss_color);
6292 } else {
6293 pe_err("Unable to find bss color from bitmasp");
6294 if (obss_color_info->evt_type ==
6295 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY &&
6296 session->obss_color_collision_dec_evt ==
6297 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6298 /* In dot11BSSColorCollisionAPPeriod and
6299 * timer expired, time to disable bss color.
6300 */
6301 obss_color_collision_process_color_disable(mac_ctx,
6302 session);
6303 else
6304 /*
6305 * Enter dot11BSSColorCollisionAPPeriod period.
6306 */
6307 lim_send_obss_color_collision_cfg(mac_ctx, session,
6308 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY);
6309 }
6310}
6311
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006312void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6313{
6314 struct sir_set_he_bss_color *bss_color;
6315 tpPESession session_entry = NULL;
6316 tUpdateBeaconParams beacon_params;
6317
6318 if (!msg_buf) {
6319 pe_err("Buffer is Pointing to NULL");
6320 return;
6321 }
6322
6323 bss_color = (struct sir_set_he_bss_color *)msg_buf;
6324 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
6325 bss_color->session_id);
6326 if (!session_entry) {
6327 pe_err("Session not found for given session_id %d",
6328 bss_color->session_id);
6329 return;
6330 }
6331
6332 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6333 pe_err("Invalid SystemRole %d",
6334 GET_LIM_SYSTEM_ROLE(session_entry));
6335 return;
6336 }
6337
6338 if (bss_color->bss_color == session_entry->he_op.bss_color) {
6339 pe_err("No change in BSS color, current BSS color %d",
6340 bss_color->bss_color);
6341 return;
6342 }
6343 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
6344 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
6345 session_entry->he_op.bss_col_disabled = 1;
6346 session_entry->he_bss_color_change.countdown =
6347 BSS_COLOR_SWITCH_COUNTDOWN;
6348 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08006349 beacon_params.bss_color_disabled = 1;
6350 beacon_params.bss_color = session_entry->he_op.bss_color;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006351 session_entry->bss_color_changing = 1;
6352
6353 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006354 QDF_STATUS_SUCCESS) {
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006355 pe_err("Unable to set op mode IE in beacon");
6356 return;
6357 }
6358
6359 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
Arif Hussain05fb4872018-01-03 16:02:55 -08006360 lim_send_obss_color_collision_cfg(mac_ctx, session_entry,
6361 OBSS_COLOR_COLLISION_DETECTION_DISABLE);
6362}
6363
6364void lim_send_obss_color_collision_cfg(tpAniSirGlobal mac_ctx,
6365 tpPESession session,
6366 enum wmi_obss_color_collision_evt_type
6367 event_type)
6368{
6369 struct wmi_obss_color_collision_cfg_param *cfg_param;
6370 struct scheduler_msg msg = {0};
6371
6372 if (!session) {
6373 pe_err("Invalid session");
6374 return;
6375 }
6376
6377 if (!session->he_capable ||
6378 !session->is_session_obss_color_collision_det_enabled) {
6379 pe_debug("%d: obss color det not enabled, he_cap:%d, sup:%d:%d",
6380 session->smeSessionId, session->he_capable,
6381 session->is_session_obss_color_collision_det_enabled,
6382 mac_ctx->lim.global_obss_color_collision_det_offload);
6383 return;
6384 }
6385
6386 cfg_param = qdf_mem_malloc(sizeof(*cfg_param));
Arif Hussainf5b6c412018-10-10 19:41:09 -07006387 if (!cfg_param)
Arif Hussain05fb4872018-01-03 16:02:55 -08006388 return;
Arif Hussain05fb4872018-01-03 16:02:55 -08006389
6390 pe_debug("%d: sending event:%d", session->smeSessionId, event_type);
6391 qdf_mem_zero(cfg_param, sizeof(*cfg_param));
6392 cfg_param->vdev_id = session->smeSessionId;
6393 cfg_param->evt_type = event_type;
6394 if (LIM_IS_AP_ROLE(session))
6395 cfg_param->detection_period_ms =
6396 OBSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS;
6397 else
6398 cfg_param->detection_period_ms =
6399 OBSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS;
6400
6401 cfg_param->scan_period_ms = OBSS_COLOR_COLLISION_SCAN_PERIOD_MS;
6402 if (event_type == OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6403 cfg_param->free_slot_expiry_time_ms =
6404 OBSS_COLOR_COLLISION_FREE_SLOT_EXPIRY_MS;
6405
6406 msg.type = WMA_OBSS_COLOR_COLLISION_REQ;
6407 msg.bodyptr = cfg_param;
6408 msg.reserved = 0;
6409
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05306410 if (QDF_IS_STATUS_ERROR(scheduler_post_message(QDF_MODULE_ID_PE,
6411 QDF_MODULE_ID_WMA,
6412 QDF_MODULE_ID_WMA,
6413 &msg))) {
Arif Hussain05fb4872018-01-03 16:02:55 -08006414 pe_err("Failed to post WMA_OBSS_COLOR_COLLISION_REQ to WMA");
6415 qdf_mem_free(cfg_param);
6416 } else {
6417 session->obss_color_collision_dec_evt = event_type;
6418 }
6419}
6420
6421void lim_process_obss_color_collision_info(tpAniSirGlobal mac_ctx,
6422 uint32_t *msg_buf)
6423{
6424 struct wmi_obss_color_collision_info *obss_color_info;
6425 tpPESession session;
6426
6427 if (!msg_buf) {
6428 pe_err("Buffer is Pointing to NULL");
6429 return;
6430 }
6431
6432 obss_color_info = (struct wmi_obss_color_collision_info *)msg_buf;
6433 session = pe_find_session_by_sme_session_id(mac_ctx,
6434 obss_color_info->vdev_id);
6435 if (!session) {
6436 pe_err("Session not found for given session_id %d",
6437 obss_color_info->vdev_id);
6438 return;
6439 }
6440
6441 pe_debug("vdev_id:%d, evt:%d:%d, 0to31:0x%x, 32to63:0x%x, cap:%d:%d:%d",
6442 obss_color_info->vdev_id,
6443 obss_color_info->evt_type,
6444 session->obss_color_collision_dec_evt,
6445 obss_color_info->obss_color_bitmap_bit0to31,
6446 obss_color_info->obss_color_bitmap_bit32to63,
6447 session->he_capable,
6448 session->is_session_obss_color_collision_det_enabled,
6449 mac_ctx->lim.global_obss_color_collision_det_offload);
6450
6451 if (!session->he_capable ||
6452 !session->is_session_obss_color_collision_det_enabled) {
6453 return;
6454 }
6455
6456 switch (obss_color_info->evt_type) {
6457 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
6458 pe_err("%d: FW disabled obss color det. he_cap:%d, sup:%d:%d",
6459 session->smeSessionId, session->he_capable,
6460 session->is_session_obss_color_collision_det_enabled,
6461 mac_ctx->lim.global_obss_color_collision_det_offload);
6462 session->is_session_obss_color_collision_det_enabled = false;
6463 return;
6464 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
6465 case OBSS_COLOR_COLLISION_DETECTION:
6466 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
6467 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6468 pe_debug("Invalid System Role %d",
6469 GET_LIM_SYSTEM_ROLE(session));
6470 return;
6471 }
6472
6473 if (session->obss_color_collision_dec_evt !=
6474 obss_color_info->evt_type) {
6475 pe_debug("%d: Wrong event: %d, skiping",
6476 obss_color_info->vdev_id,
6477 obss_color_info->evt_type);
6478 return;
6479 }
6480 obss_color_collision_process_color_change(mac_ctx, session,
6481 obss_color_info);
6482 break;
6483 default:
6484 pe_err("%d: Invalid event type %d",
6485 obss_color_info->vdev_id, obss_color_info->evt_type);
6486 return;
6487 }
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006488}
6489#endif
Abhishek Singh20a8e442018-09-12 15:50:44 +05306490
6491#ifdef CONFIG_VDEV_SM
6492void lim_send_csa_restart_req(tpAniSirGlobal mac_ctx, uint8_t vdev_id)
6493{
6494 tpPESession session;
6495
6496 session = pe_find_session_by_sme_session_id(mac_ctx, vdev_id);
6497
6498 if (!session) {
6499 pe_err("session not found for vdev id %d", vdev_id);
6500 return;
6501 }
6502
6503 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
6504 WLAN_VDEV_SM_EV_CSA_RESTART,
6505 sizeof(*session), session);
6506}
6507#endif