blob: 36de9010d84baf946a3cda42934a341470551ac1 [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 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*
29 * This file lim_process_sme_req_messages.cc contains the code
30 * for processing SME request messages.
31 * Author: Chandra Modumudi
32 * Date: 02/11/02
33 * History:-
34 * Date Modified by Modification Information
35 * --------------------------------------------------------------------
36 *
37 */
38
39#include "cds_api.h"
40#include "wni_api.h"
41#include "wni_cfg.h"
42#include "cfg_api.h"
43#include "sir_api.h"
44#include "sch_api.h"
45#include "utils_api.h"
46#include "lim_types.h"
47#include "lim_utils.h"
48#include "lim_assoc_utils.h"
49#include "lim_security_utils.h"
50#include "lim_ser_des_utils.h"
51#include "lim_sme_req_utils.h"
52#include "lim_ibss_peer_mgmt.h"
53#include "lim_admit_control.h"
54#include "dph_hash_table.h"
55#include "lim_send_messages.h"
56#include "lim_api.h"
57#include "wmm_apsd.h"
58#include "sir_mac_prot_def.h"
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -080059#include "rrm_api.h"
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070060#include "nan_datapath.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080061
62#include "sap_api.h"
63
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080064
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080065#include <lim_ft.h>
Naveen Rawat3b6068c2016-04-14 19:01:06 -070066#include "cds_regdomain.h"
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053067#include "lim_process_fils.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070068#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080069
70/*
71 * This overhead is time for sending NOA start to host in case of GO/sending
72 * NULL data & receiving ACK in case of P2P Client and starting actual scanning
73 * with init scan req/rsp plus in case of concurrency, taking care of sending
74 * null data and receiving ACK to/from AP/Also SetChannel with calibration
75 * is taking around 7ms .
76 */
77#define SCAN_MESSAGING_OVERHEAD 20 /* in msecs */
78#define JOIN_NOA_DURATION 2000 /* in msecs */
79#define OEM_DATA_NOA_DURATION 60 /* in msecs */
80#define DEFAULT_PASSIVE_MAX_CHANNEL_TIME 110 /* in msecs */
81
82#define CONV_MS_TO_US 1024 /* conversion factor from ms to us */
83
Paul Zhangd2315472017-02-22 10:02:50 +080084#define BEACON_INTERVAL_THRESHOLD 50 /* in msecs */
85#define STA_BURST_SCAN_DURATION 120 /* in msecs */
86
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080087/* SME REQ processing function templates */
88static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080089static bool __lim_process_sme_start_bss_req(tpAniSirGlobal,
90 struct scheduler_msg *pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080091static void __lim_process_sme_join_req(tpAniSirGlobal, uint32_t *);
92static void __lim_process_sme_reassoc_req(tpAniSirGlobal, uint32_t *);
93static void __lim_process_sme_disassoc_req(tpAniSirGlobal, uint32_t *);
94static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal, uint32_t *);
95static void __lim_process_sme_deauth_req(tpAniSirGlobal, uint32_t *);
96static void __lim_process_sme_set_context_req(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080097static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal,
98 struct scheduler_msg *pMsg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053099static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
100 uint32_t *msg_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800101static void lim_process_sme_channel_change_request(tpAniSirGlobal pMac,
102 uint32_t *pMsg);
103static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg);
104static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal pMac, uint32_t *pMsg);
105static void lim_process_nss_update_request(tpAniSirGlobal pMac, uint32_t *pMsg);
106static void lim_process_set_ie_req(tpAniSirGlobal pMac, uint32_t *pMsg);
107
108static void lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
109 uint8_t **pDstData_buff,
110 uint16_t *pDstDataLen,
111 uint8_t *pSrcData_buff,
112 uint16_t srcDataLen);
113
114static void lim_update_add_ie_buffer(tpAniSirGlobal pMac,
115 uint8_t **pDstData_buff,
116 uint16_t *pDstDataLen,
117 uint8_t *pSrcData_buff, uint16_t srcDataLen);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800118static bool lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac,
119 uint8_t **pDstData_buff,
120 uint16_t *pDstDataLen,
121 tSirModifyIE *pModifyIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800122static void lim_process_modify_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
123
124static void lim_process_update_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
125
Abhishek Singh518323d2015-10-19 17:42:01 +0530126static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
127 uint32_t *msg);
128
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800129/**
130 * lim_process_set_hw_mode() - Send set HW mode command to WMA
131 * @mac: Globacl MAC pointer
132 * @msg: Message containing the hw mode index
133 *
134 * Send the set HW mode command to WMA
135 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530136 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800137 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530138static QDF_STATUS lim_process_set_hw_mode(tpAniSirGlobal mac, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800139{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530140 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700141 struct scheduler_msg message = {0};
Tushnim Bhattacharyya66348bd2017-03-09 15:02:10 -0800142 struct policy_mgr_hw_mode *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800143 uint32_t len;
144 struct s_sir_set_hw_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700145 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800146 struct sir_set_hw_mode_resp *param;
147
148 buf = (struct s_sir_set_hw_mode *) msg;
149 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700150 pe_err("Set HW mode param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800151 /* To free the active command list */
152 goto fail;
153 }
154
155 len = sizeof(*req_msg);
156
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530157 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800158 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700159 pe_err("qdf_mem_malloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800160 /* Free the active command list
161 * Probably the malloc is going to fail there as well?!
162 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530163 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800164 }
165
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530167 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168 /* Other parameters are not needed for WMA */
169
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800170 message.bodyptr = req_msg;
171 message.type = SIR_HAL_PDEV_SET_HW_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800172
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700173 pe_debug("Posting SIR_HAL_SOC_SET_HW_MOD to WMA");
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800174 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530175 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700176 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800177 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530178 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800179 goto fail;
180 }
181 return status;
182fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530183 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800184 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700185 pe_err("HW mode resp failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530186 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800187 }
188 param->status = SET_HW_MODE_STATUS_ECANCELED;
189 param->cfgd_hw_mode_index = 0;
190 param->num_vdev_mac_entries = 0;
191 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
192 resp_msg.bodyptr = param;
193 resp_msg.bodyval = 0;
194 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530195 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800196}
197
198/**
199 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
200 * @mac: Global MAC pointer
201 * @msg: Message containing the dual mac config parameter
202 *
203 * Send the set dual mac config command to WMA
204 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530205 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800206 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530207static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800208 uint32_t *msg)
209{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530210 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700211 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800212 struct sir_dual_mac_config *req_msg;
213 uint32_t len;
214 struct sir_set_dual_mac_cfg *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700215 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800216 struct sir_dual_mac_config_resp *param;
217
218 buf = (struct sir_set_dual_mac_cfg *) msg;
219 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700220 pe_err("Set Dual mac config is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800221 /* To free the active command list */
222 goto fail;
223 }
224
225 len = sizeof(*req_msg);
226
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530227 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800228 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700229 pe_err("qdf_mem_malloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800230 /* Free the active command list
231 * Probably the malloc is going to fail there as well?!
232 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530233 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800234 }
235
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800236 req_msg->scan_config = buf->set_dual_mac.scan_config;
237 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
238 /* Other parameters are not needed for WMA */
239
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800240 message.bodyptr = req_msg;
241 message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800242
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700243 pe_debug("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800244 req_msg->scan_config, req_msg->fw_mode_config);
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800245 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530246 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700247 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800248 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530249 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800250 goto fail;
251 }
252 return status;
253fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530254 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800255 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700256 pe_err("Dual mac config resp failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530257 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800258 }
259 param->status = SET_HW_MODE_STATUS_ECANCELED;
260 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
261 resp_msg.bodyptr = param;
262 resp_msg.bodyval = 0;
263 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530264 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800265}
266
267/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800268 * lim_process_set_antenna_mode_req() - Set antenna mode command
269 * to WMA
270 * @mac: Global MAC pointer
271 * @msg: Message containing the antenna mode parameter
272 *
273 * Send the set antenna mode command to WMA
274 *
275 * Return: QDF_STATUS_SUCCESS if message posting is successful
276 */
277static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
278 uint32_t *msg)
279{
280 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700281 struct scheduler_msg message = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800282 struct sir_antenna_mode_param *req_msg;
283 struct sir_set_antenna_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700284 struct scheduler_msg resp_msg = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800285 struct sir_antenna_mode_resp *param;
286
287 buf = (struct sir_set_antenna_mode *) msg;
288 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700289 pe_err("Set antenna mode is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800290 /* To free the active command list */
291 goto fail;
292 }
293
294 req_msg = qdf_mem_malloc(sizeof(*req_msg));
295 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700296 pe_err("qdf_mem_malloc failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800297 return QDF_STATUS_E_NOMEM;
298 }
299
300 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
301 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
302
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800303 message.bodyptr = req_msg;
304 message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800305
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700306 pe_debug("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800307 req_msg->num_rx_chains,
308 req_msg->num_tx_chains);
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800309 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800310 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700311 pe_err("scheduler_post_msg failed!(err=%d)",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800312 status);
313 qdf_mem_free(req_msg);
314 goto fail;
315 }
316 return status;
317fail:
318 param = qdf_mem_malloc(sizeof(*param));
319 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700320 pe_err("antenna mode resp failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800321 return QDF_STATUS_E_NOMEM;
322 }
323 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
324 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
325 resp_msg.bodyptr = param;
326 resp_msg.bodyval = 0;
327 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
328 return QDF_STATUS_SUCCESS;
329}
330
331/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800332 * __lim_is_sme_assoc_cnf_valid()
333 *
334 ***FUNCTION:
335 * This function is called by __lim_process_sme_assoc_cnf_new() upon
336 * receiving SME_ASSOC_CNF.
337 *
338 ***LOGIC:
339 * Message validity checks are performed in this function
340 *
341 ***ASSUMPTIONS:
342 *
343 ***NOTE:
344 *
345 * @param pMeasReq Pointer to Received ASSOC_CNF message
346 * @return true When received SME_ASSOC_CNF is formatted
347 * correctly
348 * false otherwise
349 */
350
351static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
352{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530353 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800354 return false;
355 else
356 return true;
357} /*** end __lim_is_sme_assoc_cnf_valid() ***/
358
359/**
360 * __lim_get_sme_join_req_size_for_alloc()
361 *
362 ***FUNCTION:
363 * This function is called in various places to get IE length
364 * from tSirBssDescription structure
365 * number being scanned.
366 *
367 ***PARAMS:
368 *
369 ***LOGIC:
370 *
371 ***ASSUMPTIONS:
372 * NA
373 *
374 ***NOTE:
375 * NA
376 *
377 * @param pBssDescr
378 * @return Total IE length
379 */
380
381static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
382{
383 uint16_t len = 0;
384
385 if (!pBuf)
386 return len;
387
388 pBuf += sizeof(uint16_t);
389 len = lim_get_u16(pBuf);
Arif Hussainc9651922017-04-16 14:08:23 -0700390 return len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800391}
392
393/**
394 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
395 * @pMac: Global MAC context
396 * @pMsg: Pointer to message posted from SME to LIM.
397 *
398 * Has role only if 11h is enabled. Not used on STA side.
399 * Defers the message if SME is in learn state and brings
400 * the LIM back to normal mode.
401 *
402 * Return: true - If defered false - Otherwise
403 */
404
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800405static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac,
406 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800407{
408 if (lim_is_system_in_scan_state(pMac)) {
409 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700410 pe_err("Could not defer Msg: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800411 return false;
412 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700413 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800414 pMsg->type);
415 return true;
416 }
417 return false;
418}
419
420/**
421 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
422 * @mac_ctx: Pointer to Global MAC structure
423 * @message: Pointer to message posted from SME to LIM.
424 *
425 * Has role only if 11h is enabled. Not used on STA side.
426 * Defers the message if radar is detected.
427 *
428 * Return: true, if defered otherwise return false.
429 */
430static bool
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800431__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx,
432 struct scheduler_msg *message)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800433{
434 /*
435 * fRadarDetCurOperChan will be set only if we
436 * detect radar in current operating channel and
437 * System Role == AP ROLE
438 *
439 * TODO: Need to take care radar detection.
440 *
441 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
442 */
443 if (0) {
444 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700445 pe_err("Could not defer Msg: %d", message->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800446 return false;
447 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700448 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800449 message->type);
450 return true;
451 }
452 return false;
453}
454
455/**
456 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
457 * @pMac: Global MAC context
458 * @pMsgBuf: Message from WMA
459 *
460 * handles the notification from HDD. PE just forwards this message to HAL.
461 *
462 * Return: true-Posting to HAL failed, so PE will consume the buffer.
463 * false-Posting to HAL successful, so HAL will consume the buffer.
464 */
465
466static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
467{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700468 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800469 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
470
471 msg.type = WMA_SYS_READY_IND;
472 msg.reserved = 0;
473 msg.bodyptr = pMsgBuf;
474 msg.bodyval = 0;
475
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700476 if (ANI_DRIVER_TYPE(pMac) != QDF_DRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800477 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +0530478 pe_register_mgmt_rx_frm_callback(pMac);
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700479 pe_register_callbacks_with_wma(pMac, ready_req);
Sandeep Puligilla1426d612017-04-12 18:22:06 -0700480 pMac->lim.sme_msg_callback = ready_req->sme_msg_cb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800481 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700482
483 pe_debug("sending WMA_SYS_READY_IND msg to HAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800484 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
485
486 if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700487 pe_err("wma_post_ctrl_msg failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800488 return true;
489 }
490 return false;
491}
492
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800493/**
494 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
495 *@mac_ctx: Pointer to Global MAC structure
496 *@session: A pointer to session entry
497 *@sme_start_bss_req: Start BSS Request from upper layers.
498 *
499 * This function is used to configure the start bss parameters
500 * in to the session.
501 *
502 * Return: None.
503 */
504static void
505lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
506 tpSirSmeStartBssReq sme_start_bss_req)
507{
508 session->limSystemRole = eLIM_AP_ROLE;
509 session->privacy = sme_start_bss_req->privacy;
510 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
511 session->authType = sme_start_bss_req->authType;
512 /* Store the DTIM period */
513 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
514 /* Enable/disable UAPSD */
515 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530516 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800517 session->proxyProbeRspEn = 0;
518 } else {
519 /*
520 * To detect PBC overlap in SAP WPS mode,
521 * Host handles Probe Requests.
522 */
523 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
524 session->proxyProbeRspEn = 1;
525 else
526 session->proxyProbeRspEn = 0;
527 }
528 session->ssidHidden = sme_start_bss_req->ssidHidden;
529 session->wps_state = sme_start_bss_req->wps_state;
530 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530531 session->vendor_vht_sap =
532 sme_start_bss_req->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800533 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
534 &session->shortSlotTimeSupported);
535 session->isCoalesingInIBSSAllowed =
536 sme_start_bss_req->isCoalesingInIBSSAllowed;
537
Jiachao Wu712d4fd2017-08-23 16:52:34 +0800538 session->beacon_tx_rate = sme_start_bss_req->beacon_tx_rate;
539
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800540}
541
542/**
Arif Hussain53cf5692018-04-05 16:35:54 -0700543 * lim_clear_he_tx_stbc() - Clear tx stbc for a given session
544 * @session: Session
545 *
546 * Clear tx stbc for a given session
547 *
548 * Return: None
549 */
550#ifdef WLAN_FEATURE_11AX
551static void lim_clear_he_tx_stbc(tpPESession session)
552{
553 if (session) {
554 session->he_config.tx_stbc_lt_80mhz = 0;
555 session->he_config.tx_stbc_gt_80mhz = 0;
556 }
557}
558#else
559static void lim_clear_he_tx_stbc(tpPESession session)
560{}
561#endif
562
563/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800564 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
565 *@mac_ctx: Pointer to Global MAC structure
566 *@msg_buf: A pointer to the SME message buffer
567 *
568 * This function is called to process SME_START_BSS_REQ message
569 * from HDD or upper layer application.
570 *
571 * Return: None
572 */
573static void
574__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
575{
576 uint16_t size;
577 uint32_t val = 0;
578 tSirRetStatus ret_status;
579 tSirMacChanNum channel_number;
580 tLimMlmStartReq *mlm_start_req = NULL;
581 tpSirSmeStartBssReq sme_start_bss_req = NULL;
582 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
583 /* Flag Used in case of IBSS to Auto generate BSSID. */
584 uint32_t auto_gen_bssid = false;
585 uint8_t session_id;
586 tpPESession session = NULL;
Krunal Sonib37bb352016-12-20 14:12:21 -0800587 uint8_t sme_session_id = 0xFF;
588 uint16_t sme_transaction_id = 0xFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800589 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700590 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800591 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
592
593/* FEATURE_WLAN_DIAG_SUPPORT */
594#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
595 /*
596 * Since the session is not created yet, sending NULL.
597 * The response should have the correct state.
598 */
599 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
600 NULL, 0, 0);
601#endif /* FEATURE_WLAN_DIAG_SUPPORT */
602
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700603 pe_debug("Received START_BSS_REQ");
Krunal Sonib37bb352016-12-20 14:12:21 -0800604 size = sizeof(tSirSmeStartBssReq);
605 sme_start_bss_req = qdf_mem_malloc(size);
606 if (NULL == sme_start_bss_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700607 pe_err("Allocate Memory fail for LimStartBssReq");
Krunal Sonib37bb352016-12-20 14:12:21 -0800608 /* Send failure response to host */
609 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
610 goto free;
611 }
612 qdf_mem_copy(sme_start_bss_req, msg_buf, sizeof(tSirSmeStartBssReq));
613 sme_session_id = sme_start_bss_req->sessionId;
614 sme_transaction_id = sme_start_bss_req->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800615
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800616 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
617 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800618 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
619 sme_start_bss_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700620 pe_warn("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800621 ret_code = eSIR_SME_INVALID_PARAMETERS;
622 goto free;
623 }
624
625 /*
626 * This is the place where PE is going to create a session.
627 * If session is not existed, then create a new session
628 */
629 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800630 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800631 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700632 pe_warn("Session Already exists for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800633 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
634 session = NULL;
635 goto free;
636 } else {
637 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800638 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800639 &session_id, mac_ctx->lim.maxStation,
640 sme_start_bss_req->bssType);
641 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700642 pe_warn("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800643 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
644 goto free;
645 }
646 }
647
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700648 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
649 /* Probe resp add ie */
650 lim_start_bss_update_add_ie_buffer(mac_ctx,
651 &session->addIeParams.probeRespData_buff,
652 &session->addIeParams.probeRespDataLen,
653 sme_start_bss_req->addIeParams.
654 probeRespData_buff,
655 sme_start_bss_req->addIeParams.
656 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800657
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700658 /* Probe Beacon add ie */
659 lim_start_bss_update_add_ie_buffer(mac_ctx,
660 &session->addIeParams.probeRespBCNData_buff,
661 &session->addIeParams.probeRespBCNDataLen,
662 sme_start_bss_req->addIeParams.
663 probeRespBCNData_buff,
664 sme_start_bss_req->addIeParams.
665 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800666
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700667 /* Assoc resp IE */
668 lim_start_bss_update_add_ie_buffer(mac_ctx,
669 &session->addIeParams.assocRespData_buff,
670 &session->addIeParams.assocRespDataLen,
671 sme_start_bss_req->addIeParams.
672 assocRespData_buff,
673 sme_start_bss_req->addIeParams.
674 assocRespDataLen);
675 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800676 /* Store the session related params in newly created session */
677 session->pLimStartBssReq = sme_start_bss_req;
678
679 /* Store PE session_id in session Table */
680 session->peSessionId = session_id;
681
682 /* Store SME session Id in sessionTable */
683 session->smeSessionId = sme_start_bss_req->sessionId;
684
685 session->transactionId = sme_start_bss_req->transactionId;
686
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530687 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800688 &(sme_start_bss_req->htConfig),
689 sizeof(session->htConfig));
690
Sandeep Puligilla98917432016-06-10 13:50:28 -0700691 qdf_mem_copy(&(session->vht_config),
692 &(sme_start_bss_req->vht_config),
693 sizeof(session->vht_config));
694
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800695 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800696 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800697
698 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530699 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800700 (uint8_t *) &sme_start_bss_req->ssId,
701 (sme_start_bss_req->ssId.length + 1));
702
703 session->bssType = sme_start_bss_req->bssType;
704
705 session->nwType = sme_start_bss_req->nwType;
706
707 session->beaconParams.beaconInterval =
708 sme_start_bss_req->beaconInterval;
709
710 /* Store the channel number in session Table */
711 session->currentOperChannel =
712 sme_start_bss_req->channelId;
713
714 /* Store Persona */
715 session->pePersona = sme_start_bss_req->bssPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +0530716 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800717 FL("PE PERSONA=%d"), session->pePersona);
718
719 /* Update the phymode */
720 session->gLimPhyMode = sme_start_bss_req->nwType;
721
722 session->maxTxPower =
723 cfg_get_regulatory_max_transmit_power(mac_ctx,
724 session->currentOperChannel);
725 /* Store the dot 11 mode in to the session Table */
726 session->dot11mode = sme_start_bss_req->dot11mode;
727#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
728 session->cc_switch_mode =
729 sme_start_bss_req->cc_switch_mode;
730#endif
731 session->htCapability =
732 IS_DOT11_MODE_HT(session->dot11mode);
733 session->vhtCapability =
734 IS_DOT11_MODE_VHT(session->dot11mode);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800735
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700736 pe_debug("HT[%d], VHT[%d]",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800737 session->htCapability, session->vhtCapability);
738
739 if (IS_DOT11_MODE_HE(session->dot11mode)) {
740 lim_update_session_he_capable(mac_ctx, session);
741 lim_copy_bss_he_cap(session, sme_start_bss_req);
742 }
743
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800744 session->txLdpcIniFeatureEnabled =
745 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800746#ifdef WLAN_FEATURE_11W
747 session->limRmfEnabled =
748 sme_start_bss_req->pmfCapable ? 1 : 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700749 pe_debug("Session RMF enabled: %d", session->limRmfEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800750#endif
751
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530752 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800753 (void *)&sme_start_bss_req->operationalRateSet,
754 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530755 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800756 (void *)&sme_start_bss_req->extendedRateSet,
757 sizeof(tSirMacRateSet));
758
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700759 if (IS_5G_CH(session->currentOperChannel))
760 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
761 else
762 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
763
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800764 switch (sme_start_bss_req->bssType) {
765 case eSIR_INFRA_AP_MODE:
766 lim_configure_ap_start_bss_session(mac_ctx, session,
767 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700768 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700769 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700770 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700771 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800772 break;
773 case eSIR_IBSS_MODE:
774 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
775 lim_get_short_slot_from_phy_mode(mac_ctx, session,
776 session->gLimPhyMode,
777 &session->shortSlotTimeSupported);
778
779 /*
780 * initialize to "OPEN".
781 * will be updated upon key installation
782 */
783 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700784 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800785
786 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700787 case eSIR_NDI_MODE:
788 session->limSystemRole = eLIM_NDI_ROLE;
789 break;
790
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800791
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800792 /*
793 * There is one more mode called auto mode.
794 * which is used no where
795 */
796
797 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
798
799 default:
800 /* not used anywhere...used in scan function */
801 break;
802 }
803
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700804 pe_debug("persona - %d, nss - %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700805 session->pePersona, session->vdev_nss);
806 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800807 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700808 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800809 * parsed (Re)Assoc request structure
810 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700811 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800812 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530813 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700814 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815 if (NULL == session->parsedAssocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700816 pe_warn("AllocateMemory() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800817 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
818 goto free;
819 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800820 }
821
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700822 if (!sme_start_bss_req->channelId &&
823 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700824 pe_err("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800825 ret_code = eSIR_SME_INVALID_PARAMETERS;
826 goto free;
827 }
828 channel_number = sme_start_bss_req->channelId;
829#ifdef QCA_HT_2040_COEX
830 if (sme_start_bss_req->obssEnabled)
831 session->htSupportedChannelWidthSet =
832 session->htCapability;
833 else
834#endif
835 session->htSupportedChannelWidthSet =
836 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
837 session->htSecondaryChannelOffset =
838 sme_start_bss_req->sec_ch_offset;
839 session->htRecommendedTxWidthSet =
840 (session->htSecondaryChannelOffset) ? 1 : 0;
Abhishek Singh4294f802017-08-10 16:37:07 +0530841 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800842 FL("cbMode %u"), sme_start_bss_req->cbMode);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800843 if (lim_is_session_he_capable(session) ||
844 session->vhtCapability || session->htCapability) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800845 chanwidth = sme_start_bss_req->vht_channel_width;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700846 pe_debug("vht_channel_width %u htSupportedChannelWidthSet %d",
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800847 sme_start_bss_req->vht_channel_width,
848 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800849 session->ch_width = chanwidth;
850 if (session->htSupportedChannelWidthSet) {
851 session->ch_center_freq_seg0 =
852 sme_start_bss_req->center_freq_seg0;
853 session->ch_center_freq_seg1 =
854 sme_start_bss_req->center_freq_seg1;
855 } else {
856 session->ch_center_freq_seg0 = 0;
857 session->ch_center_freq_seg1 = 0;
858 }
859 }
860
861 if (session->vhtCapability &&
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800862 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800863 session->nss = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700864 pe_debug("nss set to [%d]", session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800865 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700866 pe_debug("vht su tx bformer %d",
Krunal Soni53993f72016-07-08 18:20:03 -0700867 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868
869 /* Delete pre-auth list if any */
870 lim_delete_pre_auth_list(mac_ctx);
871
Krunal Soni53993f72016-07-08 18:20:03 -0700872 if (session->nss == 1) {
873 session->vht_config.su_beam_former = 0;
874 session->vht_config.tx_stbc = 0;
875 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530876 session->htConfig.ht_tx_stbc = 0;
Arif Hussain53cf5692018-04-05 16:35:54 -0700877 lim_clear_he_tx_stbc(session);
Krunal Soni53993f72016-07-08 18:20:03 -0700878 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800879 /*
880 * keep the RSN/WPA IE information in PE Session Entry
881 * later will be using this to check when received (Re)Assoc req
882 */
883 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
884 &sme_start_bss_req->rsnIE, session);
885
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700886 if (LIM_IS_AP_ROLE(session) ||
887 LIM_IS_IBSS_ROLE(session) ||
888 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800889 session->gLimProtectionControl =
890 sme_start_bss_req->protEnabled;
891 /*
892 * each byte will have the following info
893 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
894 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
895 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530896 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800897 (void *)&sme_start_bss_req->ht_capab,
898 sizeof(uint16_t));
899 /* Initialize WPS PBC session link list */
900 session->pAPWPSPBCSession = NULL;
901 }
902 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530903 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800904 if (NULL == mlm_start_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700905 pe_err("Allocate Memory failed for mlmStartReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800906 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
907 goto free;
908 }
909
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800910 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530911 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800912 (uint8_t *) &sme_start_bss_req->ssId,
913 sme_start_bss_req->ssId.length + 1);
914 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
915 mlm_start_req->obssProtEnabled =
916 sme_start_bss_req->obssProtEnabled;
917
918 mlm_start_req->bssType = session->bssType;
919
920 /* Fill PE session Id from the session Table */
921 mlm_start_req->sessionId = session->peSessionId;
922
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700923 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
924 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800925 /*
926 * Copy the BSSId from sessionTable to
927 * mlmStartReq struct
928 */
929 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
930 } else {
931 /* ibss mode */
932 mac_ctx->lim.gLimIbssCoalescingHappened = false;
933
934 ret_status = wlan_cfg_get_int(mac_ctx,
935 WNI_CFG_IBSS_AUTO_BSSID,
936 &auto_gen_bssid);
937 if (ret_status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700938 pe_err("Get Auto Gen BSSID fail,Status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800939 ret_status);
Abhishek Singh4294f802017-08-10 16:37:07 +0530940 ret_code = eSIR_LOGE_EXCEPTION;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800941 goto free;
942 }
943
944 if (!auto_gen_bssid) {
945 /*
946 * We're not auto generating BSSID.
947 * Instead, get it from session entry
948 */
949 sir_copy_mac_addr(mlm_start_req->bssId,
950 session->bssId);
951 /*
952 * Start IBSS group BSSID
953 * Auto Generating BSSID.
954 */
955 auto_gen_bssid = ((mlm_start_req->bssId[0] &
956 0x01) ? true : false);
957 }
958
959 if (auto_gen_bssid) {
960 /*
961 * if BSSID is not any uc id.
962 * then use locally generated BSSID.
963 * Autogenerate the BSSID
964 */
965 lim_get_random_bssid(mac_ctx,
966 mlm_start_req->bssId);
967 mlm_start_req->bssId[0] = 0x02;
968
969 /*
970 * Copy randomly generated BSSID
971 * to the session Table
972 */
973 sir_copy_mac_addr(session->bssId,
974 mlm_start_req->bssId);
975 }
976 }
977 /* store the channel num in mlmstart req structure */
978 mlm_start_req->channelNumber = session->currentOperChannel;
979 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
980 mlm_start_req->beaconPeriod =
981 session->beaconParams.beaconInterval;
Arif Hussain671a1902017-03-17 09:08:32 -0700982 mlm_start_req->cac_duration_ms =
983 sme_start_bss_req->cac_duration_ms;
984 mlm_start_req->dfs_regdomain =
985 sme_start_bss_req->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800986 if (LIM_IS_AP_ROLE(session)) {
987 mlm_start_req->dtimPeriod = session->dtimPeriod;
988 mlm_start_req->wps_state = session->wps_state;
989
990 } else {
991 if (wlan_cfg_get_int(mac_ctx,
992 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700993 pe_err("could not retrieve DTIM Period");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800994 mlm_start_req->dtimPeriod = (uint8_t) val;
995 }
996
997 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
998 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700999 pe_err("could not retrieve Beacon interval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001000 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
1001
1002 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
1003 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001004 pe_err("could not retrieve CFPMaxDuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001005 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1006
1007 /*
1008 * this may not be needed anymore now,
1009 * as rateSet is now included in the
1010 * session entry and MLM has session context.
1011 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301012 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001013 (void *)&session->rateSet,
1014 sizeof(tSirMacRateSet));
1015
1016 /* Now populate the 11n related parameters */
1017 mlm_start_req->nwType = session->nwType;
1018 mlm_start_req->htCapable = session->htCapability;
1019
1020 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1021 /* Unused */
1022 mlm_start_req->dualCTSProtection =
1023 mac_ctx->lim.gHTDualCTSProtection;
1024 mlm_start_req->txChannelWidthSet =
1025 session->htRecommendedTxWidthSet;
1026
1027 session->limRFBand = lim_get_rf_band(channel_number);
1028
1029 /* Initialize 11h Enable Flag */
1030 session->lim11hEnable = 0;
gaolez76d2a162017-03-21 19:23:58 +08001031 if (mlm_start_req->bssType != eSIR_IBSS_MODE &&
1032 (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001033 BAND_5G == session->limRFBand)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001034 if (wlan_cfg_get_int(mac_ctx,
1035 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001036 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001037 else
1038 session->lim11hEnable = val;
1039
1040 if (session->lim11hEnable &&
1041 (eSIR_INFRA_AP_MODE ==
1042 mlm_start_req->bssType)) {
1043 cfg_get_wmi_dfs_master_param =
1044 wlan_cfg_get_int(mac_ctx,
1045 WNI_CFG_DFS_MASTER_ENABLED,
1046 &val);
1047 session->lim11hEnable = val;
1048 }
1049 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1050 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001051 pe_err("Get Fail, CFG DFS ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001052 }
1053
1054 if (!session->lim11hEnable) {
1055 if (cfg_set_int(mac_ctx,
1056 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1057 eSIR_SUCCESS)
1058 /*
1059 * Failed to set the CFG param
1060 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1061 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001062 pe_err("Set LOCAL_POWER_CONSTRAINT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063 }
1064
Jiachao Wu712d4fd2017-08-23 16:52:34 +08001065 mlm_start_req->beacon_tx_rate = session->beacon_tx_rate;
1066
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001067 session->limPrevSmeState = session->limSmeState;
1068 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1069 MTRACE(mac_trace
1070 (mac_ctx, TRACE_CODE_SME_STATE,
1071 session->peSessionId,
1072 session->limSmeState));
1073
1074 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1075 (uint32_t *) mlm_start_req);
1076 return;
1077 } else {
1078
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001079 pe_err("Received unexpected START_BSS_REQ, in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001080 mac_ctx->lim.gLimSmeState);
1081 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001082 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001083 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1084
1085free:
1086 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001087 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001088 session->pLimStartBssReq = NULL;
1089 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001090 if (NULL != sme_start_bss_req)
1091 qdf_mem_free(sme_start_bss_req);
1092 if (NULL != mlm_start_req)
1093 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001094 if (NULL != session) {
1095 pe_delete_session(mac_ctx, session);
1096 session = NULL;
1097 }
1098 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1099 session, sme_session_id, sme_transaction_id);
1100}
1101
1102/**
1103 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1104 *
1105 * @pMac: Global MAC context
1106 * @pMsg: Message pointer
1107 *
1108 * Wrapper for the function __lim_handle_sme_start_bss_request
1109 * This message will be defered until softmac come out of
1110 * scan mode or if we have detected radar on the current
1111 * operating channel.
1112 *
1113 * return true - If we consumed the buffer
1114 * false - If have defered the message.
1115 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001116static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1117 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001118{
1119 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1120 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1121 /**
1122 * If message defered, buffer is not consumed yet.
1123 * So return false
1124 */
1125 return false;
1126 }
1127
1128 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1129 return true;
1130}
1131
1132/**
1133 * lim_get_random_bssid()
1134 *
1135 * FUNCTION:This function is called to process generate the random number for bssid
1136 * This function is called to process SME_SCAN_REQ message
1137 * from HDD or upper layer application.
1138 *
1139 * LOGIC:
1140 *
1141 * ASSUMPTIONS:
1142 *
1143 * NOTE:
1144 * 1. geneartes the unique random number for bssid in ibss
1145 *
1146 * @param pMac Pointer to Global MAC structure
1147 * @param *data Pointer to bssid buffer
1148 * @return None
1149 */
1150void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1151{
1152 uint32_t random[2];
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001153
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001154 random[0] = tx_time_get();
1155 random[0] |= (random[0] << 15);
1156 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301157 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001158}
1159
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001160/**
1161 * __lim_process_clear_dfs_channel_list()
1162 *
1163 ***FUNCTION:
1164 ***Clear DFS channel list when country is changed/aquired.
1165 .*This message is sent from SME.
1166 *
1167 ***LOGIC:
1168 *
1169 ***ASSUMPTIONS:
1170 *
1171 ***NOTE:
1172 *
1173 * @param pMac Pointer to Global MAC structure
1174 * @param *pMsgBuf A pointer to the SME message buffer
1175 * @return None
1176 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001177static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1178 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001179{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301180 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001181}
1182
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301183#ifdef WLAN_FEATURE_SAE
1184
1185/**
1186 * lim_update_sae_config()- This API update SAE session info to csr config
1187 * from join request.
1188 * @session: PE session
1189 * @sme_join_req: pointer to join request
1190 *
1191 * Return: None
1192 */
1193static void lim_update_sae_config(tpPESession session,
1194 tpSirSmeJoinReq sme_join_req)
1195{
1196 session->sae_pmk_cached = sme_join_req->sae_pmk_cached;
1197
1198 pe_debug("pmk_cached %d for BSSID=" MAC_ADDRESS_STR,
1199 session->sae_pmk_cached,
1200 MAC_ADDR_ARRAY(sme_join_req->bssDescription.bssId));
1201}
1202#else
1203static inline void lim_update_sae_config(tpPESession session,
1204 tpSirSmeJoinReq sme_join_req)
1205{}
1206#endif
1207
1208
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001209/**
1210 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1211 * @mac_ctx: Pointer to Global MAC structure
1212 * @msg_buf: A pointer to the SME message buffer
1213 *
1214 * This function is called to process SME_JOIN_REQ message
1215 * from HDD or upper layer application.
1216 *
1217 * Return: None
1218 */
1219static void
1220__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1221{
1222 tpSirSmeJoinReq sme_join_req = NULL;
1223 tLimMlmJoinReq *mlm_join_req;
1224 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1225 uint32_t val = 0;
1226 uint16_t n_size;
1227 uint8_t session_id;
1228 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301229 uint8_t sme_session_id = 0;
1230 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001231 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001232 uint16_t ie_len;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001233 const uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001234 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001235 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001236
Arif Hussain995fcaf2016-07-18 11:28:22 -07001237 if (!mac_ctx || !msg_buf) {
1238 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1239 FL("JOIN REQ with invalid data"));
1240 return;
1241 }
1242
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001243/* FEATURE_WLAN_DIAG_SUPPORT */
1244#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1245 /*
1246 * Not sending any session, since it is not created yet.
1247 * The response whould have correct state.
1248 */
1249 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1250#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1251
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001252 /*
1253 * Expect Join request in idle state.
1254 * Reassociate request is expected in link established state.
1255 */
1256
1257 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1258 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1259 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1260 msg_buf);
1261
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301262 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001263 if (NULL == sme_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001264 pe_err("AllocateMemory failed for sme_join_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001265 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301266 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001267 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301268 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001269 n_size);
1270
1271 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1272 /* Received invalid eWNI_SME_JOIN_REQ */
1273 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001274 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001275 sme_join_req->sessionId);
1276 ret_code = eSIR_SME_INVALID_PARAMETERS;
1277 goto end;
1278 }
1279
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001280 /*
1281 * Update the capability here itself as this is used in
1282 * lim_extract_ap_capability() below. If not updated issues
1283 * like not honoring power constraint on 1st association after
1284 * driver loading might occur.
1285 */
1286 lim_update_rrm_capability(mac_ctx, sme_join_req);
1287
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001288 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001289 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001290 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001291 &session_id);
1292
1293 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001294 pe_err("Session(%d) Already exists for BSSID: "
1295 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001296 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001297 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001298 session->limSmeState);
1299
1300 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1301 session->smeSessionId == sme_join_req->sessionId) {
1302 /*
1303 * Received eWNI_SME_JOIN_REQ for same
1304 * BSS as currently associated.
1305 * Log the event and send success
1306 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001307 pe_warn("SessionId: %d", session_id);
1308 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001309 /* Send Join success response to host */
1310 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1311 session = NULL;
1312 goto end;
1313 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001314 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001315 ret_code = eSIR_SME_REFUSED;
1316 session = NULL;
1317 goto end;
1318 }
1319 } else {
1320 /*
1321 * Session Entry does not exist for given BSSId
1322 * Try to Create a new session
1323 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001324 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325 &session_id, mac_ctx->lim.maxStation,
1326 eSIR_INFRASTRUCTURE_MODE);
1327 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001328 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001329 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1330 goto end;
1331 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001332 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001333 session_id);
1334 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001335 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001336
1337 /*
1338 * Store Session related parameters
1339 * Store PE session Id in session Table
1340 */
1341 session->peSessionId = session_id;
1342
1343 /* store the smejoin req handle in session table */
1344 session->pLimJoinReq = sme_join_req;
1345
1346 /* Store SME session Id in sessionTable */
1347 session->smeSessionId = sme_join_req->sessionId;
1348
1349 /* Store SME transaction Id in session Table */
1350 session->transactionId = sme_join_req->transactionId;
1351
1352 /* Store beaconInterval */
1353 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001354 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001355
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301356 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001357 sizeof(session->htConfig));
1358
Sandeep Puligilla98917432016-06-10 13:50:28 -07001359 qdf_mem_copy(&(session->vht_config),
1360 &(sme_join_req->vht_config),
1361 sizeof(session->vht_config));
1362
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001363 /* Copying of bssId is already done, while creating session */
1364 sir_copy_mac_addr(session->selfMacAddr,
1365 sme_join_req->selfMacAddr);
1366 session->bssType = sme_join_req->bsstype;
1367
1368 session->statypeForBss = STA_ENTRY_PEER;
1369 session->limWmeEnabled = sme_join_req->isWMEenabled;
1370 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301371 session->wps_registration = sme_join_req->wps_registration;
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001372 session->he_with_wep_tkip = sme_join_req->he_with_wep_tkip;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001373
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301374 session->enable_bcast_probe_rsp =
1375 sme_join_req->enable_bcast_probe_rsp;
1376
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001378 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001379 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1380
Naveen Rawat08db88f2017-09-08 15:07:48 -07001381 vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001382 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001383 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001384
1385 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001386 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387 session->isCiscoVendorAP = true;
1388 } else {
1389 session->isCiscoVendorAP = false;
1390 }
1391
1392 /* Copy the dot 11 mode in to the session table */
1393
1394 session->dot11mode = sme_join_req->dot11mode;
1395#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1396 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1397#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001398 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001399 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1400 session->enableHtSmps = sme_join_req->enableHtSmps;
1401 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001402 session->send_smps_action =
1403 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001404 /*
1405 * By default supported NSS 1x1 is set to true
1406 * and later on updated while determining session
1407 * supported rates which is the intersection of
1408 * self and peer rates
1409 */
1410 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301411 /*Store Persona */
1412 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001413 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 -08001414 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001415 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001416 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301417 session->supported_nss_1x1,
1418 session->pePersona,
1419 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001420
1421 /*Store Persona */
1422 session->pePersona = sme_join_req->staPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +05301423 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301424 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d force_24ghz_in_ht20 %d"),
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001425 session->pePersona, sme_join_req->cbMode,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301426 session->nwType, session->dot11mode,
1427 sme_join_req->force_24ghz_in_ht20);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001428
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001429 /* Copy The channel Id to the session Table */
1430 session->currentOperChannel = bss_desc->channelId;
1431 if (IS_5G_CH(session->currentOperChannel))
1432 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001433 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001434 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1435 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1436 session->vdev_nss = vdev_type_nss->p2p_cli;
1437 else
1438 session->vdev_nss = vdev_type_nss->sta;
1439 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440 session->vhtCapability =
1441 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001442 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301443 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001444 session->vht_config.su_beam_formee =
1445 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001446 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001447 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001448 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001449 session->enableVhtpAid =
1450 sme_join_req->enableVhtpAid;
1451 session->enableVhtGid =
1452 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001453 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001454 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001455 }
Krunal Soni53993f72016-07-08 18:20:03 -07001456
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001457 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301458 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001459 session->vht_config.su_beam_formee,
1460 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001461 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001462 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001463 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001464 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301465 session->force_24ghz_in_ht20 =
1466 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001467 /* cbMode is already merged value of peer and self -
1468 * done by csr in csr_get_cb_mode_from_ies */
1469 session->htSupportedChannelWidthSet =
1470 (sme_join_req->cbMode) ? 1 : 0;
1471 session->htRecommendedTxWidthSet =
1472 session->htSupportedChannelWidthSet;
1473 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1474
1475 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1476 session->ch_center_freq_seg0 =
1477 session->currentOperChannel - 2;
1478 session->ch_width = CH_WIDTH_40MHZ;
1479 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1480 sme_join_req->cbMode) {
1481 session->ch_center_freq_seg0 =
1482 session->currentOperChannel + 2;
1483 session->ch_width = CH_WIDTH_40MHZ;
1484 } else {
1485 session->ch_center_freq_seg0 = 0;
1486 session->ch_width = CH_WIDTH_20MHZ;
1487 }
1488
Naveen Rawataeca1b92017-10-16 16:55:31 -07001489 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1490 lim_update_session_he_capable(mac_ctx, session);
1491 lim_copy_join_req_he_cap(session, sme_join_req);
1492 }
1493
1494
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001495 /* Record if management frames need to be protected */
1496#ifdef WLAN_FEATURE_11W
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +05301497 if ((eSIR_ED_AES_128_CMAC ==
1498 sme_join_req->MgmtEncryptionType) ||
1499 (eSIR_ED_AES_GMAC_128 == sme_join_req->MgmtEncryptionType) ||
1500 (eSIR_ED_AES_GMAC_256 == sme_join_req->MgmtEncryptionType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001501 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001502 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001503 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001504#endif
1505
1506#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001507 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001508#endif
1509
1510 /* Copy the SSID from smejoinreq to session entry */
1511 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301512 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001513 session->ssId.length);
1514
1515 /*
1516 * Determin 11r or ESE connection based on input from SME
1517 * which inturn is dependent on the profile the user wants
1518 * to connect to, So input is coming from supplicant
1519 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001520 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521#ifdef FEATURE_WLAN_ESE
1522 session->isESEconnection = sme_join_req->isESEconnection;
1523#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001524 session->isFastTransitionEnabled =
1525 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001527 session->isFastRoamIniFeatureEnabled =
1528 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001529 session->txLdpcIniFeatureEnabled =
1530 sme_join_req->txLdpcIniFeatureEnabled;
1531
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301532 lim_update_fils_config(session, sme_join_req);
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301533 lim_update_sae_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001534 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1535 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001536 } else {
1537 /*
1538 * Throw an error and return and make
1539 * sure to delete the session.
1540 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001541 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001542 session->bssType);
1543 ret_code = eSIR_SME_INVALID_PARAMETERS;
1544 goto end;
1545 }
1546
1547 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301548 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001549 &sme_join_req->addIEScan, sizeof(tSirAddie));
1550
1551 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301552 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001553 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1554
1555 val = sizeof(tLimMlmJoinReq) +
1556 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301557 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001558 if (NULL == mlm_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001559 pe_err("AllocateMemory failed for mlmJoinReq");
Nitesh Shah0102cac2016-07-13 14:38:30 +05301560 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1561 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001562 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001563
1564 /* PE SessionId is stored as a part of JoinReq */
1565 mlm_join_req->sessionId = session->peSessionId;
1566
1567 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1568 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1569 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001570 pe_err("couldn't retrieve JoinFailureTimer value"
1571 " setting to default value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001572 mlm_join_req->joinFailureTimeout =
1573 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1574 }
1575
1576 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301577 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001578 (void *)&sme_join_req->operationalRateSet,
1579 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301580 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581 (void *)&sme_join_req->extendedRateSet,
1582 sizeof(tSirMacRateSet));
1583 /*
1584 * this may not be needed anymore now, as rateSet is now
1585 * included in the session entry and MLM has session context.
1586 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301587 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001588 (void *)&session->rateSet,
1589 sizeof(tSirMacRateSet));
1590
1591 session->encryptType = sme_join_req->UCEncryptionType;
1592
1593 mlm_join_req->bssDescription.length =
1594 session->pLimJoinReq->bssDescription.length;
1595
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301596 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001597 (uint8_t *)
1598 &session->pLimJoinReq->bssDescription.bssId,
1599 session->pLimJoinReq->bssDescription.length + 2);
1600
1601 session->limCurrentBssCaps =
1602 session->pLimJoinReq->bssDescription.capabilityInfo;
1603
1604 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1605 session->currentOperChannel);
1606 local_power_constraint = reg_max;
1607
1608 lim_extract_ap_capability(mac_ctx,
1609 (uint8_t *)
1610 session->pLimJoinReq->bssDescription.ieFields,
1611 lim_get_ielen_from_bss_description(
1612 &session->pLimJoinReq->bssDescription),
1613 &session->limCurrentBssQosCaps,
1614 &session->limCurrentBssPropCap,
1615 &session->gLimCurrentBssUapsd,
1616 &local_power_constraint, session);
1617
Krunal Soni53993f72016-07-08 18:20:03 -07001618 /*
1619 * Once the AP capabilities are available then set the
1620 * beam forming capabilities accordingly.
1621 */
1622 if (session->nss == 1) {
1623 session->vht_config.su_beam_former = 0;
1624 session->vht_config.tx_stbc = 0;
1625 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301626 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001627 }
1628
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001629 session->maxTxPower = lim_get_max_tx_power(reg_max,
1630 local_power_constraint,
1631 mac_ctx->roam.configParam.nTxPowerCap);
Abhinav Kumard528d192018-03-09 17:31:12 +05301632 session->def_max_tx_pwr = session->maxTxPower;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301633
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001634 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301635 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001636
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301637 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1638 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1639 pe_debug("Update MaxTxPower in join Req to %d",
1640 sme_join_req->powerCap.maxTxPower);
1641 }
1642
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001643 if (session->gLimCurrentBssUapsd) {
1644 session->gUapsdPerAcBitmask =
1645 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001646 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001647 session->gUapsdPerAcBitmask);
1648
1649 /* resetting the dynamic uapsd mask */
1650 session->gUapsdPerAcDeliveryEnableMask = 0;
1651 session->gUapsdPerAcTriggerEnableMask = 0;
1652 }
1653
1654 session->limRFBand =
1655 lim_get_rf_band(session->currentOperChannel);
1656
1657 /* Initialize 11h Enable Flag */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001658 if (BAND_5G == session->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001659 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1660 &val) != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001661 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001662 session->lim11hEnable =
1663 WNI_CFG_11H_ENABLED_STADEF;
1664 } else {
1665 session->lim11hEnable = val;
1666 }
1667 } else {
1668 session->lim11hEnable = 0;
1669 }
1670
1671 /*
1672 * To care of the scenario when STA transitions from
1673 * IBSS to Infrastructure mode.
1674 */
1675 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1676
1677 session->limPrevSmeState = session->limSmeState;
1678 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1679 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1680 session->peSessionId,
1681 session->limSmeState));
1682
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001683 /* Indicate whether spectrum management is enabled */
1684 session->spectrumMgtEnabled =
1685 sme_join_req->spectrumMgtIndicator;
1686
1687 /* Enable the spectrum management if this is a DFS channel */
1688 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001689 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001690 session->currentOperChannel))
1691 session->spectrumMgtEnabled = true;
1692
1693 session->isOSENConnection = sme_join_req->isOSENConnection;
1694
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001695 /* Issue LIM_MLM_JOIN_REQ to MLM */
1696 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1697 (uint32_t *) mlm_join_req);
1698 return;
1699
1700 } else {
1701 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001702 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001703 mac_ctx->lim.gLimSmeState);
1704 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1705 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1706 session = NULL;
1707 goto end;
1708 }
1709
1710end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301711 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1712 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001713
1714 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301715 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001716 sme_join_req = NULL;
1717 if (NULL != session)
1718 session->pLimJoinReq = NULL;
1719 }
1720 if (ret_code != eSIR_SME_SUCCESS) {
1721 if (NULL != session) {
1722 pe_delete_session(mac_ctx, session);
1723 session = NULL;
1724 }
1725 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001726 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001727 sme_session_id, ret_code);
1728 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1729 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1730 sme_transaction_id);
1731}
1732
Amar Singhala297bfa2015-10-15 15:07:29 -07001733uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001734 uint8_t iniTxPower)
1735{
1736 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301737 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001738
Anurag Chouhan6d760662016-02-20 16:05:43 +05301739 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001740 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1741 maxTxPower = txPower;
1742 else if (txPower < MIN_TX_PWR_CAP)
1743 maxTxPower = MIN_TX_PWR_CAP;
1744 else
1745 maxTxPower = MAX_TX_PWR_CAP;
1746
1747 return maxTxPower;
1748}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001749
1750/**
1751 * __lim_process_sme_reassoc_req() - process reassoc req
1752 *
1753 * @mac_ctx: Pointer to Global MAC structure
1754 * @msg_buf: pointer to the SME message buffer
1755 *
1756 * This function is called to process SME_REASSOC_REQ message
1757 * from HDD or upper layer application.
1758 *
1759 * Return: None
1760 */
1761
1762static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
1763 uint32_t *msg_buf)
1764{
1765 uint16_t caps;
1766 uint32_t val;
1767 tpSirSmeJoinReq reassoc_req = NULL;
1768 tLimMlmReassocReq *mlm_reassoc_req;
1769 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1770 tpPESession session_entry = NULL;
1771 uint8_t session_id;
1772 uint8_t sme_session_id;
1773 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001774 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001775 uint32_t tele_bcn_en = 0;
1776 uint16_t size;
1777
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001778 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301779 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001780 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001781 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001782
1783 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1784 goto end;
1785 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301786 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787
1788 if (!lim_is_sme_join_req_valid(mac_ctx,
1789 (tpSirSmeJoinReq)reassoc_req)) {
1790 /*
1791 * Received invalid eWNI_SME_REASSOC_REQ
1792 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001793 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001794
1795 ret_code = eSIR_SME_INVALID_PARAMETERS;
1796 goto end;
1797 }
1798
1799 session_entry = pe_find_session_by_bssid(mac_ctx,
1800 reassoc_req->bssDescription.bssId,
1801 &session_id);
1802 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001803 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001804 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
1805 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001806 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001807 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
1808 &sme_session_id, &transaction_id);
1809 session_entry =
1810 pe_find_session_by_sme_session_id(mac_ctx,
1811 sme_session_id);
1812 if (session_entry != NULL)
1813 lim_handle_sme_join_result(mac_ctx,
1814 eSIR_SME_INVALID_PARAMETERS,
1815 eSIR_MAC_UNSPEC_FAILURE_STATUS,
1816 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817 goto end;
1818 }
1819#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
1820 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
1821 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
1822#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1823 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
1824
1825 /* Store the reassoc handle in the session Table */
1826 session_entry->pLimReAssocReq = reassoc_req;
1827
1828 session_entry->dot11mode = reassoc_req->dot11mode;
1829 session_entry->vhtCapability =
1830 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001831
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301832 if (session_entry->vhtCapability) {
1833 if (session_entry->pePersona == QDF_STA_MODE) {
1834 session_entry->vht_config.su_beam_formee =
1835 reassoc_req->vht_config.su_beam_formee;
1836 } else {
1837 reassoc_req->vht_config.su_beam_formee = 0;
1838 }
1839 session_entry->enableVhtpAid =
1840 reassoc_req->enableVhtpAid;
1841 session_entry->enableVhtGid =
1842 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001843 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301844 }
1845
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001846 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301847 session_entry->vhtCapability,
1848 session_entry->vht_config.su_beam_formee,
1849 session_entry->vht_config.su_beam_former);
1850
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001851 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
1852 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001853 session_entry->send_smps_action =
1854 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001855 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001856 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001857 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001858 session_entry->send_smps_action,
1859 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001860 /*
1861 * Reassociate request is expected
1862 * in link established state only.
1863 */
1864
1865 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001866 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
1867 /*
1868 * May be from 11r FT pre-auth. So lets check it
1869 * before we bail out
1870 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001871 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001872 session_entry->peSessionId);
1873
1874 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301875 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001876 session_entry->limReAssocbssId,
1877 6)) {
1878 lim_print_mac_addr(mac_ctx,
1879 reassoc_req->bssDescription.
1880 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001881 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001882 ret_code = eSIR_SME_INVALID_PARAMETERS;
1883 goto end;
1884 }
1885
1886 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
1887 session_entry);
1888 return;
1889 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890 /*
1891 * Should not have received eWNI_SME_REASSOC_REQ
1892 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001893 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001894 session_entry->limSmeState);
1895 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
1896
1897 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1898 goto end;
1899 }
1900
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301901 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001902 session_entry->pLimReAssocReq->bssDescription.bssId,
1903 sizeof(tSirMacAddr));
1904
1905 session_entry->limReassocChannelId =
1906 session_entry->pLimReAssocReq->bssDescription.channelId;
1907
1908 session_entry->reAssocHtSupportedChannelWidthSet =
1909 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
1910 session_entry->reAssocHtRecommendedTxWidthSet =
1911 session_entry->reAssocHtSupportedChannelWidthSet;
1912 session_entry->reAssocHtSecondaryChannelOffset =
1913 session_entry->pLimReAssocReq->cbMode;
1914
1915 session_entry->limReassocBssCaps =
1916 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
1917 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1918 session_entry->currentOperChannel);
1919 local_pwr_constraint = reg_max;
1920
1921 lim_extract_ap_capability(mac_ctx,
1922 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
1923 lim_get_ielen_from_bss_description(
1924 &session_entry->pLimReAssocReq->bssDescription),
1925 &session_entry->limReassocBssQosCaps,
1926 &session_entry->limReassocBssPropCap,
1927 &session_entry->gLimCurrentBssUapsd,
1928 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05301929 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001930 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301931 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001932 /* Copy the SSID from session entry to local variable */
1933 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301934 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001935 reassoc_req->ssId.ssId,
1936 session_entry->limReassocSSID.length);
1937 if (session_entry->gLimCurrentBssUapsd) {
1938 session_entry->gUapsdPerAcBitmask =
1939 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001940 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001941 session_entry->gUapsdPerAcBitmask);
1942 }
1943
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301944 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001945 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001946 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001947
1948 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1949 goto end;
1950 }
1951
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301952 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001953 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
1954
1955 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
1956 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001957 eSIR_SUCCESS)
1958 pe_err("could not retrieve ReassocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001959
1960 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001961 eSIR_SUCCESS)
1962 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301963
1964 lim_update_caps_info_for_bss(mac_ctx, &caps,
1965 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001966 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301967
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001968 mlm_reassoc_req->capabilityInfo = caps;
1969
1970 /* Update PE session_id */
1971 mlm_reassoc_req->sessionId = session_id;
1972
1973 /*
1974 * If telescopic beaconing is enabled, set listen interval to
1975 * WNI_CFG_TELE_BCN_MAX_LI
1976 */
1977 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
1978 &tele_bcn_en) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001979 pe_err("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001980
1981 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
1982
1983 if (tele_bcn_en) {
1984 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
1985 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001986 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987 } else {
1988 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
1989 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001990 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991 }
1992
1993 mlm_reassoc_req->listenInterval = (uint16_t) val;
1994
1995 /* Indicate whether spectrum management is enabled */
1996 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
1997
1998 /* Enable the spectrum management if this is a DFS channel */
1999 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002000 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002001 session_entry->currentOperChannel))
2002 session_entry->spectrumMgtEnabled = true;
2003
2004 session_entry->limPrevSmeState = session_entry->limSmeState;
2005 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2006
2007 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2008 session_entry->peSessionId,
2009 session_entry->limSmeState));
2010
2011 lim_post_mlm_message(mac_ctx,
2012 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2013 return;
2014end:
2015 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302016 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002017 if (session_entry)
2018 session_entry->pLimReAssocReq = NULL;
2019 }
2020
2021 if (session_entry) {
2022 /*
2023 * error occurred after we determined the session so extract
2024 * session and transaction info from there
2025 */
2026 sme_session_id = session_entry->smeSessionId;
2027 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002028 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002029 /*
2030 * error occurred before or during the time we determined
2031 * the session so extract the session and transaction info
2032 * from the message
2033 */
2034 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2035 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002036 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002037 /*
2038 * Send Reassoc failure response to host
2039 * (note session_entry may be NULL, but that's OK)
2040 */
2041 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2042 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2043 session_entry, sme_session_id,
2044 transaction_id);
2045}
2046
2047bool send_disassoc_frame = 1;
2048/**
2049 * __lim_process_sme_disassoc_req()
2050 *
2051 ***FUNCTION:
2052 * This function is called to process SME_DISASSOC_REQ message
2053 * from HDD or upper layer application.
2054 *
2055 ***LOGIC:
2056 *
2057 ***ASSUMPTIONS:
2058 *
2059 ***NOTE:
2060 *
2061 * @param pMac Pointer to Global MAC structure
2062 * @param *pMsgBuf A pointer to the SME message buffer
2063 * @return None
2064 */
2065
2066static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2067{
2068 uint16_t disassocTrigger, reasonCode;
2069 tLimMlmDisassocReq *pMlmDisassocReq;
2070 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2071 tSirSmeDisassocReq smeDisassocReq;
2072 tpPESession psessionEntry = NULL;
2073 uint8_t sessionId;
2074 uint8_t smesessionId;
2075 uint16_t smetransactionId;
2076
2077 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002078 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002079 return;
2080 }
2081
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302082 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002083 smesessionId = smeDisassocReq.sessionId;
2084 smetransactionId = smeDisassocReq.transactionId;
2085 if (!lim_is_sme_disassoc_req_valid(pMac,
2086 &smeDisassocReq,
2087 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002088 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002089 if (pMac->lim.gLimRspReqd) {
2090 pMac->lim.gLimRspReqd = false;
2091
2092 retCode = eSIR_SME_INVALID_PARAMETERS;
2093 disassocTrigger = eLIM_HOST_DISASSOC;
2094 goto sendDisassoc;
2095 }
2096
2097 return;
2098 }
2099
2100 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002101 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002102 &sessionId);
2103 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002104 pe_err("session does not exist for given bssId "
2105 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002106 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002107 retCode = eSIR_SME_INVALID_PARAMETERS;
2108 disassocTrigger = eLIM_HOST_DISASSOC;
2109 goto sendDisassoc;
2110 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002111 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2112 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002113 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2114 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002115 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002116
2117#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2118 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2119 0, smeDisassocReq.reasonCode);
2120#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2121
2122 /* Update SME session Id and SME transaction ID */
2123
2124 psessionEntry->smeSessionId = smesessionId;
2125 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002126 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002127 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002128
2129 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2130 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002131 switch (psessionEntry->limSmeState) {
2132 case eLIM_SME_ASSOCIATED_STATE:
2133 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002134 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002135 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002136 psessionEntry->limPrevSmeState =
2137 psessionEntry->limSmeState;
2138 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002139 /* Delete all TDLS peers connected before leaving BSS */
2140 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002141 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2142 psessionEntry->peSessionId,
2143 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002144 break;
2145
2146 case eLIM_SME_WT_DEAUTH_STATE:
2147 /* PE shall still process the DISASSOC_REQ and proceed with
2148 * link tear down even if it had already sent a DEAUTH_IND to
2149 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2150 * its been set when PE entered WT_DEAUTH_STATE.
2151 */
2152 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2153 MTRACE(mac_trace
2154 (pMac, TRACE_CODE_SME_STATE,
2155 psessionEntry->peSessionId,
2156 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002157 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002158 break;
2159
2160 case eLIM_SME_WT_DISASSOC_STATE:
2161 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2162 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2163 * PE can continue processing DISASSOC_REQ and send the response instead
2164 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2165 * for disassoc frame.
2166 *
2167 * It will send a disassoc, which is ok. However, we can use the global flag
2168 * sendDisassoc to not send disassoc frame.
2169 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002170 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002171 break;
2172
2173 case eLIM_SME_JOIN_FAILURE_STATE: {
2174 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002175 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002176 if (pMac->lim.gLimRspReqd) {
2177 retCode = eSIR_SME_SUCCESS;
2178 disassocTrigger = eLIM_HOST_DISASSOC;
2179 goto sendDisassoc;
2180 }
2181 }
2182 break;
2183 default:
2184 /**
2185 * STA is not currently associated.
2186 * Log error and send response to host
2187 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002188 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002189 psessionEntry->limSmeState);
2190 lim_print_sme_state(pMac, LOGE,
2191 psessionEntry->limSmeState);
2192
2193 if (pMac->lim.gLimRspReqd) {
2194 if (psessionEntry->limSmeState !=
2195 eLIM_SME_WT_ASSOC_STATE)
2196 pMac->lim.gLimRspReqd = false;
2197
2198 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2199 disassocTrigger = eLIM_HOST_DISASSOC;
2200 goto sendDisassoc;
2201 }
2202
2203 return;
2204 }
2205
2206 break;
2207
2208 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002209 /* Fall through */
2210 break;
2211
2212 case eLIM_STA_IN_IBSS_ROLE:
2213 default:
2214 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002215 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002216 GET_LIM_SYSTEM_ROLE(psessionEntry));
2217
2218 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2219 disassocTrigger = eLIM_HOST_DISASSOC;
2220 goto sendDisassoc;
2221 } /* end switch (pMac->lim.gLimSystemRole) */
2222
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302223 disassocTrigger = eLIM_HOST_DISASSOC;
2224 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002225
2226 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002227 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002228 send_disassoc_frame = 0;
2229 }
2230 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002231 pe_debug("Sending Disasscoc with disassoc Trigger"
2232 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002233 disassocTrigger, reasonCode);
2234
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302235 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002236 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002237 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002238 return;
2239 }
2240
Anurag Chouhanc5548422016-02-24 18:33:27 +05302241 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002242 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002243
2244 pMlmDisassocReq->reasonCode = reasonCode;
2245 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2246
2247 /* Update PE session ID */
2248 pMlmDisassocReq->sessionId = sessionId;
2249
2250 lim_post_mlm_message(pMac,
2251 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2252 return;
2253
2254sendDisassoc:
2255 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002256 lim_send_sme_disassoc_ntf(pMac,
2257 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002258 retCode,
2259 disassocTrigger,
2260 1, smesessionId, smetransactionId,
2261 psessionEntry);
2262 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002263 lim_send_sme_disassoc_ntf(pMac,
2264 smeDisassocReq.peer_macaddr.bytes,
2265 retCode, disassocTrigger, 1,
2266 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002267
2268} /*** end __lim_process_sme_disassoc_req() ***/
2269
2270/** -----------------------------------------------------------------
2271 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2272
2273 This function is called to process SME_DISASSOC_CNF message
2274 from HDD or upper layer application.
2275
2276 \param pMac - global mac structure
2277 \param pStaDs - station dph hash node
2278 \return none
2279 \sa
2280 ----------------------------------------------------------------- */
2281static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2282{
2283 tSirSmeDisassocCnf smeDisassocCnf;
2284 uint16_t aid;
2285 tpDphHashNode pStaDs;
2286 tpPESession psessionEntry;
2287 uint8_t sessionId;
2288
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302289 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002290 sizeof(struct sSirSmeDisassocCnf));
2291
2292 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002293 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002294 &sessionId);
2295 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002296 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002297 return;
2298 }
2299
2300 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002301 pe_err("received invalid SME_DISASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002302 return;
2303 }
2304#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2305 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2306 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2307 psessionEntry,
2308 (uint16_t) smeDisassocCnf.statusCode, 0);
2309 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2310 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2311 psessionEntry,
2312 (uint16_t) smeDisassocCnf.statusCode, 0);
2313#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2314
2315 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2316 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002317 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2318 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2319 && (psessionEntry->limSmeState !=
2320 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002321 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002322 psessionEntry->limSmeState);
2323 lim_print_sme_state(pMac, LOGE,
2324 psessionEntry->limSmeState);
2325 return;
2326 }
2327 break;
2328
2329 case eLIM_AP_ROLE:
2330 /* Fall through */
2331 break;
2332
2333 case eLIM_STA_IN_IBSS_ROLE:
2334 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002335 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002336 GET_LIM_SYSTEM_ROLE(psessionEntry));
2337
2338 return;
2339 }
2340
2341 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2342 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2343 LIM_IS_AP_ROLE(psessionEntry)) {
2344 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002345 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002346 &psessionEntry->dph.dphHashTable);
2347 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002348 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2349 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002350 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002351 return;
2352 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302353
2354 if ((pStaDs->mlmStaContext.mlmState ==
2355 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2356 (pStaDs->mlmStaContext.mlmState ==
2357 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002358 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002359 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302360 pStaDs->mlmStaContext.mlmState);
2361 return;
2362 }
2363
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002364 /* Delete FT session if there exists one */
2365 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002366 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2367
2368 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002369 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002370 }
2371
2372 return;
2373}
2374
2375/**
2376 * __lim_process_sme_deauth_req() - process sme deauth req
2377 * @mac_ctx: Pointer to Global MAC structure
2378 * @msg_buf: pointer to the SME message buffer
2379 *
2380 * This function is called to process SME_DEAUTH_REQ message
2381 * from HDD or upper layer application.
2382 *
2383 * Return: None
2384 */
2385
2386static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2387 uint32_t *msg_buf)
2388{
2389 uint16_t deauth_trigger, reason_code;
2390 tLimMlmDeauthReq *mlm_deauth_req;
2391 tSirSmeDeauthReq sme_deauth_req;
2392 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2393 tpPESession session_entry;
2394 uint8_t session_id; /* PE sessionId */
2395 uint8_t sme_session_id;
2396 uint16_t sme_transaction_id;
2397
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302398 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002399 sme_session_id = sme_deauth_req.sessionId;
2400 sme_transaction_id = sme_deauth_req.transactionId;
2401
2402 /*
2403 * We need to get a session first but we don't even know
2404 * if the message is correct.
2405 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002406 session_entry = pe_find_session_by_bssid(mac_ctx,
2407 sme_deauth_req.bssid.bytes,
2408 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002409 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002410 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002411 ret_code = eSIR_SME_INVALID_PARAMETERS;
2412 deauth_trigger = eLIM_HOST_DEAUTH;
2413 goto send_deauth;
2414 }
2415
2416 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2417 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002418 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002419 mac_ctx->lim.gLimRspReqd = false;
2420
2421 ret_code = eSIR_SME_INVALID_PARAMETERS;
2422 deauth_trigger = eLIM_HOST_DEAUTH;
2423 goto send_deauth;
2424 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002425 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2426 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002427 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2428 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002429 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002430#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2431 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2432 session_entry, 0, sme_deauth_req.reasonCode);
2433#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2434
2435 /* Update SME session ID and Transaction ID */
2436 session_entry->smeSessionId = sme_session_id;
2437 session_entry->transactionId = sme_transaction_id;
2438
2439 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2440 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002441 switch (session_entry->limSmeState) {
2442 case eLIM_SME_ASSOCIATED_STATE:
2443 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302444 /* Delete all TDLS peers connected before leaving BSS */
2445 lim_delete_tdls_peers(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002446 case eLIM_SME_WT_ASSOC_STATE:
2447 case eLIM_SME_JOIN_FAILURE_STATE:
2448 case eLIM_SME_IDLE_STATE:
2449 session_entry->limPrevSmeState =
2450 session_entry->limSmeState;
2451 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2452 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2453 session_entry->peSessionId,
2454 session_entry->limSmeState));
2455 /* Send Deauthentication request to MLM below */
2456 break;
2457 case eLIM_SME_WT_DEAUTH_STATE:
2458 case eLIM_SME_WT_DISASSOC_STATE:
2459 /*
2460 * PE Recieved a Deauth/Disassoc frame. Normally it get
2461 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2462 * Which means host is also trying to disconnect.
2463 * PE can continue processing DEAUTH_REQ and send
2464 * the response instead of failing the request.
2465 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2466 * was sent for deauth/disassoc frame.
2467 */
2468 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002469 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002470 break;
2471 default:
2472 /*
2473 * STA is not in a state to deauthenticate with
2474 * peer. Log error and send response to host.
2475 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002476 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002477 session_entry->limSmeState);
2478 lim_print_sme_state(mac_ctx, LOGE,
2479 session_entry->limSmeState);
2480
2481 if (mac_ctx->lim.gLimRspReqd) {
2482 mac_ctx->lim.gLimRspReqd = false;
2483
2484 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2485 deauth_trigger = eLIM_HOST_DEAUTH;
2486
wadesong42968e92017-06-08 14:11:21 +08002487 /*
2488 * here we received deauth request from AP so
2489 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2490 * have ISSUED delSta then mlm state should be
2491 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2492 * delBSS rsp then mlm state should be
2493 * eLIM_MLM_IDLE_STATE so the below condition
2494 * captures the state where delSta not done
2495 * and firmware still in connected state.
2496 */
2497 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002498 eLIM_SME_WT_DEAUTH_STATE &&
2499 session_entry->limMlmState !=
2500 eLIM_MLM_IDLE_STATE &&
2501 session_entry->limMlmState !=
2502 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002503 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002504 goto send_deauth;
2505 }
2506 return;
2507 }
2508 break;
2509
2510 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002511 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002512 if (mac_ctx->lim.gLimRspReqd) {
2513 mac_ctx->lim.gLimRspReqd = false;
2514 ret_code = eSIR_SME_INVALID_PARAMETERS;
2515 deauth_trigger = eLIM_HOST_DEAUTH;
2516 goto send_deauth;
2517 }
2518 return;
2519 case eLIM_AP_ROLE:
2520 break;
2521 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002522 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002523 GET_LIM_SYSTEM_ROLE(session_entry));
2524 if (mac_ctx->lim.gLimRspReqd) {
2525 mac_ctx->lim.gLimRspReqd = false;
2526 ret_code = eSIR_SME_INVALID_PARAMETERS;
2527 deauth_trigger = eLIM_HOST_DEAUTH;
2528 goto send_deauth;
2529 }
2530 return;
2531 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2532
2533 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2534 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002535 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002536 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2537 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2538 } else {
2539 deauth_trigger = eLIM_HOST_DEAUTH;
2540 reason_code = sme_deauth_req.reasonCode;
2541 }
2542
2543 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302544 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002545 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002546 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002547 if (mac_ctx->lim.gLimRspReqd) {
2548 mac_ctx->lim.gLimRspReqd = false;
2549 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2550 deauth_trigger = eLIM_HOST_DEAUTH;
2551 goto send_deauth;
2552 }
2553 return;
2554 }
2555
Anurag Chouhanc5548422016-02-24 18:33:27 +05302556 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002557 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002558
2559 mlm_deauth_req->reasonCode = reason_code;
2560 mlm_deauth_req->deauthTrigger = deauth_trigger;
2561
2562 /* Update PE session Id */
2563 mlm_deauth_req->sessionId = session_id;
2564
2565 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2566 (uint32_t *)mlm_deauth_req);
2567 return;
2568
2569send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002570 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2571 ret_code, deauth_trigger, 1,
2572 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002573}
2574
2575/**
2576 * __lim_process_sme_set_context_req()
2577 *
2578 * @mac_ctx: Pointer to Global MAC structure
2579 * @msg_buf: pointer to the SME message buffer
2580 *
2581 * This function is called to process SME_SETCONTEXT_REQ message
2582 * from HDD or upper layer application.
2583 *
2584 * Return: None
2585 */
2586
2587static void
2588__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2589{
2590 tpSirSmeSetContextReq set_context_req;
2591 tLimMlmSetKeysReq *mlm_set_key_req;
2592 tpPESession session_entry;
2593 uint8_t session_id; /* PE sessionID */
2594 uint8_t sme_session_id;
2595 uint16_t sme_transaction_id;
2596
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002597 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002598 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002599 return;
2600 }
2601
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302602 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002603 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002604 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002605 return;
2606 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302607 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002608 sizeof(struct sSirSmeSetContextReq));
2609 sme_session_id = set_context_req->sessionId;
2610 sme_transaction_id = set_context_req->transactionId;
2611
2612 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002613 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002614 goto end;
2615 }
2616
2617 if (set_context_req->keyMaterial.numKeys >
2618 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002619 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002620 set_context_req->keyMaterial.numKeys);
2621 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002622 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002623 eSIR_SME_INVALID_PARAMETERS, NULL,
2624 sme_session_id, sme_transaction_id);
2625 goto end;
2626 }
2627
2628 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002629 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002630 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002631 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002632 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002633 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002634 eSIR_SME_INVALID_PARAMETERS, NULL,
2635 sme_session_id, sme_transaction_id);
2636 goto end;
2637 }
2638#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2639 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2640 session_entry, 0, 0);
2641#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2642
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002643 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002644 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2645 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002646 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002647 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2648 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302649 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002650 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002651 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002652 goto end;
2653 }
2654 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2655 mlm_set_key_req->numKeys =
2656 set_context_req->keyMaterial.numKeys;
2657 if (mlm_set_key_req->numKeys >
2658 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002659 pe_err("no.of keys exceeded max num of default keys limit");
Jingxiang Ge4168a232018-01-03 18:47:15 +08002660 qdf_mem_free(mlm_set_key_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002661 goto end;
2662 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302663 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002664 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002665
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302666 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002667 (uint8_t *) &set_context_req->keyMaterial.key,
2668 sizeof(tSirKeys) *
2669 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2670 numKeys : 1));
2671
2672 mlm_set_key_req->sessionId = session_id;
2673 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002674 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002675 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002676
2677 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2678 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2679 LIM_IS_AP_ROLE(session_entry)) {
2680 if (set_context_req->keyMaterial.key[0].keyLength) {
2681 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002682
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002683 key_id =
2684 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302685 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002686 &session_entry->WEPKeyMaterial[key_id],
2687 (uint8_t *) &set_context_req->keyMaterial,
2688 sizeof(tSirKeyMaterial));
2689 } else {
2690 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002691
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002692 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2693 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302694 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002695 &mlm_set_key_req->key[i],
2696 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2697 sizeof(tSirKeys));
2698 }
2699 }
2700 }
2701 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2702 (uint32_t *) mlm_set_key_req);
2703 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002704 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002705 GET_LIM_SYSTEM_ROLE(session_entry),
2706 session_entry->limSmeState);
2707 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2708
2709 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002710 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002711 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2712 session_entry, sme_session_id,
2713 sme_transaction_id);
2714 }
2715end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302716 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002717 return;
2718}
2719
2720/**
2721 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2722 *
2723 * @mac_ctx: Pointer to Global MAC structure
2724 * @msg_buf: pointer to the SME message buffer
2725 *
2726 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2727 * from HDD or upper layer application.
2728 *
2729 * Return: None
2730 */
2731
Jeff Johnson801f1532016-10-07 07:54:50 -07002732static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2733 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002734{
2735 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2736 tpDphHashNode sta_ds = NULL;
2737 tpPESession session_entry = NULL;
2738 tSap_Event sap_event;
2739 tpWLAN_SAPEventCB sap_event_cb = NULL;
2740 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2741 uint8_t session_id = CSR_SESSION_ID_INVALID;
2742 uint8_t assoc_id = 0;
2743 uint8_t sta_cnt = 0;
2744
2745 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002746 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002747 return;
2748 }
2749
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302750 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002751 sizeof(struct sSirSmeGetAssocSTAsReq));
2752 /*
2753 * Get Associated stations from PE.
2754 * Find PE session Entry
2755 */
2756 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08002757 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002758 &session_id);
2759 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002760 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002761 goto lim_assoc_sta_end;
2762 }
2763
2764 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002765 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002766 session_entry->limSmeState,
2767 GET_LIM_SYSTEM_ROLE(session_entry));
2768 goto lim_assoc_sta_end;
2769 }
2770 /* Retrieve values obtained in the request message */
2771 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
2772 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2773
2774 if (NULL == assoc_sta_tmp)
2775 goto lim_assoc_sta_end;
2776 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
2777 assoc_id++) {
2778 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
2779 &session_entry->dph.dphHashTable);
2780 if (NULL == sta_ds)
2781 continue;
2782 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302783 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002784 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302785 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002786 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
2787 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
2788
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302789 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002790 (uint8_t *)&sta_ds->supportedRates,
2791 sizeof(tSirSupportedRates));
2792 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
2793 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
2794 assoc_sta_tmp->Support40Mhz =
2795 sta_ds->htDsssCckRate40MHzSupport;
2796
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002797 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002798 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002799 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002800 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002801 pe_debug("Association Id: %d Station Index: %d",
2802 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002803 assoc_sta_tmp++;
2804 sta_cnt++;
2805 }
2806 }
2807lim_assoc_sta_end:
2808 /*
2809 * Call hdd callback with sap event to send the list of
2810 * associated stations from PE
2811 */
2812 if (sap_event_cb != NULL) {
2813 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
2814 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302815 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002816 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
2817 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
2818 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2819 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
2820 }
2821}
2822
2823/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002824 * __lim_counter_measures()
2825 *
2826 * FUNCTION:
2827 * This function is called to "implement" MIC counter measure
2828 * and is *temporary* only
2829 *
2830 * LOGIC: on AP, disassoc all STA associated thru TKIP,
2831 * we don't do the proper STA disassoc sequence since the
2832 * BSS will be stoped anyway
2833 *
2834 ***ASSUMPTIONS:
2835 *
2836 ***NOTE:
2837 *
2838 * @param pMac Pointer to Global MAC structure
2839 * @return None
2840 */
2841
2842static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
2843{
2844 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002845
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002846 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002847 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
2848 mac, psessionEntry, false);
2849};
2850
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002851static void
2852__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2853{
2854 tSirSmeStopBssReq stopBssReq;
2855 tSirRetStatus status;
2856 tLimSmeStates prevState;
2857 tpPESession psessionEntry;
2858 uint8_t smesessionId;
2859 uint8_t sessionId;
2860 uint16_t smetransactionId;
2861 uint8_t i = 0;
2862 tpDphHashNode pStaDs = NULL;
2863
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302864 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002865 smesessionId = stopBssReq.sessionId;
2866 smetransactionId = stopBssReq.transactionId;
2867
2868 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002869 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002870 /* Send Stop BSS response to host */
2871 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2872 eSIR_SME_INVALID_PARAMETERS, smesessionId,
2873 smetransactionId);
2874 return;
2875 }
2876
2877 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08002878 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002879 &sessionId);
2880 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002881 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002882 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2883 eSIR_SME_INVALID_PARAMETERS, smesessionId,
2884 smetransactionId);
2885 return;
2886 }
2887#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2888 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
2889 0, 0);
2890#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2891
2892 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
2893 LIM_IS_STA_ROLE(psessionEntry)) {
2894 /**
2895 * Should not have received STOP_BSS_REQ in states
2896 * other than 'normal' state or on STA in Infrastructure
2897 * mode. Log error and return response to host.
2898 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002899 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002900 psessionEntry->limSmeState,
2901 GET_LIM_SYSTEM_ROLE(psessionEntry));
2902 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
2903 /* / Send Stop BSS response to host */
2904 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2905 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
2906 smetransactionId);
2907 return;
2908 }
2909
2910 if (LIM_IS_AP_ROLE(psessionEntry))
2911 lim_wpspbc_close(pMac, psessionEntry);
2912
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002913 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002914 stopBssReq.reasonCode);
2915
2916 prevState = psessionEntry->limSmeState;
2917
2918 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
2919 MTRACE(mac_trace
2920 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
2921 psessionEntry->limSmeState));
2922
2923 /* Update SME session Id and Transaction Id */
2924 psessionEntry->smeSessionId = smesessionId;
2925 psessionEntry->transactionId = smetransactionId;
2926
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002927 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
2928 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
2929 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002930 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002931
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002932 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
2933 /* Send disassoc all stations associated thru TKIP */
2934 __lim_counter_measures(pMac, psessionEntry);
2935 else
2936 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002937 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
2938 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002939 }
2940
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002941 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
2942 /* Free the buffer allocated in START_BSS_REQ */
2943 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
2944 psessionEntry->addIeParams.probeRespDataLen = 0;
2945 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002946
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002947 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
2948 psessionEntry->addIeParams.assocRespDataLen = 0;
2949 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002950
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002951 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
2952 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
2953 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002954
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002955 /*
2956 * lim_del_bss is also called as part of coalescing,
2957 * when we send DEL BSS followed by Add Bss msg.
2958 */
2959 pMac->lim.gLimIbssCoalescingHappened = false;
2960 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002961 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
2962 pStaDs =
2963 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
2964 if (NULL == pStaDs)
2965 continue;
2966 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
2967 if (eSIR_SUCCESS == status) {
2968 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
2969 pStaDs->assocId, psessionEntry);
2970 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
2971 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002972 pe_err("lim_del_sta failed with Status: %d", status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302973 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002974 }
2975 }
2976 /* send a delBss to HAL and wait for a response */
2977 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
2978
2979 if (status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002980 pe_err("delBss failed for bss %d", psessionEntry->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002981 psessionEntry->limSmeState = prevState;
2982
2983 MTRACE(mac_trace
2984 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
2985 psessionEntry->limSmeState));
2986
2987 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2988 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
2989 smetransactionId);
2990 }
2991}
2992
2993/**
2994 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
2995 * @pMac: Global MAC context
2996 * @pMsg: Message from SME
2997 *
2998 * Wrapper for the function __lim_handle_sme_stop_bss_request
2999 * This message will be defered until softmac come out of
3000 * scan mode. Message should be handled even if we have
3001 * detected radar in the current operating channel.
3002 *
3003 * Return: true - If we consumed the buffer
3004 * false - If have defered the message.
3005 */
3006
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003007static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3008 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003009{
3010 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3011 /**
3012 * If message defered, buffer is not consumed yet.
3013 * So return false
3014 */
3015 return false;
3016 }
3017 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3018 return true;
3019} /*** end __lim_process_sme_stop_bss_req() ***/
3020
3021void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3022 uint32_t body, tpPESession psessionEntry)
3023{
3024
3025 (void)body;
3026 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3027 lim_ibss_delete(pMac, psessionEntry);
3028 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3029 lim_delete_pre_auth_list(pMac);
3030 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3031 psessionEntry->smeSessionId,
3032 psessionEntry->transactionId);
3033 return;
3034}
3035
3036/**
3037 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3038 *
3039 * @mac_ctx: pointer to mac context
3040 * @msg_type: message type
3041 * @msg_buf: pointer to the SME message buffer
3042 *
3043 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3044 * in BTAMP AP.
3045 *
3046 * Return: None
3047 */
3048
3049void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3050 uint32_t *msg_buf)
3051{
3052 tSirSmeAssocCnf assoc_cnf;
3053 tpDphHashNode sta_ds = NULL;
3054 tpPESession session_entry = NULL;
3055 uint8_t session_id;
3056 tpSirAssocReq assoc_req;
3057
3058 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003059 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003060 goto end;
3061 }
3062
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303063 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003064 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003065 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003066 goto end;
3067 }
3068
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003069 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003070 &session_id);
3071 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003072 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003073 goto end;
3074 }
3075
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003076 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003077 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3078 (session_entry->limSmeState !=
3079 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003080 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003081 msg_type, session_entry->limSmeState,
3082 GET_LIM_SYSTEM_ROLE(session_entry));
3083 goto end;
3084 }
3085 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3086 &session_entry->dph.dphHashTable);
3087 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003088 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003089 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303090 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003091
3092 /*
3093 * send a DISASSOC_IND message to WSM to make sure
3094 * the state in WSM and LIM is the same
3095 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003096 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003097 eSIR_SME_STA_NOT_ASSOCIATED,
3098 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3099 session_entry->smeSessionId,
3100 session_entry->transactionId,
3101 session_entry);
3102 goto end;
3103 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303104 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003105 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303106 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003107 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003108 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303109 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003110 goto end;
3111 }
3112
3113 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3114 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3115 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3116 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3117 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003118 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3119 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003120 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303121 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003122 goto end;
3123 }
3124 /*
3125 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3126 * has been received
3127 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003128 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003129 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3130 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3131
3132 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3133 /*
3134 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3135 * when it had received Assoc Request frame. Now, PE just needs
3136 * to send association rsp frame to the requesting BTAMP-STA.
3137 */
3138 sta_ds->mlmStaContext.mlmState =
3139 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003140 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003141 sta_ds->assocId);
3142 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3143 sta_ds->assocId, sta_ds->staAddr,
3144 sta_ds->mlmStaContext.subType, sta_ds,
3145 session_entry);
3146 goto end;
3147 } else {
3148 /*
3149 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3150 * to be associated since the HAL sta entry is created for
3151 * denied STA we need to remove this HAL entry.
3152 * So to do that set updateContext to 1
3153 */
3154 if (!sta_ds->mlmStaContext.updateContext)
3155 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003156 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003157 assoc_cnf.statusCode, sta_ds->assocId);
3158 lim_reject_association(mac_ctx, sta_ds->staAddr,
3159 sta_ds->mlmStaContext.subType,
3160 true, sta_ds->mlmStaContext.authType,
3161 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003162 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003163 session_entry);
3164 }
3165end:
3166 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3167 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3168 assoc_req = (tpSirAssocReq)
3169 session_entry->parsedAssocReq[sta_ds->assocId];
3170 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303171 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003172 assoc_req->assocReqFrame = NULL;
3173 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303174 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003175 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3176 }
3177}
3178
3179static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3180{
3181 tpDphHashNode pStaDs;
3182 tSirMacAddr peerMac;
3183 tpSirAddtsReq pSirAddts;
3184 uint32_t timeout;
3185 tpPESession psessionEntry;
3186 uint8_t sessionId; /* PE sessionId */
3187 uint8_t smesessionId;
3188 uint16_t smetransactionId;
3189
3190 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003191 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192 return;
3193 }
3194
3195 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3196 &smetransactionId);
3197
3198 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3199
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003200 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3201 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003202 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003203 pe_err("Session Does not exist for given bssId");
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303204 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3205 NULL, pSirAddts->req.tspec,
3206 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003207 return;
3208 }
3209#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3210 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3211 0);
3212#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3213
3214 /* if sta
3215 * - verify assoc state
3216 * - send addts request to ap
3217 * - wait for addts response from ap
3218 * if ap, just ignore with error log
3219 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003220 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3221 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3222 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003223
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003224 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003225 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303226 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003227 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003228
3229 pStaDs =
3230 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3231 &psessionEntry->dph.dphHashTable);
3232
3233 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003234 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303235 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003236 }
3237
3238 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3239 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003240 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303241 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003242 }
3243
3244 pSirAddts->req.wsmTspecPresent = 0;
3245 pSirAddts->req.wmeTspecPresent = 0;
3246 pSirAddts->req.lleTspecPresent = 0;
3247
3248 if ((pStaDs->wsmEnabled) &&
3249 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3250 SIR_MAC_ACCESSPOLICY_EDCA))
3251 pSirAddts->req.wsmTspecPresent = 1;
3252 else if (pStaDs->wmeEnabled)
3253 pSirAddts->req.wmeTspecPresent = 1;
3254 else if (pStaDs->lleEnabled)
3255 pSirAddts->req.lleTspecPresent = 1;
3256 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003257 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303258 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003259 }
3260
3261 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3262 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003263 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003264 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303265 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003266 }
3267
3268 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003269 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003270 pMac->lim.gLimAddtsReq.req.dialogToken,
3271 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3272 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3273 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303274 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003275 }
3276
3277 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3278
3279 /* save the addts request */
3280 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303281 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003282 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3283
3284 /* ship out the message now */
3285 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3286 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303287 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003288 /* start a timer to wait for the response */
3289 if (pSirAddts->timeout)
3290 timeout = pSirAddts->timeout;
3291 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3292 eSIR_SUCCESS) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303293 pe_debug("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003294 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303295 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003296 }
3297
3298 timeout = SYS_MS_TO_TICKS(timeout);
3299 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3300 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003301 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303302 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003303 }
3304 pMac->lim.gLimAddtsRspTimerCount++;
3305 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3306 pMac->lim.gLimAddtsRspTimerCount) !=
3307 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003308 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303309 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003310 }
3311 MTRACE(mac_trace
3312 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3313 eLIM_ADDTS_RSP_TIMER));
3314
3315 /* add the sessionId to the timer object */
3316 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3317 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3318 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003319 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303320 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321 }
3322 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303323
3324send_failure_addts_rsp:
3325 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3326 psessionEntry, pSirAddts->req.tspec,
3327 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003328}
3329
3330static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3331{
3332 tSirMacAddr peerMacAddr;
3333 uint8_t ac;
3334 tSirMacTSInfo *pTsinfo;
3335 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3336 tpDphHashNode pStaDs = NULL;
3337 tpPESession psessionEntry;
3338 uint8_t sessionId;
3339 uint32_t status = eSIR_SUCCESS;
3340 uint8_t smesessionId;
3341 uint16_t smetransactionId;
3342
3343 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3344 &smetransactionId);
3345
3346 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003347 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003348 &sessionId);
3349 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003350 pe_err("Session Does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003351 status = eSIR_FAILURE;
3352 goto end;
3353 }
3354#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3355 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3356 0);
3357#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3358
3359 if (eSIR_SUCCESS !=
3360 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003361 pe_err("lim_validate_delts_req failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003362 status = eSIR_FAILURE;
3363 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3364 smesessionId, smetransactionId);
3365 return;
3366 }
3367
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003368 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3369 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003370 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3371
3372 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3373 pDeltsReq->req.wmeTspecPresent,
3374 &pDeltsReq->req.tsinfo,
3375 &pDeltsReq->req.tspec, psessionEntry);
3376
3377 pTsinfo =
3378 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3379 tsinfo : &pDeltsReq->req.tsinfo;
3380
3381 /* We've successfully send DELTS frame to AP. Update the
3382 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3383 * is no longer trigger enabled or delivery enabled
3384 */
3385 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3386 pTsinfo, CLEAR_UAPSD_MASK);
3387
3388 /* We're deleting the TSPEC, so this particular AC is no longer
3389 * admitted. PE needs to downgrade the EDCA
3390 * parameters(for the AC for which TS is being deleted) to the
3391 * next best AC for which ACM is not enabled, and send the
3392 * updated values to HAL.
3393 */
3394 ac = upToAc(pTsinfo->traffic.userPrio);
3395
3396 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3397 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3398 ~(1 << ac);
3399 } else if (pTsinfo->traffic.direction ==
3400 SIR_MAC_DIRECTION_DNLINK) {
3401 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3402 ~(1 << ac);
3403 } else if (pTsinfo->traffic.direction ==
3404 SIR_MAC_DIRECTION_BIDIR) {
3405 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3406 ~(1 << ac);
3407 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3408 ~(1 << ac);
3409 }
3410
3411 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3412 psessionEntry);
3413
3414 pStaDs =
3415 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3416 &psessionEntry->dph.dphHashTable);
3417 if (pStaDs != NULL) {
3418 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3419 pStaDs->bssId);
3420 status = eSIR_SUCCESS;
3421 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003422 pe_err("Self entry missing in Hash Table");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003423 status = eSIR_FAILURE;
3424 }
3425#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003426 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003427#endif
3428
3429 /* send an sme response back */
3430end:
3431 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3432 smesessionId, smetransactionId);
3433}
3434
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303435void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436{
3437 /* fetch the sessionEntry based on the sessionId */
3438 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003439
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003440 psessionEntry = pe_find_session_by_session_id(pMac,
3441 pMac->lim.limTimers.gLimAddtsRspTimer.
3442 sessionId);
3443 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003444 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003445 return;
3446 }
3447
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003448 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003449 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003450 GET_LIM_SYSTEM_ROLE(psessionEntry));
3451 pMac->lim.gLimAddtsSent = false;
3452 return;
3453 }
3454
3455 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003456 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003457 return;
3458 }
3459
3460 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003461 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462 pMac->lim.gLimAddtsRspTimerCount);
3463 return;
3464 }
3465 /* this a real response timeout */
3466 pMac->lim.gLimAddtsSent = false;
3467 pMac->lim.gLimAddtsRspTimerCount++;
3468
3469 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3470 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3471 psessionEntry->smeSessionId,
3472 psessionEntry->transactionId);
3473}
3474
3475/**
3476 * __lim_process_sme_get_statistics_request()
3477 *
3478 ***FUNCTION:
3479 *
3480 *
3481 ***NOTE:
3482 *
3483 * @param pMac Pointer to Global MAC structure
3484 * @param *pMsgBuf A pointer to the SME message buffer
3485 * @return None
3486 */
3487static void
3488__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3489{
3490 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003491 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003492
3493 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3494
3495 msgQ.type = WMA_GET_STATISTICS_REQ;
3496
3497 msgQ.reserved = 0;
3498 msgQ.bodyptr = pMsgBuf;
3499 msgQ.bodyval = 0;
3500 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3501
3502 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303503 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003504 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003505 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003506 return;
3507 }
3508
3509 return;
3510}
3511
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003512#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003513/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003514 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003515 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003516 * @pMac: Pointer to Global MAC structure
3517 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003518 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003519 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003520 */
3521static void
3522__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3523{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003524 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003525
3526 msgQ.type = WMA_TSM_STATS_REQ;
3527 msgQ.reserved = 0;
3528 msgQ.bodyptr = pMsgBuf;
3529 msgQ.bodyval = 0;
3530 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3531
3532 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303533 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003534 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003535 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003536 return;
3537 }
3538}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003539#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003540
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08003541static void lim_process_sme_set_addba_accept(tpAniSirGlobal mac_ctx,
3542 struct sme_addba_accept *msg)
3543{
3544 if (!msg) {
3545 pe_err("Msg Buffer is NULL");
3546 return;
3547 }
3548 if (!msg->addba_accept)
3549 mac_ctx->reject_addba_req = 1;
3550 else
3551 mac_ctx->reject_addba_req = 0;
3552}
3553
Arif Hussaineb8ba362018-03-07 19:15:13 -08003554static void lim_process_sme_update_edca_params(tpAniSirGlobal mac_ctx,
3555 uint32_t sme_session_id)
3556{
3557 tpPESession pe_session;
3558 tpDphHashNode sta_ds_ptr;
3559
3560 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3561 if (!pe_session) {
3562 pe_err("Session does not exist: sme_id %d", sme_session_id);
3563 return;
3564 }
3565 pe_session->gLimEdcaParamsActive[EDCA_AC_BE].no_ack =
3566 mac_ctx->no_ack_policy_cfg[EDCA_AC_BE];
3567 pe_session->gLimEdcaParamsActive[EDCA_AC_BK].no_ack =
3568 mac_ctx->no_ack_policy_cfg[EDCA_AC_BK];
3569 pe_session->gLimEdcaParamsActive[EDCA_AC_VI].no_ack =
3570 mac_ctx->no_ack_policy_cfg[EDCA_AC_VI];
3571 pe_session->gLimEdcaParamsActive[EDCA_AC_VO].no_ack =
3572 mac_ctx->no_ack_policy_cfg[EDCA_AC_VO];
3573 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3574 &pe_session->dph.dphHashTable);
3575 if (sta_ds_ptr)
3576 lim_send_edca_params(mac_ctx,
3577 pe_session->gLimEdcaParamsActive,
3578 sta_ds_ptr->bssId);
3579 else
3580 pe_err("Self entry missing in Hash Table");
3581}
3582
Naveen Rawat8029a402017-06-01 10:54:19 -07003583static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3584 struct update_config *msg)
3585{
3586 tpPESession pe_session;
3587
3588 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3589 if (msg == NULL) {
3590 pe_err("Buffer is Pointing to NULL");
3591 return;
3592 }
3593
3594 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3595 msg->sme_session_id);
3596 if (pe_session == NULL) {
3597 pe_warn("Session does not exist for given BSSID");
3598 return;
3599 }
3600
3601 switch (msg->capab) {
3602 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3603 pe_session->htConfig.ht_rx_ldpc = msg->value;
3604 break;
3605 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3606 pe_session->htConfig.ht_tx_stbc = msg->value;
3607 break;
3608 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3609 pe_session->htConfig.ht_rx_stbc = msg->value;
3610 break;
3611 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3612 pe_session->htConfig.ht_sgi20 = msg->value;
3613 break;
3614 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3615 pe_session->htConfig.ht_sgi40 = msg->value;
3616 break;
3617 }
3618
3619 if (LIM_IS_AP_ROLE(pe_session)) {
3620 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3621 lim_send_beacon_ind(mac_ctx, pe_session);
3622 }
3623}
3624
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003625void
3626lim_send_vdev_restart(tpAniSirGlobal pMac,
3627 tpPESession psessionEntry, uint8_t sessionId)
3628{
3629 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003630 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003631 tSirRetStatus retCode = eSIR_SUCCESS;
3632
3633 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003634 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003635 return;
3636 }
3637
3638 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303639 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003640 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003641 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003642 return;
3643 }
3644
3645 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3646 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003647 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003648
3649 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3650 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3651 msgQ.bodyval = 0;
3652
3653 retCode = wma_post_ctrl_msg(pMac, &msgQ);
3654 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003655 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303656 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003657 }
3658}
3659
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303660/**
3661 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3662 * @mac_ctx: Pointer to Global MAC structure
3663 * @msg_buf: Pointer to SME message buffer
3664 *
3665 * Return: None
3666 */
3667static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3668 uint32_t *msg_buf)
3669{
3670 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003671 struct scheduler_msg wma_msg = {0};
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303672 tSirRetStatus status;
3673 tSirRoamOffloadScanReq *req_buffer;
3674 uint16_t local_ie_len;
3675 uint8_t *local_ie_buf;
3676
3677 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3678 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3679 req_buffer->sessionId);
3680
3681 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3682 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003683 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303684 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303685 return;
3686 }
3687
3688 local_ie_len = req_buffer->assoc_ie.length;
3689 /* Update ext cap IE if present */
3690 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003691 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3692 local_ie_buf, &local_ie_len)) {
3693 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003694 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3695 req_buffer->assoc_ie.length = local_ie_len;
3696 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3697 local_ie_buf, local_ie_len);
3698 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303699 }
3700 qdf_mem_free(local_ie_buf);
3701
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303702 if (pe_session)
3703 lim_update_fils_rik(pe_session, req_buffer);
3704
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303705 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3706 wma_msg.bodyptr = req_buffer;
3707
3708 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
3709 if (eSIR_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003710 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303711 qdf_mem_free(req_buffer);
3712 }
3713}
3714
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303715/*
3716 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3717 * @mac_ctx: Pointer to global mac context
3718 * @session: Pointer to PE session
3719 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3720 * 1 - Disable broadcast SSID
3721 *
3722 * Return: None
3723 */
3724static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3725 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003726{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003727 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003728 session->ssidHidden, ssid_hidden);
3729
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003730 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303731 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003732 } else {
3733 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05303734 return;
3735 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003736
3737 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303738 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003739
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003740 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303741}
3742
3743/**
3744 * __lim_process_sme_session_update - process SME session update msg
3745 *
3746 * @mac_ctx: Pointer to global mac context
3747 * @msg_buf: Pointer to the received message buffer
3748 *
3749 * Return: None
3750 */
3751static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
3752 uint32_t *msg_buf)
3753{
3754 struct sir_update_session_param *msg;
3755 tpPESession session;
3756
3757 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003758 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303759 return;
3760 }
3761
3762 msg = (struct sir_update_session_param *) msg_buf;
3763
3764 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
3765 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003766 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303767 msg->session_id);
3768 return;
3769 }
3770
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003771 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303772 msg->param_type, msg->param_val);
3773 switch (msg->param_type) {
3774 case SIR_PARAM_SSID_HIDDEN:
3775 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
3776 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303777 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
3778 session->ignore_assoc_disallowed = msg->param_val;
3779 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303780 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003781 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303782 break;
3783 }
3784}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003785
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003786/*
3787 Update the beacon Interval dynamically if beaconInterval is different in MCC
3788 */
3789static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3790{
3791 tpSirChangeBIParams pChangeBIParams;
3792 tpPESession psessionEntry;
3793 uint8_t sessionId = 0;
3794 tUpdateBeaconParams beaconParams;
3795
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003796 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003797
3798 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003799 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003800 return;
3801 }
3802
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303803 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003804 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
3805
3806 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08003807 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003808 &sessionId);
3809 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003810 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003811 return;
3812 }
3813
3814 /*Update sessionEntry Beacon Interval */
3815 if (psessionEntry->beaconParams.beaconInterval !=
3816 pChangeBIParams->beaconInterval) {
3817 psessionEntry->beaconParams.beaconInterval =
3818 pChangeBIParams->beaconInterval;
3819 }
3820
3821 /*Update sch beaconInterval */
3822 if (pMac->sch.schObject.gSchBeaconInterval !=
3823 pChangeBIParams->beaconInterval) {
3824 pMac->sch.schObject.gSchBeaconInterval =
3825 pChangeBIParams->beaconInterval;
3826
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003827 pe_debug("LIM send update BeaconInterval Indication: %d",
3828 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003829
3830 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
3831 /* Update beacon */
3832 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3833
3834 beaconParams.bssIdx = psessionEntry->bssIdx;
3835 /* Set change in beacon Interval */
3836 beaconParams.beaconInterval =
3837 pChangeBIParams->beaconInterval;
3838 beaconParams.paramChangeBitmap =
3839 PARAM_BCN_INTERVAL_CHANGED;
3840 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
3841 }
3842 }
3843
3844 return;
3845} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
3846
3847#ifdef QCA_HT_2040_COEX
3848static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
3849 uint32_t *pMsgBuf)
3850{
3851 tpSirSetHT2040Mode pSetHT2040Mode;
3852 tpPESession psessionEntry;
3853 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003854 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003855 tUpdateVHTOpMode *pHtOpMode = NULL;
3856 uint16_t staId = 0;
3857 tpDphHashNode pStaDs = NULL;
3858
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003859 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003860 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003861 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003862 return;
3863 }
3864
3865 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
3866
3867 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08003868 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003869 &sessionId);
3870 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003871 pe_debug("Session does not exist for given BSSID");
3872 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003873 return;
3874 }
3875
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003876 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003877 pSetHT2040Mode->cbMode);
3878 /*Update sessionEntry HT related fields */
3879 switch (pSetHT2040Mode->cbMode) {
3880 case PHY_SINGLE_CHANNEL_CENTERED:
3881 psessionEntry->htSecondaryChannelOffset =
3882 PHY_SINGLE_CHANNEL_CENTERED;
3883 psessionEntry->htRecommendedTxWidthSet = 0;
3884 if (pSetHT2040Mode->obssEnabled)
3885 psessionEntry->htSupportedChannelWidthSet
3886 = eHT_CHANNEL_WIDTH_40MHZ;
3887 else
3888 psessionEntry->htSupportedChannelWidthSet
3889 = eHT_CHANNEL_WIDTH_20MHZ;
3890 break;
3891 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
3892 psessionEntry->htSecondaryChannelOffset =
3893 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3894 psessionEntry->htRecommendedTxWidthSet = 1;
3895 break;
3896 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
3897 psessionEntry->htSecondaryChannelOffset =
3898 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3899 psessionEntry->htRecommendedTxWidthSet = 1;
3900 break;
3901 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003902 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003903 return;
3904 }
3905
3906 /* Update beacon */
3907 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3908 lim_send_beacon_ind(pMac, psessionEntry);
3909
3910 /* update OP Mode for each associated peer */
3911 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
3912 pStaDs = dph_get_hash_entry(pMac, staId,
3913 &psessionEntry->dph.dphHashTable);
3914 if (NULL == pStaDs)
3915 continue;
3916
3917 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303918 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003919 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003920 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003921 return;
3922 }
3923 pHtOpMode->opMode =
3924 (psessionEntry->htSecondaryChannelOffset ==
3925 PHY_SINGLE_CHANNEL_CENTERED) ?
3926 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
3927 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303928 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003929 sizeof(tSirMacAddr));
3930 pHtOpMode->smesessionId = sessionId;
3931
3932 msg.type = WMA_UPDATE_OP_MODE;
3933 msg.reserved = 0;
3934 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003935 if (!QDF_IS_STATUS_SUCCESS
3936 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
3937 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303938 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003939 return;
3940 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003941 pe_debug("Notifed FW about OP mode: %d for staId=%d",
3942 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003943
3944 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003945 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003946 }
3947
3948 return;
3949}
3950#endif
3951
3952/* -------------------------------------------------------------------- */
3953/**
3954 * __lim_process_report_message
3955 *
3956 * FUNCTION: Processes the next received Radio Resource Management message
3957 *
3958 * LOGIC:
3959 *
3960 * ASSUMPTIONS:
3961 *
3962 * NOTE:
3963 *
3964 * @param None
3965 * @return None
3966 */
3967
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003968static void __lim_process_report_message(tpAniSirGlobal pMac,
3969 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003970{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003971 switch (pMsg->type) {
3972 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
3973 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
3974 break;
3975 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003976 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08003977 break;
3978 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003979 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003980 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003981}
3982
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003983/* -------------------------------------------------------------------- */
3984/**
3985 * lim_send_set_max_tx_power_req
3986 *
3987 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
3988 *
3989 * LOGIC:
3990 *
3991 * ASSUMPTIONS:
3992 *
3993 * NOTE:
3994 *
3995 * @param txPower txPower to be set.
3996 * @param pSessionEntry session entry.
3997 * @return None
3998 */
3999tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004000lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004001 tpPESession pSessionEntry)
4002{
4003 tpMaxTxPowerParams pMaxTxParams = NULL;
4004 tSirRetStatus retCode = eSIR_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004005 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004006
4007 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004008 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004009 return eSIR_FAILURE;
4010 }
4011
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304012 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004013 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004014 pe_err("Unable to allocate memory for pMaxTxParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004015 return eSIR_MEM_ALLOC_FAILED;
4016
4017 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004018 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304019 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304020 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304021 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004022 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304023 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004024
4025 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4026 msgQ.bodyptr = pMaxTxParams;
4027 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004028 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004029 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4030 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4031 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004032 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304033 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004034 }
4035 return retCode;
4036}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004037
4038/**
4039 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4040 *
4041 * @mac_ctx: Pointer to Global MAC structure
4042 * @msg_buf: pointer to the SME message buffer
4043 *
4044 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4045 * from SME. It Register this information within PE.
4046 *
4047 * Return: None
4048 */
4049static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4050 uint32_t *msg_buf)
4051{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304052 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004053 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4054 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4055 struct mgmt_frm_reg_info *next = NULL;
4056 bool match = false;
4057
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004058 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004059 sme_req->registerFrame, sme_req->frameType,
4060 sme_req->matchLen);
4061 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304062 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304063 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4064 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304065 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004066
4067 while (lim_mgmt_regn != NULL) {
4068 if (lim_mgmt_regn->frameType != sme_req->frameType)
4069 goto skip_match;
4070 if (sme_req->matchLen) {
4071 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304072 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004073 sme_req->matchData,
4074 lim_mgmt_regn->matchLen))) {
4075 /* found match! */
4076 match = true;
4077 break;
4078 }
4079 } else {
4080 /* found match! */
4081 match = true;
4082 break;
4083 }
4084skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304085 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304086 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004087 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304088 (qdf_list_node_t *)lim_mgmt_regn,
4089 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304090 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004091 lim_mgmt_regn = next;
4092 next = NULL;
4093 }
4094 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304095 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004096 if (QDF_STATUS_SUCCESS ==
4097 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004098 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004099 (qdf_list_node_t *)lim_mgmt_regn))
4100 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304101 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004102 }
4103
4104 if (sme_req->registerFrame) {
4105 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304106 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004107 sme_req->matchLen);
4108 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004109 lim_mgmt_regn->frameType = sme_req->frameType;
4110 lim_mgmt_regn->matchLen = sme_req->matchLen;
4111 lim_mgmt_regn->sessionId = sme_req->sessionId;
4112 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304113 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004114 sme_req->matchData,
4115 sme_req->matchLen);
4116 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304117 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004118 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304119 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004120 gLimMgmtFrameRegistratinQueue,
4121 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304122 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004123 &mac_ctx->lim.lim_frame_register_lock);
4124 }
4125 }
4126 return;
4127}
4128
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004129static void
4130__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4131{
4132 tpSirResetAPCapsChange pResetCapsChange;
4133 tpPESession psessionEntry;
4134 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004135
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004136 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004137 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004138 return;
4139 }
4140
4141 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4142 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004143 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4144 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004145 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004146 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004147 return;
4148 }
4149
4150 psessionEntry->limSentCapsChangeNtf = false;
4151 return;
4152}
4153
4154/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304155 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4156 * indication callback in PE.
4157 * @mac_ptr: Mac pointer
4158 * @msg_buf: Msg pointer containing the callback
4159 *
4160 * This function is used save the Management frame
4161 * indication callback in PE.
4162 *
4163 * Return: None
4164 */
4165static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4166 uint32_t *msg_buf)
4167{
4168 struct sir_sme_mgmt_frame_cb_req *sme_req =
4169 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4170
4171 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004172 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304173 return;
4174 }
4175 if (sme_req->callback)
4176 mac_ctx->mgmt_frame_ind_cb =
4177 (sir_mgmt_frame_ind_callback)sme_req->callback;
4178 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004179 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304180}
4181
4182/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304183 *__lim_process_send_disassoc_frame: function processes disassoc frame
4184 * @mac_ctx: pointer to mac context
4185 * @msg_buf: message buffer
4186 *
4187 * function processes disassoc request received from SME
4188 *
4189 * return: none
4190 */
4191static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4192 uint32_t *msg_buf)
4193{
4194 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4195 tSirRetStatus status;
4196 tpPESession session_entry = NULL;
4197 uint8_t sme_session_id;
4198 uint16_t sme_trans_id;
4199
4200 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004201 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304202 return;
4203 }
4204
4205 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4206 &sme_trans_id);
4207
4208 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4209 &sme_send_disassoc_frame_req,
4210 (uint8_t *)msg_buf);
4211
4212 if ((eSIR_FAILURE == status) ||
4213 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4214 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004215 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304216 return;
4217 }
4218
4219 session_entry = pe_find_session_by_sme_session_id(
4220 mac_ctx, sme_session_id);
4221 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004222 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304223 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4224 return;
4225 }
4226
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004227 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 +05304228 sme_send_disassoc_frame_req.msg_type,
4229 sme_send_disassoc_frame_req.length,
4230 sme_send_disassoc_frame_req.session_id,
4231 sme_send_disassoc_frame_req.trans_id,
4232 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4233 sme_send_disassoc_frame_req.reason,
4234 sme_send_disassoc_frame_req.wait_for_ack);
4235
4236 lim_send_disassoc_mgmt_frame(mac_ctx,
4237 sme_send_disassoc_frame_req.reason,
4238 sme_send_disassoc_frame_req.peer_mac,
4239 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4240}
4241
4242/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004243 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4244 * @mac_ctx: Pointer to Global MAC structure
4245 * @pdev_id: pdev id to set the IE.
4246 * @nss: Nss values to prepare the HT IE.
4247 *
4248 * Prepares the HT IE with self capabilities for different
4249 * Nss values and sends the set HT IE req to FW.
4250 *
4251 * Return: None
4252 */
4253static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4254 uint8_t nss)
4255{
4256 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004257 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004258 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004259 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004260 tHtCaps *p_ht_cap;
4261 int i;
4262
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004263 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004264 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4265 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004266 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004267 return;
4268 }
4269 ie_params->nss = i;
4270 ie_params->pdev_id = pdev_id;
4271 ie_params->ie_type = DOT11_HT_IE;
4272 /* 2 for IE len and EID */
4273 ie_params->ie_len = 2 + sizeof(tHtCaps);
4274 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4275 if (NULL == ie_params->ie_ptr) {
4276 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004277 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004278 return;
4279 }
4280 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4281 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4282 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4283 ie_params->ie_len);
4284
4285 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004286 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4287 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004288 if (NULL == p_ie) {
4289 qdf_mem_free(ie_params->ie_ptr);
4290 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004291 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004292 return;
4293 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004294 p_ht_cap = (tHtCaps *)&p_ie[2];
4295 p_ht_cap->supportedMCSSet[1] = 0;
4296 p_ht_cap->txSTBC = 0;
4297 }
4298
4299 msg.type = WMA_SET_PDEV_IE_REQ;
4300 msg.bodyptr = ie_params;
4301 msg.bodyval = 0;
4302
4303 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4304 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004305 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004306 qdf_mem_free(ie_params->ie_ptr);
4307 qdf_mem_free(ie_params);
4308 return;
4309 }
4310 }
4311}
4312
4313/**
4314 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4315 * @mac_ctx: Pointer to Global MAC structure
4316 * @pdev_id: pdev id to set the IE.
4317 * @nss: Nss values to prepare the VHT IE.
4318 *
4319 * Prepares the VHT IE with self capabilities for different
4320 * Nss values and sends the set VHT IE req to FW.
4321 *
4322 * Return: None
4323 */
4324static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4325 uint8_t nss)
4326{
4327 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004328 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004329 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004330 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004331 tSirMacVHTCapabilityInfo *vht_cap;
4332 int i;
4333 tSirVhtMcsInfo *vht_mcs;
4334
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004335 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004336 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4337 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004338 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004339 return;
4340 }
4341 ie_params->nss = i;
4342 ie_params->pdev_id = pdev_id;
4343 ie_params->ie_type = DOT11_VHT_IE;
4344 /* 2 for IE len and EID */
4345 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4346 sizeof(tSirVhtMcsInfo);
4347 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4348 if (NULL == ie_params->ie_ptr) {
4349 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004350 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004351 return;
4352 }
4353 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4354 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4355 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4356 ie_params->ie_len);
4357
4358 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004359 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4360 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004361 if (NULL == p_ie) {
4362 qdf_mem_free(ie_params->ie_ptr);
4363 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004364 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004365 return;
4366 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004367 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4368 vht_cap->txSTBC = 0;
4369 vht_mcs =
4370 (tSirVhtMcsInfo *)&p_ie[2 +
4371 sizeof(tSirMacVHTCapabilityInfo)];
4372 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4373 vht_mcs->rxHighest =
4374 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4375 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4376 vht_mcs->txHighest =
4377 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4378 }
4379 msg.type = WMA_SET_PDEV_IE_REQ;
4380 msg.bodyptr = ie_params;
4381 msg.bodyval = 0;
4382
4383 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4384 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004385 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004386 qdf_mem_free(ie_params->ie_ptr);
4387 qdf_mem_free(ie_params);
4388 return;
4389 }
4390 }
4391}
4392
4393/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004394 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4395 * @mac_ctx: Pointer to Global MAC structure
4396 * @msg_buf: Pointer to the SME message buffer
4397 *
4398 * This function is called by limProcessMessageQueue(). This function sets the
4399 * VDEV IEs to the FW.
4400 *
4401 * Return: None
4402 */
4403static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4404 uint32_t *msg_buf)
4405{
4406 struct sir_set_vdev_ies_per_band *p_msg =
4407 (struct sir_set_vdev_ies_per_band *)msg_buf;
4408
4409 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004410 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004411 return;
4412 }
4413
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004414 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004415 p_msg->vdev_id);
4416 /* intentionally using NULL here so that self capabilty are sent */
4417 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4418 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004419 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004420}
4421
4422/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004423 * lim_process_set_pdev_IEs() - process the set pdev IE req
4424 * @mac_ctx: Pointer to Global MAC structure
4425 * @msg_buf: Pointer to the SME message buffer
4426 *
4427 * This function is called by limProcessMessageQueue(). This
4428 * function sets the PDEV IEs to the FW.
4429 *
4430 * Return: None
4431 */
4432static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4433{
4434 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4435
4436 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4437
4438 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004439 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004440 return;
4441 }
4442
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004443 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004444 ht_vht_cfg->nss);
4445 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4446
4447 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4448 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4449 ht_vht_cfg->nss);
4450}
4451
4452/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304453 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4454 *
4455 * access policy
4456 * @mac_ctx: pointer to mac context
4457 * @msg: message buffer
4458 *
4459 * function processes vendor IE and access policy from SME and updates PE
4460 *
4461 * session entry
4462 *
4463 * return: none
4464*/
4465static void lim_process_sme_update_access_policy_vendor_ie(
4466 tpAniSirGlobal mac_ctx,
4467 uint32_t *msg)
4468{
4469 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4470 struct sPESession *pe_session_entry;
4471 uint8_t num_bytes;
4472
4473 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004474 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304475 return;
4476 }
4477 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4478 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4479 update_vendor_ie->sme_session_id);
4480
4481 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004482 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304483 update_vendor_ie->sme_session_id);
4484 return;
4485 }
4486 if (pe_session_entry->access_policy_vendor_ie)
4487 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4488
4489 num_bytes = update_vendor_ie->ie[1] + 2;
4490 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4491
4492 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004493 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304494 return;
4495 }
4496 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4497 &update_vendor_ie->ie[0], num_bytes);
4498
4499 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4500}
4501
4502/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004503 * lim_process_sme_req_messages()
4504 *
4505 ***FUNCTION:
4506 * This function is called by limProcessMessageQueue(). This
4507 * function processes SME request messages from HDD or upper layer
4508 * application.
4509 *
4510 ***LOGIC:
4511 *
4512 ***ASSUMPTIONS:
4513 *
4514 ***NOTE:
4515 *
4516 * @param pMac Pointer to Global MAC structure
4517 * @param msgType Indicates the SME message type
4518 * @param *pMsgBuf A pointer to the SME message buffer
4519 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4520 * false - if pMsgBuf is not to be freed.
4521 */
4522
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004523bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4524 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004525{
4526 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
4527 uint32_t *pMsgBuf = pMsg->bodyptr;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004528
4529 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004530 lim_msg_str(pMsg->type), pMsg->type,
4531 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4532 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004533
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004534 /* If no insert NOA required then execute the code below */
4535
4536 switch (pMsg->type) {
4537 case eWNI_SME_SYS_READY_IND:
4538 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4539 break;
4540
4541 case eWNI_SME_START_BSS_REQ:
4542 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4543 break;
4544
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004545 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4546 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4547 break;
4548 case eWNI_SME_JOIN_REQ:
4549 __lim_process_sme_join_req(pMac, pMsgBuf);
4550 break;
4551
4552 case eWNI_SME_REASSOC_REQ:
4553 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4554 break;
4555
4556 case eWNI_SME_DISASSOC_REQ:
4557 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4558 break;
4559
4560 case eWNI_SME_DISASSOC_CNF:
4561 case eWNI_SME_DEAUTH_CNF:
4562 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4563 break;
4564
4565 case eWNI_SME_DEAUTH_REQ:
4566 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4567 break;
4568
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304569 case eWNI_SME_SEND_DISASSOC_FRAME:
4570 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4571 break;
4572
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004573 case eWNI_SME_SETCONTEXT_REQ:
4574 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4575 break;
4576
4577 case eWNI_SME_STOP_BSS_REQ:
4578 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4579 break;
4580
4581 case eWNI_SME_ASSOC_CNF:
4582 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004583 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004584 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4585 pMsgBuf);
4586 break;
4587
4588 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004589 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004590 __lim_process_sme_addts_req(pMac, pMsgBuf);
4591 break;
4592
4593 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004594 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004595 __lim_process_sme_delts_req(pMac, pMsgBuf);
4596 break;
4597
4598 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004599 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004600 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4601 break;
4602
4603 case eWNI_SME_GET_STATISTICS_REQ:
4604 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4605 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4606 bufConsumed = false;
4607 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004608#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004609 case eWNI_SME_GET_TSM_STATS_REQ:
4610 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4611 bufConsumed = false;
4612 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004613#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004614 case eWNI_SME_GET_ASSOC_STAS_REQ:
4615 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4616 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304617 case eWNI_SME_SESSION_UPDATE_PARAM:
4618 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004619 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304620 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4621 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4622 bufConsumed = false;
4623 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004624 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4625 /* Update the beaconInterval */
4626 __lim_process_sme_change_bi(pMac, pMsgBuf);
4627 break;
4628
4629#ifdef QCA_HT_2040_COEX
4630 case eWNI_SME_SET_HT_2040_MODE:
4631 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4632 break;
4633#endif
4634
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004635 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4636 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4637 __lim_process_report_message(pMac, pMsg);
4638 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004639
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004640 case eWNI_SME_FT_PRE_AUTH_REQ:
4641 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4642 break;
4643 case eWNI_SME_FT_UPDATE_KEY:
4644 lim_process_ft_update_key(pMac, pMsgBuf);
4645 break;
4646
4647 case eWNI_SME_FT_AGGR_QOS_REQ:
4648 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4649 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004650
4651 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4652 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4653 break;
4654#ifdef FEATURE_WLAN_TDLS
4655 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4656 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4657 break;
4658 case eWNI_SME_TDLS_ADD_STA_REQ:
4659 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4660 break;
4661 case eWNI_SME_TDLS_DEL_STA_REQ:
4662 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4663 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004664#endif
4665 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4666 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4667 break;
4668
4669 case eWNI_SME_CHANNEL_CHANGE_REQ:
4670 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4671 break;
4672
4673 case eWNI_SME_START_BEACON_REQ:
4674 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4675 break;
4676
4677 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4678 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4679 break;
4680
4681 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4682 lim_process_update_add_ies(pMac, pMsgBuf);
4683 break;
4684
4685 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4686 lim_process_modify_add_ies(pMac, pMsgBuf);
4687 break;
4688 case eWNI_SME_SET_HW_MODE_REQ:
4689 lim_process_set_hw_mode(pMac, pMsgBuf);
4690 break;
4691 case eWNI_SME_NSS_UPDATE_REQ:
4692 lim_process_nss_update_request(pMac, pMsgBuf);
4693 break;
4694 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4695 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4696 break;
4697 case eWNI_SME_SET_IE_REQ:
4698 lim_process_set_ie_req(pMac, pMsgBuf);
4699 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304700 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4701 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
4702 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304703 case eWNI_SME_EXT_CHANGE_CHANNEL:
4704 lim_process_ext_change_channel(pMac, pMsgBuf);
4705 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08004706 case eWNI_SME_SET_ANTENNA_MODE_REQ:
4707 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
4708 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004709 case eWNI_SME_PDEV_SET_HT_VHT_IE:
4710 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07004711 break;
4712 case eWNI_SME_SET_VDEV_IES_PER_BAND:
4713 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
4714 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304715 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
4716 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
4717 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07004718 case eWNI_SME_UPDATE_CONFIG:
4719 lim_process_sme_update_config(pMac,
4720 (struct update_config *)pMsgBuf);
4721 break;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004722 case eWNI_SME_SET_ADDBA_ACCEPT:
4723 lim_process_sme_set_addba_accept(pMac,
4724 (struct sme_addba_accept *)pMsgBuf);
4725 break;
Arif Hussaineb8ba362018-03-07 19:15:13 -08004726 case eWNI_SME_UPDATE_EDCA_PROFILE:
4727 lim_process_sme_update_edca_params(pMac, pMsg->bodyval);
4728 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004729 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304730 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004731 pMsg->bodyptr = NULL;
4732 break;
4733 } /* switch (msgType) */
4734
4735 return bufConsumed;
4736} /*** end lim_process_sme_req_messages() ***/
4737
4738/**
4739 * lim_process_sme_start_beacon_req()
4740 *
4741 ***FUNCTION:
4742 * This function is called by limProcessMessageQueue(). This
4743 * function processes SME request messages from HDD or upper layer
4744 * application.
4745 *
4746 ***LOGIC:
4747 *
4748 ***ASSUMPTIONS:
4749 *
4750 ***NOTE:
4751 *
4752 * @param pMac Pointer to Global MAC structure
4753 * @param msgType Indicates the SME message type
4754 * @param *pMsgBuf A pointer to the SME message buffer
4755 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4756 * false - if pMsgBuf is not to be freed.
4757 */
4758static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
4759{
4760 tpSirStartBeaconIndication pBeaconStartInd;
4761 tpPESession psessionEntry;
4762 uint8_t sessionId; /* PE sessionID */
4763
4764 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004765 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004766 return;
4767 }
4768
4769 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
4770 psessionEntry = pe_find_session_by_bssid(pMac,
4771 pBeaconStartInd->bssid,
4772 &sessionId);
4773 if (psessionEntry == NULL) {
4774 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004775 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004776 return;
4777 }
4778
4779 if (pBeaconStartInd->beaconStartStatus == true) {
4780 /*
4781 * Currently this Indication comes from SAP
4782 * to start Beacon Tx on a DFS channel
4783 * since beaconing has to be done on DFS
4784 * channel only after CAC WAIT is completed.
4785 * On a DFS Channel LIM does not start beacon
4786 * Tx right after the WMA_ADD_BSS_RSP.
4787 */
4788 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05304789 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004790 FL("Start Beacon with ssid %s Ch %d"),
4791 psessionEntry->ssId.ssId,
4792 psessionEntry->currentOperChannel);
4793 lim_send_beacon_ind(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08004794 lim_enable_obss_detection_config(pMac, psessionEntry);
Arif Hussain05fb4872018-01-03 16:02:55 -08004795 lim_send_obss_color_collision_cfg(pMac, psessionEntry,
4796 OBSS_COLOR_COLLISION_DETECTION);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004797 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004798 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004799 return;
4800 }
4801}
4802
4803/**
4804 * lim_process_sme_channel_change_request() - process sme ch change req
4805 *
4806 * @mac_ctx: Pointer to Global MAC structure
4807 * @msg_buf: pointer to the SME message buffer
4808 *
4809 * This function is called to process SME_CHANNEL_CHANGE_REQ message
4810 *
4811 * Return: None
4812 */
4813static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
4814 uint32_t *msg_buf)
4815{
4816 tpSirChanChangeRequest ch_change_req;
4817 tpPESession session_entry;
4818 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07004819 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004820 uint32_t val = 0;
4821
4822 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004823 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004824 return;
4825 }
4826 ch_change_req = (tpSirChanChangeRequest)msg_buf;
4827
4828 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
4829 ch_change_req->targetChannel);
4830
4831 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
4832 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004833 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004834 return;
4835 }
4836
4837 session_entry = pe_find_session_by_bssid(mac_ctx,
4838 ch_change_req->bssid, &session_id);
4839 if (session_entry == NULL) {
4840 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004841 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004842 return;
4843 }
4844
Manjunathappa Prakash34fda792018-02-07 18:23:42 -08004845 if ((session_entry->currentOperChannel ==
4846 ch_change_req->targetChannel) &&
4847 (session_entry->ch_width == ch_change_req->ch_width)) {
4848 pe_err("Target channel and mode is same as current channel and mode channel %d and mode %d",
4849 session_entry->currentOperChannel, session_entry->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004850 return;
4851 }
4852
4853 if (LIM_IS_AP_ROLE(session_entry))
4854 session_entry->channelChangeReasonCode =
4855 LIM_SWITCH_CHANNEL_SAP_DFS;
4856 else
4857 session_entry->channelChangeReasonCode =
4858 LIM_SWITCH_CHANNEL_OPERATION;
4859
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004860 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004861 session_entry->currentOperChannel,
4862 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004863 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004864
4865 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004866 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004867 session_entry->ch_center_freq_seg0 =
4868 ch_change_req->center_freq_seg_0;
4869 session_entry->ch_center_freq_seg1 =
4870 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004871 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004872 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004873 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004874 session_entry->htRecommendedTxWidthSet =
4875 session_entry->htSupportedChannelWidthSet;
4876 session_entry->currentOperChannel =
4877 ch_change_req->targetChannel;
4878 session_entry->limRFBand =
4879 lim_get_rf_band(session_entry->currentOperChannel);
4880 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08004881 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004882 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004883 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
4884 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004885 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004886 }
4887
4888 session_entry->lim11hEnable = val;
4889 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304890 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004891 &ch_change_req->operational_rateset,
4892 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304893 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004894 &ch_change_req->extended_rateset,
4895 sizeof(session_entry->extRateSet));
4896 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
4897 session_entry->ch_center_freq_seg0,
4898 session_entry->ch_center_freq_seg1,
4899 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07004900 max_tx_pwr, session_entry->peSessionId,
4901 ch_change_req->cac_duration_ms,
4902 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004903}
4904
4905/******************************************************************************
4906* lim_start_bss_update_add_ie_buffer()
4907*
4908***FUNCTION:
4909* This function checks the src buffer and its length and then malloc for
4910* dst buffer update the same
4911*
4912***LOGIC:
4913*
4914***ASSUMPTIONS:
4915*
4916***NOTE:
4917*
4918* @param pMac Pointer to Global MAC structure
4919* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
4920* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
4921* @param *pSrcData_buff A pointer of uint8_t src buffer
4922* @param srcDataLen src buffer length
4923******************************************************************************/
4924
4925static void
4926lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
4927 uint8_t **pDstData_buff,
4928 uint16_t *pDstDataLen,
4929 uint8_t *pSrcData_buff, uint16_t srcDataLen)
4930{
4931
4932 if (srcDataLen > 0 && pSrcData_buff != NULL) {
4933 *pDstDataLen = srcDataLen;
4934
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304935 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004936
4937 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004938 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004939 return;
4940 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304941 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004942 } else {
4943 *pDstData_buff = NULL;
4944 *pDstDataLen = 0;
4945 }
4946}
4947
4948/******************************************************************************
4949* lim_update_add_ie_buffer()
4950*
4951***FUNCTION:
4952* This function checks the src buffer and length if src buffer length more
4953* than dst buffer length then free the dst buffer and malloc for the new src
4954* length, and update the dst buffer and length. But if dst buffer is bigger
4955* than src buffer length then it just update the dst buffer and length
4956*
4957***LOGIC:
4958*
4959***ASSUMPTIONS:
4960*
4961***NOTE:
4962*
4963* @param pMac Pointer to Global MAC structure
4964* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
4965* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
4966* @param *pSrcData_buff A pointer of uint8_t src buffer
4967* @param srcDataLen src buffer length
4968******************************************************************************/
4969
4970static void
4971lim_update_add_ie_buffer(tpAniSirGlobal pMac,
4972 uint8_t **pDstData_buff,
4973 uint16_t *pDstDataLen,
4974 uint8_t *pSrcData_buff, uint16_t srcDataLen)
4975{
4976
4977 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004978 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004979 return;
4980 }
4981
4982 if (srcDataLen > *pDstDataLen) {
4983 *pDstDataLen = srcDataLen;
4984 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304985 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004986 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304987 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004988
4989 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004990 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004991 *pDstDataLen = 0;
4992 return;
4993 }
4994 }
4995
4996 /* copy the content of buffer into dst buffer
4997 */
4998 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304999 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005000
5001}
5002
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005003/**
5004 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5005 * @pMac : Pointer to Global MAC structure
5006 * @pDstData_buff : A pointer to pointer of dst buffer
5007 * @pDstDataLen : A pointer to pointer of dst buffer length
5008 * @pModifyIE : A pointer to tSirModifyIE
5009 *
5010 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5011 *
5012 * Return:
5013 * True or false depending upon whether IE is updated or not
5014 */
5015static bool
5016lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5017 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5018{
Hong Shi1553d692016-09-28 12:16:19 +08005019 int32_t oui_length;
5020 uint8_t *ibss_ie = NULL;
5021 uint8_t *vendor_ie;
5022#define MAC_VENDOR_OUI "\x00\x16\x32"
5023#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005024
5025 ibss_ie = pModifyIE->pIEBuffer;
5026 oui_length = pModifyIE->oui_length;
5027
5028 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005029 pe_err("Invalid set IBSS vendor IE command length %d",
5030 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005031 return false;
5032 }
5033
Hong Shi1553d692016-09-28 12:16:19 +08005034 /*
5035 * Why replace only beacon OUI data here:
5036 * 1. other ie (such as wpa) shall not be overwritten here.
5037 * 2. per spec, beacon oui ie might be set twice and original one
5038 * shall be updated.
5039 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005040 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005041 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5042 if (vendor_ie) {
5043 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5044 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5045 pModifyIE->ieBufferlength);
5046 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005047 uint16_t new_length;
5048 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005049
Naveen Rawat668dee32017-09-29 14:39:40 -07005050 /*
5051 * check for uint16 overflow before using sum of two numbers as
5052 * length of size to malloc
5053 */
5054 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5055 pe_err("U16 overflow due to %d + %d",
5056 pModifyIE->ieBufferlength, *pDstDataLen);
5057 return false;
5058 }
5059
5060 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5061 new_ptr = qdf_mem_malloc(new_length);
Hong Shi1553d692016-09-28 12:16:19 +08005062 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005063 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005064 return false;
5065 }
5066 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5067 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5068 pModifyIE->ieBufferlength);
5069 qdf_mem_free(*pDstData_buff);
5070 *pDstDataLen = new_length;
5071 *pDstData_buff = new_ptr;
5072 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005073 return true;
5074}
5075
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005076/*
5077* lim_process_modify_add_ies() - process modify additional IE req.
5078*
5079* @mac_ctx: Pointer to Global MAC structure
5080* @msg_buf: pointer to the SME message buffer
5081*
5082* This function update the PE buffers for additional IEs.
5083*
5084* Return: None
5085*/
5086static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5087 uint32_t *msg_buf)
5088{
5089 tpSirModifyIEsInd modify_add_ies;
5090 tpPESession session_entry;
5091 uint8_t session_id;
5092 bool ret = false;
5093 tSirAddIeParams *add_ie_params;
5094
5095 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005096 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005097 return;
5098 }
5099
5100 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5101 /* Incoming message has smeSession, use BSSID to find PE session */
5102 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005103 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005104
5105 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005106 pe_err("Session not found for given bssid"
5107 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005108 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005109 goto end;
5110 }
5111 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5112 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5113 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005114 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005115 modify_add_ies->modifyIE.pIEBuffer,
5116 modify_add_ies->modifyIE.ieBufferlength,
5117 modify_add_ies->modifyIE.ieID,
5118 modify_add_ies->modifyIE.ieIDLen,
5119 modify_add_ies->updateType);
5120 goto end;
5121 }
5122 add_ie_params = &session_entry->addIeParams;
5123 switch (modify_add_ies->updateType) {
5124 case eUPDATE_IE_PROBE_RESP:
5125 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005126 if (LIM_IS_IBSS_ROLE(session_entry)) {
5127 lim_update_ibss_prop_add_ies(mac_ctx,
5128 &add_ie_params->probeRespData_buff,
5129 &add_ie_params->probeRespDataLen,
5130 &modify_add_ies->modifyIE);
5131 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005132 break;
5133 case eUPDATE_IE_ASSOC_RESP:
5134 /* assoc resp IE */
5135 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305136 QDF_TRACE(QDF_MODULE_ID_PE,
5137 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005138 "assoc resp add ie not present %d"),
5139 add_ie_params->assocRespDataLen);
5140 }
5141 /* search through the buffer and modify the IE */
5142 break;
5143 case eUPDATE_IE_PROBE_BCN:
5144 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005145 if (LIM_IS_IBSS_ROLE(session_entry)) {
5146 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5147 &add_ie_params->probeRespBCNData_buff,
5148 &add_ie_params->probeRespBCNDataLen,
5149 &modify_add_ies->modifyIE);
5150 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005151 if (ret == true && modify_add_ies->modifyIE.notify) {
5152 lim_handle_param_update(mac_ctx,
5153 modify_add_ies->updateType);
5154 }
5155 break;
5156 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005157 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005158 modify_add_ies->updateType);
5159 break;
5160 }
5161end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305162 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005163 modify_add_ies->modifyIE.pIEBuffer = NULL;
5164}
5165
5166/*
5167* lim_process_update_add_ies() - process additional IE update req
5168*
5169* @mac_ctx: Pointer to Global MAC structure
5170* @msg_buf: pointer to the SME message buffer
5171*
5172* This function update the PE buffers for additional IEs.
5173*
5174* Return: None
5175*/
5176static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5177 uint32_t *msg_buf)
5178{
5179 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5180 uint8_t session_id;
5181 tpPESession session_entry;
5182 tSirAddIeParams *addn_ie;
5183 uint16_t new_length = 0;
5184 uint8_t *new_ptr = NULL;
5185 tSirUpdateIE *update_ie;
5186
5187 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005188 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005189 return;
5190 }
5191 update_ie = &update_add_ies->updateIE;
5192 /* incoming message has smeSession, use BSSID to find PE session */
5193 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005194 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005195
5196 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005197 pe_err("Session not found for given bssid"
5198 MAC_ADDRESS_STR,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005199 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005200 goto end;
5201 }
5202 addn_ie = &session_entry->addIeParams;
5203 /* if len is 0, upper layer requested freeing of buffer */
5204 if (0 == update_ie->ieBufferlength) {
5205 switch (update_add_ies->updateType) {
5206 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305207 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005208 addn_ie->probeRespData_buff = NULL;
5209 addn_ie->probeRespDataLen = 0;
5210 break;
5211 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305212 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005213 addn_ie->assocRespData_buff = NULL;
5214 addn_ie->assocRespDataLen = 0;
5215 break;
5216 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305217 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005218 addn_ie->probeRespBCNData_buff = NULL;
5219 addn_ie->probeRespBCNDataLen = 0;
5220
5221 if (update_ie->notify)
5222 lim_handle_param_update(mac_ctx,
5223 update_add_ies->updateType);
5224 break;
5225 default:
5226 break;
5227 }
5228 return;
5229 }
5230 switch (update_add_ies->updateType) {
5231 case eUPDATE_IE_PROBE_RESP:
5232 if (update_ie->append) {
5233 /*
5234 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005235 * with combined length.
5236 * Multiple back to back append commands
5237 * can lead to a huge length.So, check
5238 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005239 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005240 if (addn_ie->probeRespDataLen >
5241 (USHRT_MAX - update_ie->ieBufferlength)) {
5242 pe_err("IE Length overflow, curr:%d, new:%d",
5243 addn_ie->probeRespDataLen,
5244 update_ie->ieBufferlength);
5245 goto end;
5246 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005247 new_length = update_ie->ieBufferlength +
5248 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305249 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005250 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005251 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005252 goto end;
5253 }
5254 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305255 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005256 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305257 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005258 update_ie->pAdditionIEBuffer,
5259 update_ie->ieBufferlength);
5260 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305261 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005262 /* adjust length accordingly */
5263 addn_ie->probeRespDataLen = new_length;
5264 /* save refernece of local buffer in PE session */
5265 addn_ie->probeRespData_buff = new_ptr;
5266 goto end;
5267 }
5268 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5269 &addn_ie->probeRespDataLen,
5270 update_ie->pAdditionIEBuffer,
5271 update_ie->ieBufferlength);
5272 break;
5273 case eUPDATE_IE_ASSOC_RESP:
5274 /* assoc resp IE */
5275 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5276 &addn_ie->assocRespDataLen,
5277 update_ie->pAdditionIEBuffer,
5278 update_ie->ieBufferlength);
5279 break;
5280 case eUPDATE_IE_PROBE_BCN:
5281 /* probe resp Bcn IE */
5282 lim_update_add_ie_buffer(mac_ctx,
5283 &addn_ie->probeRespBCNData_buff,
5284 &addn_ie->probeRespBCNDataLen,
5285 update_ie->pAdditionIEBuffer,
5286 update_ie->ieBufferlength);
5287 if (update_ie->notify)
5288 lim_handle_param_update(mac_ctx,
5289 update_add_ies->updateType);
5290 break;
5291 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005292 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005293 break;
5294 }
5295end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305296 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005297 update_ie->pAdditionIEBuffer = NULL;
5298}
5299
5300/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305301 * send_extended_chan_switch_action_frame()- function to send ECSA
5302 * action frame for each sta connected to SAP/GO and AP in case of
5303 * STA .
5304 * @mac_ctx: pointer to global mac structure
5305 * @new_channel: new channel to switch to.
5306 * @ch_bandwidth: BW of channel to calculate op_class
5307 * @session_entry: pe session
5308 *
5309 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5310 *
5311 * Return: void
5312 */
5313
5314static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5315 uint16_t new_channel, uint8_t ch_bandwidth,
5316 tpPESession session_entry)
5317{
5318 uint16_t op_class;
5319 uint8_t switch_mode = 0, i;
5320 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005321 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305322
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005323 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305324 mac_ctx->scan.countryCodeCurrent,
5325 new_channel,
5326 ch_bandwidth);
5327
5328 if (LIM_IS_AP_ROLE(session_entry) &&
5329 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005330 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305331
gaoleze2920bd2017-03-21 17:38:42 +08005332 switch_count = session_entry->gLimChannelSwitch.switchCount;
5333
Abhishek Singh518323d2015-10-19 17:42:01 +05305334 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005335 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305336 psta =
5337 session_entry->dph.dphHashTable.pDphNodeArray + i;
5338 if (psta && psta->added)
5339 lim_send_extended_chan_switch_action_frame(
5340 mac_ctx,
5341 psta->staAddr,
5342 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005343 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305344 }
5345 } else if (LIM_IS_STA_ROLE(session_entry)) {
5346 lim_send_extended_chan_switch_action_frame(mac_ctx,
5347 session_entry->bssId,
5348 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005349 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305350 }
5351
5352}
5353
gaolez76d2a162017-03-21 19:23:58 +08005354void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5355 uint16_t new_channel,
5356 uint8_t ch_bandwidth,
5357 tpPESession session_entry)
5358{
5359 uint16_t op_class;
5360 uint8_t switch_mode = 0, i;
5361 uint8_t switch_count;
5362 tpDphHashNode psta;
5363 tpDphHashNode dph_node_array_ptr;
5364
5365 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5366
5367 op_class = wlan_reg_dmn_get_opclass_from_channel(
5368 mac_ctx->scan.countryCodeCurrent,
5369 new_channel, ch_bandwidth);
5370
5371 if (LIM_IS_AP_ROLE(session_entry) &&
5372 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5373 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5374
5375 switch_count = session_entry->gLimChannelSwitch.switchCount;
5376
5377 if (LIM_IS_AP_ROLE(session_entry)) {
5378 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5379 psta = dph_node_array_ptr + i;
5380 if (!(psta && psta->added))
5381 continue;
5382 if (session_entry->lim_non_ecsa_cap_num == 0)
5383 lim_send_extended_chan_switch_action_frame
5384 (mac_ctx, psta->staAddr, switch_mode,
5385 op_class, new_channel, switch_count,
5386 session_entry);
5387 else
5388 lim_send_channel_switch_mgmt_frame
5389 (mac_ctx, psta->staAddr, switch_mode,
5390 new_channel, switch_count,
5391 session_entry);
5392 }
5393 } else if (LIM_IS_STA_ROLE(session_entry)) {
5394 lim_send_extended_chan_switch_action_frame
5395 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5396 new_channel, switch_count, session_entry);
5397 }
5398}
5399
5400/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005401 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5402 *
5403 * @mac_ctx: Pointer to Global MAC structure
5404 * @msg_buf: pointer to the SME message buffer
5405 *
5406 * This function processes SME request messages from HDD or upper layer
5407 * application.
5408 *
5409 * Return: None
5410 */
5411static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5412 uint32_t *msg_buf)
5413{
5414 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5415 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005416 uint8_t session_id;
5417 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005418 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005419
5420 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005421 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005422 return;
5423 }
5424
5425 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5426 session_entry = pe_find_session_by_bssid(mac_ctx,
5427 dfs_csa_ie_req->bssid, &session_id);
5428 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005429 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005430 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5431 return;
5432 }
5433
5434 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005435 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005436 GET_LIM_SYSTEM_ROLE(session_entry));
5437 return;
5438 }
5439
5440 /* target channel */
5441 session_entry->gLimChannelSwitch.primaryChannel =
5442 dfs_csa_ie_req->targetChannel;
5443
5444 /* Channel switch announcement needs to be included in beacon */
5445 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005446 session_entry->gLimChannelSwitch.switchCount =
5447 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005448 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005449 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305450 session_entry->gLimChannelSwitch.sec_ch_offset =
5451 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005452 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005453 session_entry->gLimChannelSwitch.switchMode =
5454 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005455
5456 /*
5457 * Validate if SAP is operating HT or VHT mode and set the Channel
5458 * Switch Wrapper element with the Wide Band Switch subelement.
5459 */
5460 if (true != session_entry->vhtCapability)
5461 goto skip_vht;
5462
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005463 /* Now encode the Wider Ch BW element depending on the ch width */
5464 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005465 switch (dfs_csa_ie_req->ch_params.ch_width) {
5466 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005467 /*
5468 * Wide channel BW sublement in channel wrapper element is not
5469 * required in case of 20 Mhz operation. Currently It is set
5470 * only set in case of 40/80 Mhz Operation.
5471 */
5472 session_entry->dfsIncludeChanWrapperIe = false;
5473 wider_bw_ch_switch->newChanWidth =
5474 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5475 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005476 case CH_WIDTH_40MHZ:
5477 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005478 wider_bw_ch_switch->newChanWidth =
5479 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5480 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005481 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005482 session_entry->dfsIncludeChanWrapperIe = true;
5483 wider_bw_ch_switch->newChanWidth =
5484 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5485 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005486 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005487 session_entry->dfsIncludeChanWrapperIe = true;
5488 wider_bw_ch_switch->newChanWidth =
5489 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5490 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005491 case CH_WIDTH_80P80MHZ:
5492 session_entry->dfsIncludeChanWrapperIe = true;
5493 wider_bw_ch_switch->newChanWidth =
5494 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005495 /*
5496 * This is not applicable for 20/40/80 Mhz.
5497 * Only used when we support 80+80 Mhz operation.
5498 * In case of 80+80 Mhz, this parameter indicates
5499 * center channel frequency index of 80 Mhz channel of
5500 * frequency segment 1.
5501 */
5502 wider_bw_ch_switch->newCenterChanFreq1 =
5503 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005504 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005505 default:
5506 session_entry->dfsIncludeChanWrapperIe = false;
5507 /*
5508 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5509 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5510 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005511 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005512 break;
5513 }
5514 /* Fetch the center channel based on the channel width */
5515 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005516 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005517skip_vht:
5518 /* Send CSA IE request from here */
5519 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5520 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005521 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005522 return;
5523 }
5524
5525 /*
5526 * First beacon update request is sent here, the remaining updates are
5527 * done when the FW responds back after sending the first beacon after
5528 * the template update
5529 */
5530 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305531
5532 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5533 ch_offset = BW80;
5534 else
5535 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5536
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005537 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305538 session_entry->gLimChannelSwitch.switchCount,
5539 session_entry->gLimChannelSwitch.primaryChannel,
5540 session_entry->gLimChannelSwitch.ch_width,
5541 session_entry->dfsIncludeChanWrapperIe,
5542 ch_offset);
5543
gaolez76d2a162017-03-21 19:23:58 +08005544 /* Send ECSA/CSA Action frame after updating the beacon */
5545 if (CHAN_HOP_ALL_BANDS_ENABLE)
5546 lim_send_chan_switch_action_frame(mac_ctx,
5547 session_entry->gLimChannelSwitch.primaryChannel,
5548 ch_offset, session_entry);
5549 else
5550 send_extended_chan_switch_action_frame(mac_ctx,
5551 session_entry->gLimChannelSwitch.primaryChannel,
5552 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005553}
5554
5555/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305556 * lim_process_ext_change_channel()- function to send ECSA
5557 * action frame for STA/CLI .
5558 * @mac_ctx: pointer to global mac structure
5559 * @msg: params from sme for new channel.
5560 *
5561 * This function is called to send ECSA frame for STA/CLI.
5562 *
5563 * Return: void
5564 */
5565
5566static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5567 uint32_t *msg)
5568{
5569 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5570 (struct sir_sme_ext_cng_chan_req *) msg;
5571 tpPESession session_entry = NULL;
5572
5573 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005574 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305575 return;
5576 }
5577 session_entry =
5578 pe_find_session_by_sme_session_id(mac_ctx,
5579 ext_chng_channel->session_id);
5580 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005581 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305582 ext_chng_channel->session_id);
5583 return;
5584 }
5585 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005586 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305587 return;
5588 }
5589 send_extended_chan_switch_action_frame(mac_ctx,
5590 ext_chng_channel->new_channel,
5591 0, session_entry);
5592}
5593
5594/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005595 * lim_process_nss_update_request() - process sme nss update req
5596 *
5597 * @mac_ctx: Pointer to Global MAC structure
5598 * @msg_buf: pointer to the SME message buffer
5599 *
5600 * This function processes SME request messages from HDD or upper layer
5601 * application.
5602 *
5603 * Return: None
5604 */
5605static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5606 uint32_t *msg_buf)
5607{
5608 struct sir_nss_update_request *nss_update_req_ptr;
5609 tpPESession session_entry = NULL;
5610
5611 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005612 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005613 return;
5614 }
5615
5616 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305617 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005618 nss_update_req_ptr->vdev_id);
5619 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005620 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005621 nss_update_req_ptr->vdev_id);
5622 return;
5623 }
5624
5625 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005626 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005627 GET_LIM_SYSTEM_ROLE(session_entry));
5628 return;
5629 }
5630
5631 /* populate nss field in the beacon */
5632 session_entry->gLimOperatingMode.present = 1;
5633 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05305634 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
5635
5636 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
5637 (session_entry->ch_width > CH_WIDTH_80MHZ))
5638 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
5639
5640 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
5641
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005642 /* Send nss update request from here */
5643 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5644 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005645 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005646 return;
5647 }
5648
5649 lim_send_beacon_ind(mac_ctx, session_entry);
5650}
5651
5652/**
5653 * lim_process_set_ie_req() - process sme set IE request
5654 *
5655 * @mac_ctx: Pointer to Global MAC structure
5656 * @msg_buf: pointer to the SME message buffer
5657 *
5658 * This function processes SME request messages from HDD or upper layer
5659 * application.
5660 *
5661 * Return: None
5662 */
5663static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5664{
5665 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305666 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005667
5668 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005669 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005670 return;
5671 }
5672
5673 msg = (struct send_extcap_ie *)msg_buf;
5674 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305675 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005676 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005677
5678}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005679
5680#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Arif Hussain05fb4872018-01-03 16:02:55 -08005681
5682/**
5683 * obss_color_collision_process_color_disable() - Disable bss color
5684 * @mac_ctx: Pointer to Global MAC structure
5685 * @session: pointer to session
5686 *
5687 * This function will disbale bss color.
5688 *
5689 * Return: None
5690 */
5691static void obss_color_collision_process_color_disable(tpAniSirGlobal mac_ctx,
5692 tpPESession session)
5693{
5694 tUpdateBeaconParams beacon_params;
5695
5696 if (!session) {
5697 pe_err("Invalid session");
5698 return;
5699 }
5700
5701 if (session->valid && !LIM_IS_AP_ROLE(session)) {
5702 pe_err("Invalid SystemRole %d",
5703 GET_LIM_SYSTEM_ROLE(session));
5704 return;
5705 }
5706
5707 if (session->bss_color_changing == 1) {
5708 pe_warn("%d: color change in progress", session->smeSessionId);
5709 /* Continue color collision detection */
5710 lim_send_obss_color_collision_cfg(mac_ctx, session,
5711 OBSS_COLOR_COLLISION_DETECTION);
5712 return;
5713 }
5714
5715 if (session->he_op.bss_col_disabled == 1) {
5716 pe_warn("%d: bss color already disabled",
5717 session->smeSessionId);
5718 /* Continue free color detection */
5719 lim_send_obss_color_collision_cfg(mac_ctx, session,
5720 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5721 return;
5722 }
5723
5724 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5725 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5726 session->he_op.bss_col_disabled = 1;
Arif Hussain05fb4872018-01-03 16:02:55 -08005727 beacon_params.bss_color_disabled = 1;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005728 beacon_params.bss_color = session->he_op.bss_color;
Arif Hussain05fb4872018-01-03 16:02:55 -08005729
5730 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
5731 eSIR_SUCCESS) {
5732 pe_err("Unable to set op mode IE in beacon");
5733 return;
5734 }
5735
5736 lim_send_beacon_params(mac_ctx, &beacon_params, session);
5737 lim_send_obss_color_collision_cfg(mac_ctx, session,
5738 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5739}
5740
5741/**
5742 * obss_color_collision_process_color_change() - Process bss color change
5743 * @mac_ctx: Pointer to Global MAC structure
5744 * @session: pointer to session
5745 * @obss_color_info: obss color collision/free slot indication info
5746 *
5747 * This function selects new color ib case of bss color collision.
5748 *
5749 * Return: None
5750 */
5751static void obss_color_collision_process_color_change(tpAniSirGlobal mac_ctx,
5752 tpPESession session,
5753 struct wmi_obss_color_collision_info *obss_color_info)
5754{
5755 int i, num_bss_color = 0;
5756 uint32_t bss_color_bitmap;
5757 uint8_t bss_color_index_array[MAX_BSS_COLOR_VALUE];
5758 uint32_t rand_byte = 0;
5759 struct sir_set_he_bss_color he_bss_color;
5760 bool is_color_collision = false;
5761
5762
5763 if (session->bss_color_changing == 1) {
5764 pe_err("%d: color change in progress", session->smeSessionId);
5765 return;
5766 }
5767
5768 if (!session->he_op.bss_col_disabled) {
5769 if (session->he_op.bss_color < 32)
5770 is_color_collision = (obss_color_info->
5771 obss_color_bitmap_bit0to31 >>
5772 session->he_op.bss_color) & 0x01;
5773 else
5774 is_color_collision = (obss_color_info->
5775 obss_color_bitmap_bit32to63 >>
5776 (session->he_op.bss_color -
Arif Hussain9e8c5612018-04-12 16:35:48 -07005777 32)) & 0x01;
Arif Hussain05fb4872018-01-03 16:02:55 -08005778 if (!is_color_collision) {
5779 pe_err("%d: color collision not found, curr_color: %d",
5780 session->smeSessionId,
5781 session->he_op.bss_color);
5782 return;
5783 }
5784 }
5785
5786 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit0to31;
5787
5788 /* Skip color zero */
5789 bss_color_bitmap = bss_color_bitmap >> 1;
5790 for (i = 0; (i < 31) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5791 if (!(bss_color_bitmap & 0x01)) {
5792 bss_color_index_array[num_bss_color] = i + 1;
5793 num_bss_color++;
5794 }
5795 bss_color_bitmap = bss_color_bitmap >> 1;
5796 }
5797
5798 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit32to63;
5799 for (i = 0; (i < 32) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5800 if (!(bss_color_bitmap & 0x01)) {
5801 bss_color_index_array[num_bss_color] = i + 32;
5802 num_bss_color++;
5803 }
5804 bss_color_bitmap = bss_color_bitmap >> 1;
5805 }
5806
5807 if (num_bss_color) {
5808 qdf_get_random_bytes((void *) &rand_byte, 1);
5809 i = (rand_byte + qdf_mc_timer_get_system_ticks()) %
5810 num_bss_color;
5811 pe_debug("New bss color = %d", bss_color_index_array[i]);
5812 he_bss_color.session_id = obss_color_info->vdev_id;
5813 he_bss_color.bss_color = bss_color_index_array[i];
5814 lim_process_set_he_bss_color(mac_ctx,
5815 (uint32_t *)&he_bss_color);
5816 } else {
5817 pe_err("Unable to find bss color from bitmasp");
5818 if (obss_color_info->evt_type ==
5819 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY &&
5820 session->obss_color_collision_dec_evt ==
5821 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
5822 /* In dot11BSSColorCollisionAPPeriod and
5823 * timer expired, time to disable bss color.
5824 */
5825 obss_color_collision_process_color_disable(mac_ctx,
5826 session);
5827 else
5828 /*
5829 * Enter dot11BSSColorCollisionAPPeriod period.
5830 */
5831 lim_send_obss_color_collision_cfg(mac_ctx, session,
5832 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY);
5833 }
5834}
5835
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005836void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5837{
5838 struct sir_set_he_bss_color *bss_color;
5839 tpPESession session_entry = NULL;
5840 tUpdateBeaconParams beacon_params;
5841
5842 if (!msg_buf) {
5843 pe_err("Buffer is Pointing to NULL");
5844 return;
5845 }
5846
5847 bss_color = (struct sir_set_he_bss_color *)msg_buf;
5848 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5849 bss_color->session_id);
5850 if (!session_entry) {
5851 pe_err("Session not found for given session_id %d",
5852 bss_color->session_id);
5853 return;
5854 }
5855
5856 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5857 pe_err("Invalid SystemRole %d",
5858 GET_LIM_SYSTEM_ROLE(session_entry));
5859 return;
5860 }
5861
5862 if (bss_color->bss_color == session_entry->he_op.bss_color) {
5863 pe_err("No change in BSS color, current BSS color %d",
5864 bss_color->bss_color);
5865 return;
5866 }
5867 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5868 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5869 session_entry->he_op.bss_col_disabled = 1;
5870 session_entry->he_bss_color_change.countdown =
5871 BSS_COLOR_SWITCH_COUNTDOWN;
5872 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005873 beacon_params.bss_color_disabled = 1;
5874 beacon_params.bss_color = session_entry->he_op.bss_color;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005875 session_entry->bss_color_changing = 1;
5876
5877 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5878 eSIR_SUCCESS) {
5879 pe_err("Unable to set op mode IE in beacon");
5880 return;
5881 }
5882
5883 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
Arif Hussain05fb4872018-01-03 16:02:55 -08005884 lim_send_obss_color_collision_cfg(mac_ctx, session_entry,
5885 OBSS_COLOR_COLLISION_DETECTION_DISABLE);
5886}
5887
5888void lim_send_obss_color_collision_cfg(tpAniSirGlobal mac_ctx,
5889 tpPESession session,
5890 enum wmi_obss_color_collision_evt_type
5891 event_type)
5892{
5893 struct wmi_obss_color_collision_cfg_param *cfg_param;
5894 struct scheduler_msg msg = {0};
5895
5896 if (!session) {
5897 pe_err("Invalid session");
5898 return;
5899 }
5900
5901 if (!session->he_capable ||
5902 !session->is_session_obss_color_collision_det_enabled) {
5903 pe_debug("%d: obss color det not enabled, he_cap:%d, sup:%d:%d",
5904 session->smeSessionId, session->he_capable,
5905 session->is_session_obss_color_collision_det_enabled,
5906 mac_ctx->lim.global_obss_color_collision_det_offload);
5907 return;
5908 }
5909
5910 cfg_param = qdf_mem_malloc(sizeof(*cfg_param));
5911 if (!cfg_param) {
5912 pe_err("Failed to allocate memory");
5913 return;
5914 }
5915
5916 pe_debug("%d: sending event:%d", session->smeSessionId, event_type);
5917 qdf_mem_zero(cfg_param, sizeof(*cfg_param));
5918 cfg_param->vdev_id = session->smeSessionId;
5919 cfg_param->evt_type = event_type;
5920 if (LIM_IS_AP_ROLE(session))
5921 cfg_param->detection_period_ms =
5922 OBSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS;
5923 else
5924 cfg_param->detection_period_ms =
5925 OBSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS;
5926
5927 cfg_param->scan_period_ms = OBSS_COLOR_COLLISION_SCAN_PERIOD_MS;
5928 if (event_type == OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
5929 cfg_param->free_slot_expiry_time_ms =
5930 OBSS_COLOR_COLLISION_FREE_SLOT_EXPIRY_MS;
5931
5932 msg.type = WMA_OBSS_COLOR_COLLISION_REQ;
5933 msg.bodyptr = cfg_param;
5934 msg.reserved = 0;
5935
5936 if (QDF_IS_STATUS_ERROR(scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
5937 pe_err("Failed to post WMA_OBSS_COLOR_COLLISION_REQ to WMA");
5938 qdf_mem_free(cfg_param);
5939 } else {
5940 session->obss_color_collision_dec_evt = event_type;
5941 }
5942}
5943
5944void lim_process_obss_color_collision_info(tpAniSirGlobal mac_ctx,
5945 uint32_t *msg_buf)
5946{
5947 struct wmi_obss_color_collision_info *obss_color_info;
5948 tpPESession session;
5949
5950 if (!msg_buf) {
5951 pe_err("Buffer is Pointing to NULL");
5952 return;
5953 }
5954
5955 obss_color_info = (struct wmi_obss_color_collision_info *)msg_buf;
5956 session = pe_find_session_by_sme_session_id(mac_ctx,
5957 obss_color_info->vdev_id);
5958 if (!session) {
5959 pe_err("Session not found for given session_id %d",
5960 obss_color_info->vdev_id);
5961 return;
5962 }
5963
5964 pe_debug("vdev_id:%d, evt:%d:%d, 0to31:0x%x, 32to63:0x%x, cap:%d:%d:%d",
5965 obss_color_info->vdev_id,
5966 obss_color_info->evt_type,
5967 session->obss_color_collision_dec_evt,
5968 obss_color_info->obss_color_bitmap_bit0to31,
5969 obss_color_info->obss_color_bitmap_bit32to63,
5970 session->he_capable,
5971 session->is_session_obss_color_collision_det_enabled,
5972 mac_ctx->lim.global_obss_color_collision_det_offload);
5973
5974 if (!session->he_capable ||
5975 !session->is_session_obss_color_collision_det_enabled) {
5976 return;
5977 }
5978
5979 switch (obss_color_info->evt_type) {
5980 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
5981 pe_err("%d: FW disabled obss color det. he_cap:%d, sup:%d:%d",
5982 session->smeSessionId, session->he_capable,
5983 session->is_session_obss_color_collision_det_enabled,
5984 mac_ctx->lim.global_obss_color_collision_det_offload);
5985 session->is_session_obss_color_collision_det_enabled = false;
5986 return;
5987 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
5988 case OBSS_COLOR_COLLISION_DETECTION:
5989 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
5990 if (session->valid && !LIM_IS_AP_ROLE(session)) {
5991 pe_debug("Invalid System Role %d",
5992 GET_LIM_SYSTEM_ROLE(session));
5993 return;
5994 }
5995
5996 if (session->obss_color_collision_dec_evt !=
5997 obss_color_info->evt_type) {
5998 pe_debug("%d: Wrong event: %d, skiping",
5999 obss_color_info->vdev_id,
6000 obss_color_info->evt_type);
6001 return;
6002 }
6003 obss_color_collision_process_color_change(mac_ctx, session,
6004 obss_color_info);
6005 break;
6006 default:
6007 pe_err("%d: Invalid event type %d",
6008 obss_color_info->vdev_id, obss_color_info->evt_type);
6009 return;
6010 }
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006011}
6012#endif