blob: c43ba842bf2d56ac00402aa367559ca930449918 [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/**
543 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
544 *@mac_ctx: Pointer to Global MAC structure
545 *@msg_buf: A pointer to the SME message buffer
546 *
547 * This function is called to process SME_START_BSS_REQ message
548 * from HDD or upper layer application.
549 *
550 * Return: None
551 */
552static void
553__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
554{
555 uint16_t size;
556 uint32_t val = 0;
557 tSirRetStatus ret_status;
558 tSirMacChanNum channel_number;
559 tLimMlmStartReq *mlm_start_req = NULL;
560 tpSirSmeStartBssReq sme_start_bss_req = NULL;
561 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
562 /* Flag Used in case of IBSS to Auto generate BSSID. */
563 uint32_t auto_gen_bssid = false;
564 uint8_t session_id;
565 tpPESession session = NULL;
Krunal Sonib37bb352016-12-20 14:12:21 -0800566 uint8_t sme_session_id = 0xFF;
567 uint16_t sme_transaction_id = 0xFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800568 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700569 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800570 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
571
572/* FEATURE_WLAN_DIAG_SUPPORT */
573#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
574 /*
575 * Since the session is not created yet, sending NULL.
576 * The response should have the correct state.
577 */
578 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
579 NULL, 0, 0);
580#endif /* FEATURE_WLAN_DIAG_SUPPORT */
581
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700582 pe_debug("Received START_BSS_REQ");
Krunal Sonib37bb352016-12-20 14:12:21 -0800583 size = sizeof(tSirSmeStartBssReq);
584 sme_start_bss_req = qdf_mem_malloc(size);
585 if (NULL == sme_start_bss_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700586 pe_err("Allocate Memory fail for LimStartBssReq");
Krunal Sonib37bb352016-12-20 14:12:21 -0800587 /* Send failure response to host */
588 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
589 goto free;
590 }
591 qdf_mem_copy(sme_start_bss_req, msg_buf, sizeof(tSirSmeStartBssReq));
592 sme_session_id = sme_start_bss_req->sessionId;
593 sme_transaction_id = sme_start_bss_req->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800594
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800595 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
596 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800597 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
598 sme_start_bss_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700599 pe_warn("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800600 ret_code = eSIR_SME_INVALID_PARAMETERS;
601 goto free;
602 }
603
604 /*
605 * This is the place where PE is going to create a session.
606 * If session is not existed, then create a new session
607 */
608 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800609 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800610 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700611 pe_warn("Session Already exists for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800612 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
613 session = NULL;
614 goto free;
615 } else {
616 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800617 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800618 &session_id, mac_ctx->lim.maxStation,
619 sme_start_bss_req->bssType);
620 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700621 pe_warn("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800622 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
623 goto free;
624 }
625 }
626
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700627 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
628 /* Probe resp add ie */
629 lim_start_bss_update_add_ie_buffer(mac_ctx,
630 &session->addIeParams.probeRespData_buff,
631 &session->addIeParams.probeRespDataLen,
632 sme_start_bss_req->addIeParams.
633 probeRespData_buff,
634 sme_start_bss_req->addIeParams.
635 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800636
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700637 /* Probe Beacon add ie */
638 lim_start_bss_update_add_ie_buffer(mac_ctx,
639 &session->addIeParams.probeRespBCNData_buff,
640 &session->addIeParams.probeRespBCNDataLen,
641 sme_start_bss_req->addIeParams.
642 probeRespBCNData_buff,
643 sme_start_bss_req->addIeParams.
644 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800645
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700646 /* Assoc resp IE */
647 lim_start_bss_update_add_ie_buffer(mac_ctx,
648 &session->addIeParams.assocRespData_buff,
649 &session->addIeParams.assocRespDataLen,
650 sme_start_bss_req->addIeParams.
651 assocRespData_buff,
652 sme_start_bss_req->addIeParams.
653 assocRespDataLen);
654 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800655 /* Store the session related params in newly created session */
656 session->pLimStartBssReq = sme_start_bss_req;
657
658 /* Store PE session_id in session Table */
659 session->peSessionId = session_id;
660
661 /* Store SME session Id in sessionTable */
662 session->smeSessionId = sme_start_bss_req->sessionId;
663
664 session->transactionId = sme_start_bss_req->transactionId;
665
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530666 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800667 &(sme_start_bss_req->htConfig),
668 sizeof(session->htConfig));
669
Sandeep Puligilla98917432016-06-10 13:50:28 -0700670 qdf_mem_copy(&(session->vht_config),
671 &(sme_start_bss_req->vht_config),
672 sizeof(session->vht_config));
673
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800674 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800675 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800676
677 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530678 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800679 (uint8_t *) &sme_start_bss_req->ssId,
680 (sme_start_bss_req->ssId.length + 1));
681
682 session->bssType = sme_start_bss_req->bssType;
683
684 session->nwType = sme_start_bss_req->nwType;
685
686 session->beaconParams.beaconInterval =
687 sme_start_bss_req->beaconInterval;
688
689 /* Store the channel number in session Table */
690 session->currentOperChannel =
691 sme_start_bss_req->channelId;
692
693 /* Store Persona */
694 session->pePersona = sme_start_bss_req->bssPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +0530695 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800696 FL("PE PERSONA=%d"), session->pePersona);
697
698 /* Update the phymode */
699 session->gLimPhyMode = sme_start_bss_req->nwType;
700
701 session->maxTxPower =
702 cfg_get_regulatory_max_transmit_power(mac_ctx,
703 session->currentOperChannel);
704 /* Store the dot 11 mode in to the session Table */
705 session->dot11mode = sme_start_bss_req->dot11mode;
706#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
707 session->cc_switch_mode =
708 sme_start_bss_req->cc_switch_mode;
709#endif
710 session->htCapability =
711 IS_DOT11_MODE_HT(session->dot11mode);
712 session->vhtCapability =
713 IS_DOT11_MODE_VHT(session->dot11mode);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800714
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700715 pe_debug("HT[%d], VHT[%d]",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800716 session->htCapability, session->vhtCapability);
717
718 if (IS_DOT11_MODE_HE(session->dot11mode)) {
719 lim_update_session_he_capable(mac_ctx, session);
720 lim_copy_bss_he_cap(session, sme_start_bss_req);
721 }
722
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800723 session->txLdpcIniFeatureEnabled =
724 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800725#ifdef WLAN_FEATURE_11W
726 session->limRmfEnabled =
727 sme_start_bss_req->pmfCapable ? 1 : 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700728 pe_debug("Session RMF enabled: %d", session->limRmfEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800729#endif
730
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530731 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800732 (void *)&sme_start_bss_req->operationalRateSet,
733 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530734 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800735 (void *)&sme_start_bss_req->extendedRateSet,
736 sizeof(tSirMacRateSet));
737
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700738 if (IS_5G_CH(session->currentOperChannel))
739 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
740 else
741 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
742
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743 switch (sme_start_bss_req->bssType) {
744 case eSIR_INFRA_AP_MODE:
745 lim_configure_ap_start_bss_session(mac_ctx, session,
746 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700747 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700748 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700749 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700750 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800751 break;
752 case eSIR_IBSS_MODE:
753 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
754 lim_get_short_slot_from_phy_mode(mac_ctx, session,
755 session->gLimPhyMode,
756 &session->shortSlotTimeSupported);
757
758 /*
759 * initialize to "OPEN".
760 * will be updated upon key installation
761 */
762 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700763 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800764
765 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700766 case eSIR_NDI_MODE:
767 session->limSystemRole = eLIM_NDI_ROLE;
768 break;
769
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800770
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800771 /*
772 * There is one more mode called auto mode.
773 * which is used no where
774 */
775
776 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
777
778 default:
779 /* not used anywhere...used in scan function */
780 break;
781 }
782
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700783 pe_debug("persona - %d, nss - %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700784 session->pePersona, session->vdev_nss);
785 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800786 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700787 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800788 * parsed (Re)Assoc request structure
789 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700790 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800791 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530792 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700793 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800794 if (NULL == session->parsedAssocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700795 pe_warn("AllocateMemory() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
797 goto free;
798 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800799 }
800
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700801 if (!sme_start_bss_req->channelId &&
802 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700803 pe_err("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800804 ret_code = eSIR_SME_INVALID_PARAMETERS;
805 goto free;
806 }
807 channel_number = sme_start_bss_req->channelId;
808#ifdef QCA_HT_2040_COEX
809 if (sme_start_bss_req->obssEnabled)
810 session->htSupportedChannelWidthSet =
811 session->htCapability;
812 else
813#endif
814 session->htSupportedChannelWidthSet =
815 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
816 session->htSecondaryChannelOffset =
817 sme_start_bss_req->sec_ch_offset;
818 session->htRecommendedTxWidthSet =
819 (session->htSecondaryChannelOffset) ? 1 : 0;
Abhishek Singh4294f802017-08-10 16:37:07 +0530820 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800821 FL("cbMode %u"), sme_start_bss_req->cbMode);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800822 if (lim_is_session_he_capable(session) ||
823 session->vhtCapability || session->htCapability) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800824 chanwidth = sme_start_bss_req->vht_channel_width;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700825 pe_debug("vht_channel_width %u htSupportedChannelWidthSet %d",
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800826 sme_start_bss_req->vht_channel_width,
827 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800828 session->ch_width = chanwidth;
829 if (session->htSupportedChannelWidthSet) {
830 session->ch_center_freq_seg0 =
831 sme_start_bss_req->center_freq_seg0;
832 session->ch_center_freq_seg1 =
833 sme_start_bss_req->center_freq_seg1;
834 } else {
835 session->ch_center_freq_seg0 = 0;
836 session->ch_center_freq_seg1 = 0;
837 }
838 }
839
840 if (session->vhtCapability &&
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800841 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800842 session->nss = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700843 pe_debug("nss set to [%d]", session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800844 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700845 pe_debug("vht su tx bformer %d",
Krunal Soni53993f72016-07-08 18:20:03 -0700846 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847
848 /* Delete pre-auth list if any */
849 lim_delete_pre_auth_list(mac_ctx);
850
Krunal Soni53993f72016-07-08 18:20:03 -0700851 if (session->nss == 1) {
852 session->vht_config.su_beam_former = 0;
853 session->vht_config.tx_stbc = 0;
854 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530855 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -0700856 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800857 /*
858 * keep the RSN/WPA IE information in PE Session Entry
859 * later will be using this to check when received (Re)Assoc req
860 */
861 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
862 &sme_start_bss_req->rsnIE, session);
863
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700864 if (LIM_IS_AP_ROLE(session) ||
865 LIM_IS_IBSS_ROLE(session) ||
866 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800867 session->gLimProtectionControl =
868 sme_start_bss_req->protEnabled;
869 /*
870 * each byte will have the following info
871 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
872 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
873 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530874 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800875 (void *)&sme_start_bss_req->ht_capab,
876 sizeof(uint16_t));
877 /* Initialize WPS PBC session link list */
878 session->pAPWPSPBCSession = NULL;
879 }
880 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530881 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800882 if (NULL == mlm_start_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700883 pe_err("Allocate Memory failed for mlmStartReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800884 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
885 goto free;
886 }
887
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800888 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530889 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800890 (uint8_t *) &sme_start_bss_req->ssId,
891 sme_start_bss_req->ssId.length + 1);
892 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
893 mlm_start_req->obssProtEnabled =
894 sme_start_bss_req->obssProtEnabled;
895
896 mlm_start_req->bssType = session->bssType;
897
898 /* Fill PE session Id from the session Table */
899 mlm_start_req->sessionId = session->peSessionId;
900
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700901 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
902 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800903 /*
904 * Copy the BSSId from sessionTable to
905 * mlmStartReq struct
906 */
907 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
908 } else {
909 /* ibss mode */
910 mac_ctx->lim.gLimIbssCoalescingHappened = false;
911
912 ret_status = wlan_cfg_get_int(mac_ctx,
913 WNI_CFG_IBSS_AUTO_BSSID,
914 &auto_gen_bssid);
915 if (ret_status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700916 pe_err("Get Auto Gen BSSID fail,Status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800917 ret_status);
Abhishek Singh4294f802017-08-10 16:37:07 +0530918 ret_code = eSIR_LOGE_EXCEPTION;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800919 goto free;
920 }
921
922 if (!auto_gen_bssid) {
923 /*
924 * We're not auto generating BSSID.
925 * Instead, get it from session entry
926 */
927 sir_copy_mac_addr(mlm_start_req->bssId,
928 session->bssId);
929 /*
930 * Start IBSS group BSSID
931 * Auto Generating BSSID.
932 */
933 auto_gen_bssid = ((mlm_start_req->bssId[0] &
934 0x01) ? true : false);
935 }
936
937 if (auto_gen_bssid) {
938 /*
939 * if BSSID is not any uc id.
940 * then use locally generated BSSID.
941 * Autogenerate the BSSID
942 */
943 lim_get_random_bssid(mac_ctx,
944 mlm_start_req->bssId);
945 mlm_start_req->bssId[0] = 0x02;
946
947 /*
948 * Copy randomly generated BSSID
949 * to the session Table
950 */
951 sir_copy_mac_addr(session->bssId,
952 mlm_start_req->bssId);
953 }
954 }
955 /* store the channel num in mlmstart req structure */
956 mlm_start_req->channelNumber = session->currentOperChannel;
957 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
958 mlm_start_req->beaconPeriod =
959 session->beaconParams.beaconInterval;
Arif Hussain671a1902017-03-17 09:08:32 -0700960 mlm_start_req->cac_duration_ms =
961 sme_start_bss_req->cac_duration_ms;
962 mlm_start_req->dfs_regdomain =
963 sme_start_bss_req->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800964 if (LIM_IS_AP_ROLE(session)) {
965 mlm_start_req->dtimPeriod = session->dtimPeriod;
966 mlm_start_req->wps_state = session->wps_state;
967
968 } else {
969 if (wlan_cfg_get_int(mac_ctx,
970 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700971 pe_err("could not retrieve DTIM Period");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800972 mlm_start_req->dtimPeriod = (uint8_t) val;
973 }
974
975 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
976 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700977 pe_err("could not retrieve Beacon interval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800978 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
979
980 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
981 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700982 pe_err("could not retrieve CFPMaxDuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800983 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
984
985 /*
986 * this may not be needed anymore now,
987 * as rateSet is now included in the
988 * session entry and MLM has session context.
989 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530990 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800991 (void *)&session->rateSet,
992 sizeof(tSirMacRateSet));
993
994 /* Now populate the 11n related parameters */
995 mlm_start_req->nwType = session->nwType;
996 mlm_start_req->htCapable = session->htCapability;
997
998 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
999 /* Unused */
1000 mlm_start_req->dualCTSProtection =
1001 mac_ctx->lim.gHTDualCTSProtection;
1002 mlm_start_req->txChannelWidthSet =
1003 session->htRecommendedTxWidthSet;
1004
1005 session->limRFBand = lim_get_rf_band(channel_number);
1006
1007 /* Initialize 11h Enable Flag */
1008 session->lim11hEnable = 0;
gaolez76d2a162017-03-21 19:23:58 +08001009 if (mlm_start_req->bssType != eSIR_IBSS_MODE &&
1010 (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001011 BAND_5G == session->limRFBand)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012 if (wlan_cfg_get_int(mac_ctx,
1013 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001014 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001015 else
1016 session->lim11hEnable = val;
1017
1018 if (session->lim11hEnable &&
1019 (eSIR_INFRA_AP_MODE ==
1020 mlm_start_req->bssType)) {
1021 cfg_get_wmi_dfs_master_param =
1022 wlan_cfg_get_int(mac_ctx,
1023 WNI_CFG_DFS_MASTER_ENABLED,
1024 &val);
1025 session->lim11hEnable = val;
1026 }
1027 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1028 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001029 pe_err("Get Fail, CFG DFS ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001030 }
1031
1032 if (!session->lim11hEnable) {
1033 if (cfg_set_int(mac_ctx,
1034 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1035 eSIR_SUCCESS)
1036 /*
1037 * Failed to set the CFG param
1038 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1039 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001040 pe_err("Set LOCAL_POWER_CONSTRAINT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001041 }
1042
Jiachao Wu712d4fd2017-08-23 16:52:34 +08001043 mlm_start_req->beacon_tx_rate = session->beacon_tx_rate;
1044
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001045 session->limPrevSmeState = session->limSmeState;
1046 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1047 MTRACE(mac_trace
1048 (mac_ctx, TRACE_CODE_SME_STATE,
1049 session->peSessionId,
1050 session->limSmeState));
1051
1052 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1053 (uint32_t *) mlm_start_req);
1054 return;
1055 } else {
1056
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001057 pe_err("Received unexpected START_BSS_REQ, in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001058 mac_ctx->lim.gLimSmeState);
1059 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001060 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001061 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1062
1063free:
1064 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001065 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001066 session->pLimStartBssReq = NULL;
1067 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001068 if (NULL != sme_start_bss_req)
1069 qdf_mem_free(sme_start_bss_req);
1070 if (NULL != mlm_start_req)
1071 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001072 if (NULL != session) {
1073 pe_delete_session(mac_ctx, session);
1074 session = NULL;
1075 }
1076 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1077 session, sme_session_id, sme_transaction_id);
1078}
1079
1080/**
1081 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1082 *
1083 * @pMac: Global MAC context
1084 * @pMsg: Message pointer
1085 *
1086 * Wrapper for the function __lim_handle_sme_start_bss_request
1087 * This message will be defered until softmac come out of
1088 * scan mode or if we have detected radar on the current
1089 * operating channel.
1090 *
1091 * return true - If we consumed the buffer
1092 * false - If have defered the message.
1093 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001094static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1095 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001096{
1097 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1098 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1099 /**
1100 * If message defered, buffer is not consumed yet.
1101 * So return false
1102 */
1103 return false;
1104 }
1105
1106 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1107 return true;
1108}
1109
1110/**
1111 * lim_get_random_bssid()
1112 *
1113 * FUNCTION:This function is called to process generate the random number for bssid
1114 * This function is called to process SME_SCAN_REQ message
1115 * from HDD or upper layer application.
1116 *
1117 * LOGIC:
1118 *
1119 * ASSUMPTIONS:
1120 *
1121 * NOTE:
1122 * 1. geneartes the unique random number for bssid in ibss
1123 *
1124 * @param pMac Pointer to Global MAC structure
1125 * @param *data Pointer to bssid buffer
1126 * @return None
1127 */
1128void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1129{
1130 uint32_t random[2];
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001131
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001132 random[0] = tx_time_get();
1133 random[0] |= (random[0] << 15);
1134 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301135 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001136}
1137
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001138/**
1139 * __lim_process_clear_dfs_channel_list()
1140 *
1141 ***FUNCTION:
1142 ***Clear DFS channel list when country is changed/aquired.
1143 .*This message is sent from SME.
1144 *
1145 ***LOGIC:
1146 *
1147 ***ASSUMPTIONS:
1148 *
1149 ***NOTE:
1150 *
1151 * @param pMac Pointer to Global MAC structure
1152 * @param *pMsgBuf A pointer to the SME message buffer
1153 * @return None
1154 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001155static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1156 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001157{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301158 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001159}
1160
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301161#ifdef WLAN_FEATURE_SAE
1162
1163/**
1164 * lim_update_sae_config()- This API update SAE session info to csr config
1165 * from join request.
1166 * @session: PE session
1167 * @sme_join_req: pointer to join request
1168 *
1169 * Return: None
1170 */
1171static void lim_update_sae_config(tpPESession session,
1172 tpSirSmeJoinReq sme_join_req)
1173{
1174 session->sae_pmk_cached = sme_join_req->sae_pmk_cached;
1175
1176 pe_debug("pmk_cached %d for BSSID=" MAC_ADDRESS_STR,
1177 session->sae_pmk_cached,
1178 MAC_ADDR_ARRAY(sme_join_req->bssDescription.bssId));
1179}
1180#else
1181static inline void lim_update_sae_config(tpPESession session,
1182 tpSirSmeJoinReq sme_join_req)
1183{}
1184#endif
1185
1186
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001187/**
1188 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1189 * @mac_ctx: Pointer to Global MAC structure
1190 * @msg_buf: A pointer to the SME message buffer
1191 *
1192 * This function is called to process SME_JOIN_REQ message
1193 * from HDD or upper layer application.
1194 *
1195 * Return: None
1196 */
1197static void
1198__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1199{
1200 tpSirSmeJoinReq sme_join_req = NULL;
1201 tLimMlmJoinReq *mlm_join_req;
1202 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1203 uint32_t val = 0;
1204 uint16_t n_size;
1205 uint8_t session_id;
1206 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301207 uint8_t sme_session_id = 0;
1208 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001209 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001210 uint16_t ie_len;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001211 const uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001212 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001213 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001214
Arif Hussain995fcaf2016-07-18 11:28:22 -07001215 if (!mac_ctx || !msg_buf) {
1216 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1217 FL("JOIN REQ with invalid data"));
1218 return;
1219 }
1220
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001221/* FEATURE_WLAN_DIAG_SUPPORT */
1222#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1223 /*
1224 * Not sending any session, since it is not created yet.
1225 * The response whould have correct state.
1226 */
1227 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1228#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1229
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001230 /*
1231 * Expect Join request in idle state.
1232 * Reassociate request is expected in link established state.
1233 */
1234
1235 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1236 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1237 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1238 msg_buf);
1239
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301240 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241 if (NULL == sme_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001242 pe_err("AllocateMemory failed for sme_join_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001243 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301244 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001245 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301246 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247 n_size);
1248
1249 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1250 /* Received invalid eWNI_SME_JOIN_REQ */
1251 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001252 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001253 sme_join_req->sessionId);
1254 ret_code = eSIR_SME_INVALID_PARAMETERS;
1255 goto end;
1256 }
1257
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001258 /*
1259 * Update the capability here itself as this is used in
1260 * lim_extract_ap_capability() below. If not updated issues
1261 * like not honoring power constraint on 1st association after
1262 * driver loading might occur.
1263 */
1264 lim_update_rrm_capability(mac_ctx, sme_join_req);
1265
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001266 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001267 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001268 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001269 &session_id);
1270
1271 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001272 pe_err("Session(%d) Already exists for BSSID: "
1273 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001274 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001275 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001276 session->limSmeState);
1277
1278 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1279 session->smeSessionId == sme_join_req->sessionId) {
1280 /*
1281 * Received eWNI_SME_JOIN_REQ for same
1282 * BSS as currently associated.
1283 * Log the event and send success
1284 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001285 pe_warn("SessionId: %d", session_id);
1286 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001287 /* Send Join success response to host */
1288 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1289 session = NULL;
1290 goto end;
1291 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001292 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293 ret_code = eSIR_SME_REFUSED;
1294 session = NULL;
1295 goto end;
1296 }
1297 } else {
1298 /*
1299 * Session Entry does not exist for given BSSId
1300 * Try to Create a new session
1301 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001302 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001303 &session_id, mac_ctx->lim.maxStation,
1304 eSIR_INFRASTRUCTURE_MODE);
1305 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001306 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001307 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1308 goto end;
1309 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001310 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001311 session_id);
1312 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001313 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001314
1315 /*
1316 * Store Session related parameters
1317 * Store PE session Id in session Table
1318 */
1319 session->peSessionId = session_id;
1320
1321 /* store the smejoin req handle in session table */
1322 session->pLimJoinReq = sme_join_req;
1323
1324 /* Store SME session Id in sessionTable */
1325 session->smeSessionId = sme_join_req->sessionId;
1326
1327 /* Store SME transaction Id in session Table */
1328 session->transactionId = sme_join_req->transactionId;
1329
1330 /* Store beaconInterval */
1331 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001332 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001333
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301334 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001335 sizeof(session->htConfig));
1336
Sandeep Puligilla98917432016-06-10 13:50:28 -07001337 qdf_mem_copy(&(session->vht_config),
1338 &(sme_join_req->vht_config),
1339 sizeof(session->vht_config));
1340
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341 /* Copying of bssId is already done, while creating session */
1342 sir_copy_mac_addr(session->selfMacAddr,
1343 sme_join_req->selfMacAddr);
1344 session->bssType = sme_join_req->bsstype;
1345
1346 session->statypeForBss = STA_ENTRY_PEER;
1347 session->limWmeEnabled = sme_join_req->isWMEenabled;
1348 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301349 session->wps_registration = sme_join_req->wps_registration;
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001350 session->he_with_wep_tkip = sme_join_req->he_with_wep_tkip;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001351
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301352 session->enable_bcast_probe_rsp =
1353 sme_join_req->enable_bcast_probe_rsp;
1354
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001355 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001356 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001357 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1358
Naveen Rawat08db88f2017-09-08 15:07:48 -07001359 vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001360 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001361 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001362
1363 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001364 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001365 session->isCiscoVendorAP = true;
1366 } else {
1367 session->isCiscoVendorAP = false;
1368 }
1369
1370 /* Copy the dot 11 mode in to the session table */
1371
1372 session->dot11mode = sme_join_req->dot11mode;
1373#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1374 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1375#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001376 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1378 session->enableHtSmps = sme_join_req->enableHtSmps;
1379 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001380 session->send_smps_action =
1381 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001382 /*
1383 * By default supported NSS 1x1 is set to true
1384 * and later on updated while determining session
1385 * supported rates which is the intersection of
1386 * self and peer rates
1387 */
1388 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301389 /*Store Persona */
1390 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001391 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 -08001392 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001393 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001394 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301395 session->supported_nss_1x1,
1396 session->pePersona,
1397 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001398
1399 /*Store Persona */
1400 session->pePersona = sme_join_req->staPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +05301401 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301402 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d force_24ghz_in_ht20 %d"),
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001403 session->pePersona, sme_join_req->cbMode,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301404 session->nwType, session->dot11mode,
1405 sme_join_req->force_24ghz_in_ht20);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001406
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001407 /* Copy The channel Id to the session Table */
1408 session->currentOperChannel = bss_desc->channelId;
1409 if (IS_5G_CH(session->currentOperChannel))
1410 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001411 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001412 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1413 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1414 session->vdev_nss = vdev_type_nss->p2p_cli;
1415 else
1416 session->vdev_nss = vdev_type_nss->sta;
1417 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001418 session->vhtCapability =
1419 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001420 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301421 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001422 session->vht_config.su_beam_formee =
1423 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001424 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001425 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001426 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001427 session->enableVhtpAid =
1428 sme_join_req->enableVhtpAid;
1429 session->enableVhtGid =
1430 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001431 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001432 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001433 }
Krunal Soni53993f72016-07-08 18:20:03 -07001434
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001435 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301436 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001437 session->vht_config.su_beam_formee,
1438 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001439 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001441 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001442 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301443 session->force_24ghz_in_ht20 =
1444 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001445 /* cbMode is already merged value of peer and self -
1446 * done by csr in csr_get_cb_mode_from_ies */
1447 session->htSupportedChannelWidthSet =
1448 (sme_join_req->cbMode) ? 1 : 0;
1449 session->htRecommendedTxWidthSet =
1450 session->htSupportedChannelWidthSet;
1451 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1452
1453 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1454 session->ch_center_freq_seg0 =
1455 session->currentOperChannel - 2;
1456 session->ch_width = CH_WIDTH_40MHZ;
1457 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1458 sme_join_req->cbMode) {
1459 session->ch_center_freq_seg0 =
1460 session->currentOperChannel + 2;
1461 session->ch_width = CH_WIDTH_40MHZ;
1462 } else {
1463 session->ch_center_freq_seg0 = 0;
1464 session->ch_width = CH_WIDTH_20MHZ;
1465 }
1466
Naveen Rawataeca1b92017-10-16 16:55:31 -07001467 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1468 lim_update_session_he_capable(mac_ctx, session);
1469 lim_copy_join_req_he_cap(session, sme_join_req);
1470 }
1471
1472
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001473 /* Record if management frames need to be protected */
1474#ifdef WLAN_FEATURE_11W
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +05301475 if ((eSIR_ED_AES_128_CMAC ==
1476 sme_join_req->MgmtEncryptionType) ||
1477 (eSIR_ED_AES_GMAC_128 == sme_join_req->MgmtEncryptionType) ||
1478 (eSIR_ED_AES_GMAC_256 == sme_join_req->MgmtEncryptionType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001479 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001480 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001481 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001482#endif
1483
1484#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001485 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001486#endif
1487
1488 /* Copy the SSID from smejoinreq to session entry */
1489 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301490 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001491 session->ssId.length);
1492
1493 /*
1494 * Determin 11r or ESE connection based on input from SME
1495 * which inturn is dependent on the profile the user wants
1496 * to connect to, So input is coming from supplicant
1497 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001498 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001499#ifdef FEATURE_WLAN_ESE
1500 session->isESEconnection = sme_join_req->isESEconnection;
1501#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001502 session->isFastTransitionEnabled =
1503 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001504
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001505 session->isFastRoamIniFeatureEnabled =
1506 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001507 session->txLdpcIniFeatureEnabled =
1508 sme_join_req->txLdpcIniFeatureEnabled;
1509
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301510 lim_update_fils_config(session, sme_join_req);
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301511 lim_update_sae_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001512 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1513 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001514 } else {
1515 /*
1516 * Throw an error and return and make
1517 * sure to delete the session.
1518 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001519 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001520 session->bssType);
1521 ret_code = eSIR_SME_INVALID_PARAMETERS;
1522 goto end;
1523 }
1524
1525 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301526 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001527 &sme_join_req->addIEScan, sizeof(tSirAddie));
1528
1529 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301530 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1532
1533 val = sizeof(tLimMlmJoinReq) +
1534 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301535 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001536 if (NULL == mlm_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001537 pe_err("AllocateMemory failed for mlmJoinReq");
Nitesh Shah0102cac2016-07-13 14:38:30 +05301538 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1539 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001540 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001541
1542 /* PE SessionId is stored as a part of JoinReq */
1543 mlm_join_req->sessionId = session->peSessionId;
1544
1545 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1546 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1547 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001548 pe_err("couldn't retrieve JoinFailureTimer value"
1549 " setting to default value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001550 mlm_join_req->joinFailureTimeout =
1551 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1552 }
1553
1554 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301555 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001556 (void *)&sme_join_req->operationalRateSet,
1557 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301558 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001559 (void *)&sme_join_req->extendedRateSet,
1560 sizeof(tSirMacRateSet));
1561 /*
1562 * this may not be needed anymore now, as rateSet is now
1563 * included in the session entry and MLM has session context.
1564 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301565 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001566 (void *)&session->rateSet,
1567 sizeof(tSirMacRateSet));
1568
1569 session->encryptType = sme_join_req->UCEncryptionType;
1570
1571 mlm_join_req->bssDescription.length =
1572 session->pLimJoinReq->bssDescription.length;
1573
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301574 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001575 (uint8_t *)
1576 &session->pLimJoinReq->bssDescription.bssId,
1577 session->pLimJoinReq->bssDescription.length + 2);
1578
1579 session->limCurrentBssCaps =
1580 session->pLimJoinReq->bssDescription.capabilityInfo;
1581
1582 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1583 session->currentOperChannel);
1584 local_power_constraint = reg_max;
1585
1586 lim_extract_ap_capability(mac_ctx,
1587 (uint8_t *)
1588 session->pLimJoinReq->bssDescription.ieFields,
1589 lim_get_ielen_from_bss_description(
1590 &session->pLimJoinReq->bssDescription),
1591 &session->limCurrentBssQosCaps,
1592 &session->limCurrentBssPropCap,
1593 &session->gLimCurrentBssUapsd,
1594 &local_power_constraint, session);
1595
Krunal Soni53993f72016-07-08 18:20:03 -07001596 /*
1597 * Once the AP capabilities are available then set the
1598 * beam forming capabilities accordingly.
1599 */
1600 if (session->nss == 1) {
1601 session->vht_config.su_beam_former = 0;
1602 session->vht_config.tx_stbc = 0;
1603 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301604 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001605 }
1606
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001607 session->maxTxPower = lim_get_max_tx_power(reg_max,
1608 local_power_constraint,
1609 mac_ctx->roam.configParam.nTxPowerCap);
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301610
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001611 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301612 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001613
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301614 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1615 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1616 pe_debug("Update MaxTxPower in join Req to %d",
1617 sme_join_req->powerCap.maxTxPower);
1618 }
1619
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001620 if (session->gLimCurrentBssUapsd) {
1621 session->gUapsdPerAcBitmask =
1622 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001623 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001624 session->gUapsdPerAcBitmask);
1625
1626 /* resetting the dynamic uapsd mask */
1627 session->gUapsdPerAcDeliveryEnableMask = 0;
1628 session->gUapsdPerAcTriggerEnableMask = 0;
1629 }
1630
1631 session->limRFBand =
1632 lim_get_rf_band(session->currentOperChannel);
1633
1634 /* Initialize 11h Enable Flag */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001635 if (BAND_5G == session->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001636 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1637 &val) != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001638 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001639 session->lim11hEnable =
1640 WNI_CFG_11H_ENABLED_STADEF;
1641 } else {
1642 session->lim11hEnable = val;
1643 }
1644 } else {
1645 session->lim11hEnable = 0;
1646 }
1647
1648 /*
1649 * To care of the scenario when STA transitions from
1650 * IBSS to Infrastructure mode.
1651 */
1652 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1653
1654 session->limPrevSmeState = session->limSmeState;
1655 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1656 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1657 session->peSessionId,
1658 session->limSmeState));
1659
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001660 /* Indicate whether spectrum management is enabled */
1661 session->spectrumMgtEnabled =
1662 sme_join_req->spectrumMgtIndicator;
1663
1664 /* Enable the spectrum management if this is a DFS channel */
1665 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001666 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001667 session->currentOperChannel))
1668 session->spectrumMgtEnabled = true;
1669
1670 session->isOSENConnection = sme_join_req->isOSENConnection;
1671
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001672 /* Issue LIM_MLM_JOIN_REQ to MLM */
1673 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1674 (uint32_t *) mlm_join_req);
1675 return;
1676
1677 } else {
1678 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001679 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001680 mac_ctx->lim.gLimSmeState);
1681 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1682 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1683 session = NULL;
1684 goto end;
1685 }
1686
1687end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301688 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1689 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001690
1691 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301692 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001693 sme_join_req = NULL;
1694 if (NULL != session)
1695 session->pLimJoinReq = NULL;
1696 }
1697 if (ret_code != eSIR_SME_SUCCESS) {
1698 if (NULL != session) {
1699 pe_delete_session(mac_ctx, session);
1700 session = NULL;
1701 }
1702 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001703 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001704 sme_session_id, ret_code);
1705 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1706 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1707 sme_transaction_id);
1708}
1709
Amar Singhala297bfa2015-10-15 15:07:29 -07001710uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001711 uint8_t iniTxPower)
1712{
1713 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301714 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001715
Anurag Chouhan6d760662016-02-20 16:05:43 +05301716 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1718 maxTxPower = txPower;
1719 else if (txPower < MIN_TX_PWR_CAP)
1720 maxTxPower = MIN_TX_PWR_CAP;
1721 else
1722 maxTxPower = MAX_TX_PWR_CAP;
1723
1724 return maxTxPower;
1725}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001726
1727/**
1728 * __lim_process_sme_reassoc_req() - process reassoc req
1729 *
1730 * @mac_ctx: Pointer to Global MAC structure
1731 * @msg_buf: pointer to the SME message buffer
1732 *
1733 * This function is called to process SME_REASSOC_REQ message
1734 * from HDD or upper layer application.
1735 *
1736 * Return: None
1737 */
1738
1739static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
1740 uint32_t *msg_buf)
1741{
1742 uint16_t caps;
1743 uint32_t val;
1744 tpSirSmeJoinReq reassoc_req = NULL;
1745 tLimMlmReassocReq *mlm_reassoc_req;
1746 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1747 tpPESession session_entry = NULL;
1748 uint8_t session_id;
1749 uint8_t sme_session_id;
1750 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001751 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001752 uint32_t tele_bcn_en = 0;
1753 uint16_t size;
1754
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001755 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301756 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001757 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001758 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001759
1760 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1761 goto end;
1762 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301763 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001764
1765 if (!lim_is_sme_join_req_valid(mac_ctx,
1766 (tpSirSmeJoinReq)reassoc_req)) {
1767 /*
1768 * Received invalid eWNI_SME_REASSOC_REQ
1769 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001770 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001771
1772 ret_code = eSIR_SME_INVALID_PARAMETERS;
1773 goto end;
1774 }
1775
1776 session_entry = pe_find_session_by_bssid(mac_ctx,
1777 reassoc_req->bssDescription.bssId,
1778 &session_id);
1779 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001780 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001781 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
1782 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001783 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001784 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
1785 &sme_session_id, &transaction_id);
1786 session_entry =
1787 pe_find_session_by_sme_session_id(mac_ctx,
1788 sme_session_id);
1789 if (session_entry != NULL)
1790 lim_handle_sme_join_result(mac_ctx,
1791 eSIR_SME_INVALID_PARAMETERS,
1792 eSIR_MAC_UNSPEC_FAILURE_STATUS,
1793 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001794 goto end;
1795 }
1796#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
1797 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
1798 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
1799#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1800 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
1801
1802 /* Store the reassoc handle in the session Table */
1803 session_entry->pLimReAssocReq = reassoc_req;
1804
1805 session_entry->dot11mode = reassoc_req->dot11mode;
1806 session_entry->vhtCapability =
1807 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001808
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301809 if (session_entry->vhtCapability) {
1810 if (session_entry->pePersona == QDF_STA_MODE) {
1811 session_entry->vht_config.su_beam_formee =
1812 reassoc_req->vht_config.su_beam_formee;
1813 } else {
1814 reassoc_req->vht_config.su_beam_formee = 0;
1815 }
1816 session_entry->enableVhtpAid =
1817 reassoc_req->enableVhtpAid;
1818 session_entry->enableVhtGid =
1819 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001820 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301821 }
1822
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001823 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301824 session_entry->vhtCapability,
1825 session_entry->vht_config.su_beam_formee,
1826 session_entry->vht_config.su_beam_former);
1827
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001828 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
1829 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001830 session_entry->send_smps_action =
1831 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001832 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001833 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001834 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001835 session_entry->send_smps_action,
1836 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001837 /*
1838 * Reassociate request is expected
1839 * in link established state only.
1840 */
1841
1842 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001843 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
1844 /*
1845 * May be from 11r FT pre-auth. So lets check it
1846 * before we bail out
1847 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001848 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001849 session_entry->peSessionId);
1850
1851 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301852 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853 session_entry->limReAssocbssId,
1854 6)) {
1855 lim_print_mac_addr(mac_ctx,
1856 reassoc_req->bssDescription.
1857 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001858 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001859 ret_code = eSIR_SME_INVALID_PARAMETERS;
1860 goto end;
1861 }
1862
1863 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
1864 session_entry);
1865 return;
1866 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001867 /*
1868 * Should not have received eWNI_SME_REASSOC_REQ
1869 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001870 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001871 session_entry->limSmeState);
1872 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
1873
1874 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1875 goto end;
1876 }
1877
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301878 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001879 session_entry->pLimReAssocReq->bssDescription.bssId,
1880 sizeof(tSirMacAddr));
1881
1882 session_entry->limReassocChannelId =
1883 session_entry->pLimReAssocReq->bssDescription.channelId;
1884
1885 session_entry->reAssocHtSupportedChannelWidthSet =
1886 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
1887 session_entry->reAssocHtRecommendedTxWidthSet =
1888 session_entry->reAssocHtSupportedChannelWidthSet;
1889 session_entry->reAssocHtSecondaryChannelOffset =
1890 session_entry->pLimReAssocReq->cbMode;
1891
1892 session_entry->limReassocBssCaps =
1893 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
1894 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1895 session_entry->currentOperChannel);
1896 local_pwr_constraint = reg_max;
1897
1898 lim_extract_ap_capability(mac_ctx,
1899 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
1900 lim_get_ielen_from_bss_description(
1901 &session_entry->pLimReAssocReq->bssDescription),
1902 &session_entry->limReassocBssQosCaps,
1903 &session_entry->limReassocBssPropCap,
1904 &session_entry->gLimCurrentBssUapsd,
1905 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05301906 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001907 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301908 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001909 /* Copy the SSID from session entry to local variable */
1910 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301911 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001912 reassoc_req->ssId.ssId,
1913 session_entry->limReassocSSID.length);
1914 if (session_entry->gLimCurrentBssUapsd) {
1915 session_entry->gUapsdPerAcBitmask =
1916 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001917 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001918 session_entry->gUapsdPerAcBitmask);
1919 }
1920
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301921 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001922 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001923 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001924
1925 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1926 goto end;
1927 }
1928
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301929 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001930 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
1931
1932 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
1933 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001934 eSIR_SUCCESS)
1935 pe_err("could not retrieve ReassocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001936
1937 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001938 eSIR_SUCCESS)
1939 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301940
1941 lim_update_caps_info_for_bss(mac_ctx, &caps,
1942 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001943 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301944
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001945 mlm_reassoc_req->capabilityInfo = caps;
1946
1947 /* Update PE session_id */
1948 mlm_reassoc_req->sessionId = session_id;
1949
1950 /*
1951 * If telescopic beaconing is enabled, set listen interval to
1952 * WNI_CFG_TELE_BCN_MAX_LI
1953 */
1954 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
1955 &tele_bcn_en) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001956 pe_err("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001957
1958 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
1959
1960 if (tele_bcn_en) {
1961 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
1962 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001963 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001964 } else {
1965 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
1966 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001967 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001968 }
1969
1970 mlm_reassoc_req->listenInterval = (uint16_t) val;
1971
1972 /* Indicate whether spectrum management is enabled */
1973 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
1974
1975 /* Enable the spectrum management if this is a DFS channel */
1976 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001977 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001978 session_entry->currentOperChannel))
1979 session_entry->spectrumMgtEnabled = true;
1980
1981 session_entry->limPrevSmeState = session_entry->limSmeState;
1982 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
1983
1984 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1985 session_entry->peSessionId,
1986 session_entry->limSmeState));
1987
1988 lim_post_mlm_message(mac_ctx,
1989 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
1990 return;
1991end:
1992 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301993 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001994 if (session_entry)
1995 session_entry->pLimReAssocReq = NULL;
1996 }
1997
1998 if (session_entry) {
1999 /*
2000 * error occurred after we determined the session so extract
2001 * session and transaction info from there
2002 */
2003 sme_session_id = session_entry->smeSessionId;
2004 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002005 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002006 /*
2007 * error occurred before or during the time we determined
2008 * the session so extract the session and transaction info
2009 * from the message
2010 */
2011 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2012 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002013 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002014 /*
2015 * Send Reassoc failure response to host
2016 * (note session_entry may be NULL, but that's OK)
2017 */
2018 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2019 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2020 session_entry, sme_session_id,
2021 transaction_id);
2022}
2023
2024bool send_disassoc_frame = 1;
2025/**
2026 * __lim_process_sme_disassoc_req()
2027 *
2028 ***FUNCTION:
2029 * This function is called to process SME_DISASSOC_REQ message
2030 * from HDD or upper layer application.
2031 *
2032 ***LOGIC:
2033 *
2034 ***ASSUMPTIONS:
2035 *
2036 ***NOTE:
2037 *
2038 * @param pMac Pointer to Global MAC structure
2039 * @param *pMsgBuf A pointer to the SME message buffer
2040 * @return None
2041 */
2042
2043static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2044{
2045 uint16_t disassocTrigger, reasonCode;
2046 tLimMlmDisassocReq *pMlmDisassocReq;
2047 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2048 tSirSmeDisassocReq smeDisassocReq;
2049 tpPESession psessionEntry = NULL;
2050 uint8_t sessionId;
2051 uint8_t smesessionId;
2052 uint16_t smetransactionId;
2053
2054 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002055 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002056 return;
2057 }
2058
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302059 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002060 smesessionId = smeDisassocReq.sessionId;
2061 smetransactionId = smeDisassocReq.transactionId;
2062 if (!lim_is_sme_disassoc_req_valid(pMac,
2063 &smeDisassocReq,
2064 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002065 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002066 if (pMac->lim.gLimRspReqd) {
2067 pMac->lim.gLimRspReqd = false;
2068
2069 retCode = eSIR_SME_INVALID_PARAMETERS;
2070 disassocTrigger = eLIM_HOST_DISASSOC;
2071 goto sendDisassoc;
2072 }
2073
2074 return;
2075 }
2076
2077 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002078 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002079 &sessionId);
2080 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002081 pe_err("session does not exist for given bssId "
2082 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002083 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002084 retCode = eSIR_SME_INVALID_PARAMETERS;
2085 disassocTrigger = eLIM_HOST_DISASSOC;
2086 goto sendDisassoc;
2087 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002088 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2089 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002090 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2091 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002092 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002093
2094#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2095 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2096 0, smeDisassocReq.reasonCode);
2097#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2098
2099 /* Update SME session Id and SME transaction ID */
2100
2101 psessionEntry->smeSessionId = smesessionId;
2102 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002103 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002104 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002105
2106 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2107 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002108 switch (psessionEntry->limSmeState) {
2109 case eLIM_SME_ASSOCIATED_STATE:
2110 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002111 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002112 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002113 psessionEntry->limPrevSmeState =
2114 psessionEntry->limSmeState;
2115 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002116 /* Delete all TDLS peers connected before leaving BSS */
2117 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002118 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2119 psessionEntry->peSessionId,
2120 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002121 break;
2122
2123 case eLIM_SME_WT_DEAUTH_STATE:
2124 /* PE shall still process the DISASSOC_REQ and proceed with
2125 * link tear down even if it had already sent a DEAUTH_IND to
2126 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2127 * its been set when PE entered WT_DEAUTH_STATE.
2128 */
2129 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2130 MTRACE(mac_trace
2131 (pMac, TRACE_CODE_SME_STATE,
2132 psessionEntry->peSessionId,
2133 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002134 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002135 break;
2136
2137 case eLIM_SME_WT_DISASSOC_STATE:
2138 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2139 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2140 * PE can continue processing DISASSOC_REQ and send the response instead
2141 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2142 * for disassoc frame.
2143 *
2144 * It will send a disassoc, which is ok. However, we can use the global flag
2145 * sendDisassoc to not send disassoc frame.
2146 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002147 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002148 break;
2149
2150 case eLIM_SME_JOIN_FAILURE_STATE: {
2151 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002152 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002153 if (pMac->lim.gLimRspReqd) {
2154 retCode = eSIR_SME_SUCCESS;
2155 disassocTrigger = eLIM_HOST_DISASSOC;
2156 goto sendDisassoc;
2157 }
2158 }
2159 break;
2160 default:
2161 /**
2162 * STA is not currently associated.
2163 * Log error and send response to host
2164 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002165 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002166 psessionEntry->limSmeState);
2167 lim_print_sme_state(pMac, LOGE,
2168 psessionEntry->limSmeState);
2169
2170 if (pMac->lim.gLimRspReqd) {
2171 if (psessionEntry->limSmeState !=
2172 eLIM_SME_WT_ASSOC_STATE)
2173 pMac->lim.gLimRspReqd = false;
2174
2175 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2176 disassocTrigger = eLIM_HOST_DISASSOC;
2177 goto sendDisassoc;
2178 }
2179
2180 return;
2181 }
2182
2183 break;
2184
2185 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002186 /* Fall through */
2187 break;
2188
2189 case eLIM_STA_IN_IBSS_ROLE:
2190 default:
2191 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002192 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002193 GET_LIM_SYSTEM_ROLE(psessionEntry));
2194
2195 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2196 disassocTrigger = eLIM_HOST_DISASSOC;
2197 goto sendDisassoc;
2198 } /* end switch (pMac->lim.gLimSystemRole) */
2199
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302200 disassocTrigger = eLIM_HOST_DISASSOC;
2201 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002202
2203 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002204 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002205 send_disassoc_frame = 0;
2206 }
2207 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002208 pe_debug("Sending Disasscoc with disassoc Trigger"
2209 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002210 disassocTrigger, reasonCode);
2211
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302212 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002213 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002214 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002215 return;
2216 }
2217
Anurag Chouhanc5548422016-02-24 18:33:27 +05302218 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002219 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002220
2221 pMlmDisassocReq->reasonCode = reasonCode;
2222 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2223
2224 /* Update PE session ID */
2225 pMlmDisassocReq->sessionId = sessionId;
2226
2227 lim_post_mlm_message(pMac,
2228 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2229 return;
2230
2231sendDisassoc:
2232 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002233 lim_send_sme_disassoc_ntf(pMac,
2234 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002235 retCode,
2236 disassocTrigger,
2237 1, smesessionId, smetransactionId,
2238 psessionEntry);
2239 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002240 lim_send_sme_disassoc_ntf(pMac,
2241 smeDisassocReq.peer_macaddr.bytes,
2242 retCode, disassocTrigger, 1,
2243 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002244
2245} /*** end __lim_process_sme_disassoc_req() ***/
2246
2247/** -----------------------------------------------------------------
2248 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2249
2250 This function is called to process SME_DISASSOC_CNF message
2251 from HDD or upper layer application.
2252
2253 \param pMac - global mac structure
2254 \param pStaDs - station dph hash node
2255 \return none
2256 \sa
2257 ----------------------------------------------------------------- */
2258static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2259{
2260 tSirSmeDisassocCnf smeDisassocCnf;
2261 uint16_t aid;
2262 tpDphHashNode pStaDs;
2263 tpPESession psessionEntry;
2264 uint8_t sessionId;
2265
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302266 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002267 sizeof(struct sSirSmeDisassocCnf));
2268
2269 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002270 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002271 &sessionId);
2272 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002273 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002274 return;
2275 }
2276
2277 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002278 pe_err("received invalid SME_DISASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002279 return;
2280 }
2281#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2282 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2283 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2284 psessionEntry,
2285 (uint16_t) smeDisassocCnf.statusCode, 0);
2286 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2287 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2288 psessionEntry,
2289 (uint16_t) smeDisassocCnf.statusCode, 0);
2290#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2291
2292 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2293 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002294 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2295 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2296 && (psessionEntry->limSmeState !=
2297 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002298 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002299 psessionEntry->limSmeState);
2300 lim_print_sme_state(pMac, LOGE,
2301 psessionEntry->limSmeState);
2302 return;
2303 }
2304 break;
2305
2306 case eLIM_AP_ROLE:
2307 /* Fall through */
2308 break;
2309
2310 case eLIM_STA_IN_IBSS_ROLE:
2311 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002312 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002313 GET_LIM_SYSTEM_ROLE(psessionEntry));
2314
2315 return;
2316 }
2317
2318 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2319 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2320 LIM_IS_AP_ROLE(psessionEntry)) {
2321 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002322 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002323 &psessionEntry->dph.dphHashTable);
2324 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002325 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2326 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002327 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002328 return;
2329 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302330
2331 if ((pStaDs->mlmStaContext.mlmState ==
2332 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2333 (pStaDs->mlmStaContext.mlmState ==
2334 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002335 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002336 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302337 pStaDs->mlmStaContext.mlmState);
2338 return;
2339 }
2340
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002341 /* Delete FT session if there exists one */
2342 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002343 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2344
2345 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002346 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002347 }
2348
2349 return;
2350}
2351
2352/**
2353 * __lim_process_sme_deauth_req() - process sme deauth req
2354 * @mac_ctx: Pointer to Global MAC structure
2355 * @msg_buf: pointer to the SME message buffer
2356 *
2357 * This function is called to process SME_DEAUTH_REQ message
2358 * from HDD or upper layer application.
2359 *
2360 * Return: None
2361 */
2362
2363static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2364 uint32_t *msg_buf)
2365{
2366 uint16_t deauth_trigger, reason_code;
2367 tLimMlmDeauthReq *mlm_deauth_req;
2368 tSirSmeDeauthReq sme_deauth_req;
2369 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2370 tpPESession session_entry;
2371 uint8_t session_id; /* PE sessionId */
2372 uint8_t sme_session_id;
2373 uint16_t sme_transaction_id;
2374
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302375 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002376 sme_session_id = sme_deauth_req.sessionId;
2377 sme_transaction_id = sme_deauth_req.transactionId;
2378
2379 /*
2380 * We need to get a session first but we don't even know
2381 * if the message is correct.
2382 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002383 session_entry = pe_find_session_by_bssid(mac_ctx,
2384 sme_deauth_req.bssid.bytes,
2385 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002386 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002387 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002388 ret_code = eSIR_SME_INVALID_PARAMETERS;
2389 deauth_trigger = eLIM_HOST_DEAUTH;
2390 goto send_deauth;
2391 }
2392
2393 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2394 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002395 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002396 mac_ctx->lim.gLimRspReqd = false;
2397
2398 ret_code = eSIR_SME_INVALID_PARAMETERS;
2399 deauth_trigger = eLIM_HOST_DEAUTH;
2400 goto send_deauth;
2401 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002402 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2403 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002404 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2405 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002406 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002407#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2408 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2409 session_entry, 0, sme_deauth_req.reasonCode);
2410#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2411
2412 /* Update SME session ID and Transaction ID */
2413 session_entry->smeSessionId = sme_session_id;
2414 session_entry->transactionId = sme_transaction_id;
2415
2416 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2417 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002418 switch (session_entry->limSmeState) {
2419 case eLIM_SME_ASSOCIATED_STATE:
2420 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302421 /* Delete all TDLS peers connected before leaving BSS */
2422 lim_delete_tdls_peers(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002423 case eLIM_SME_WT_ASSOC_STATE:
2424 case eLIM_SME_JOIN_FAILURE_STATE:
2425 case eLIM_SME_IDLE_STATE:
2426 session_entry->limPrevSmeState =
2427 session_entry->limSmeState;
2428 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2429 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2430 session_entry->peSessionId,
2431 session_entry->limSmeState));
2432 /* Send Deauthentication request to MLM below */
2433 break;
2434 case eLIM_SME_WT_DEAUTH_STATE:
2435 case eLIM_SME_WT_DISASSOC_STATE:
2436 /*
2437 * PE Recieved a Deauth/Disassoc frame. Normally it get
2438 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2439 * Which means host is also trying to disconnect.
2440 * PE can continue processing DEAUTH_REQ and send
2441 * the response instead of failing the request.
2442 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2443 * was sent for deauth/disassoc frame.
2444 */
2445 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002446 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002447 break;
2448 default:
2449 /*
2450 * STA is not in a state to deauthenticate with
2451 * peer. Log error and send response to host.
2452 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002453 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002454 session_entry->limSmeState);
2455 lim_print_sme_state(mac_ctx, LOGE,
2456 session_entry->limSmeState);
2457
2458 if (mac_ctx->lim.gLimRspReqd) {
2459 mac_ctx->lim.gLimRspReqd = false;
2460
2461 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2462 deauth_trigger = eLIM_HOST_DEAUTH;
2463
wadesong42968e92017-06-08 14:11:21 +08002464 /*
2465 * here we received deauth request from AP so
2466 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2467 * have ISSUED delSta then mlm state should be
2468 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2469 * delBSS rsp then mlm state should be
2470 * eLIM_MLM_IDLE_STATE so the below condition
2471 * captures the state where delSta not done
2472 * and firmware still in connected state.
2473 */
2474 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002475 eLIM_SME_WT_DEAUTH_STATE &&
2476 session_entry->limMlmState !=
2477 eLIM_MLM_IDLE_STATE &&
2478 session_entry->limMlmState !=
2479 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002480 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002481 goto send_deauth;
2482 }
2483 return;
2484 }
2485 break;
2486
2487 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002488 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002489 if (mac_ctx->lim.gLimRspReqd) {
2490 mac_ctx->lim.gLimRspReqd = false;
2491 ret_code = eSIR_SME_INVALID_PARAMETERS;
2492 deauth_trigger = eLIM_HOST_DEAUTH;
2493 goto send_deauth;
2494 }
2495 return;
2496 case eLIM_AP_ROLE:
2497 break;
2498 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002499 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002500 GET_LIM_SYSTEM_ROLE(session_entry));
2501 if (mac_ctx->lim.gLimRspReqd) {
2502 mac_ctx->lim.gLimRspReqd = false;
2503 ret_code = eSIR_SME_INVALID_PARAMETERS;
2504 deauth_trigger = eLIM_HOST_DEAUTH;
2505 goto send_deauth;
2506 }
2507 return;
2508 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2509
2510 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2511 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002512 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002513 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2514 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2515 } else {
2516 deauth_trigger = eLIM_HOST_DEAUTH;
2517 reason_code = sme_deauth_req.reasonCode;
2518 }
2519
2520 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302521 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002522 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002523 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002524 if (mac_ctx->lim.gLimRspReqd) {
2525 mac_ctx->lim.gLimRspReqd = false;
2526 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2527 deauth_trigger = eLIM_HOST_DEAUTH;
2528 goto send_deauth;
2529 }
2530 return;
2531 }
2532
Anurag Chouhanc5548422016-02-24 18:33:27 +05302533 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002534 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002535
2536 mlm_deauth_req->reasonCode = reason_code;
2537 mlm_deauth_req->deauthTrigger = deauth_trigger;
2538
2539 /* Update PE session Id */
2540 mlm_deauth_req->sessionId = session_id;
2541
2542 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2543 (uint32_t *)mlm_deauth_req);
2544 return;
2545
2546send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002547 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2548 ret_code, deauth_trigger, 1,
2549 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002550}
2551
2552/**
2553 * __lim_process_sme_set_context_req()
2554 *
2555 * @mac_ctx: Pointer to Global MAC structure
2556 * @msg_buf: pointer to the SME message buffer
2557 *
2558 * This function is called to process SME_SETCONTEXT_REQ message
2559 * from HDD or upper layer application.
2560 *
2561 * Return: None
2562 */
2563
2564static void
2565__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2566{
2567 tpSirSmeSetContextReq set_context_req;
2568 tLimMlmSetKeysReq *mlm_set_key_req;
2569 tpPESession session_entry;
2570 uint8_t session_id; /* PE sessionID */
2571 uint8_t sme_session_id;
2572 uint16_t sme_transaction_id;
2573
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002574 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002575 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002576 return;
2577 }
2578
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302579 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002580 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002581 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002582 return;
2583 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302584 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002585 sizeof(struct sSirSmeSetContextReq));
2586 sme_session_id = set_context_req->sessionId;
2587 sme_transaction_id = set_context_req->transactionId;
2588
2589 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002590 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002591 goto end;
2592 }
2593
2594 if (set_context_req->keyMaterial.numKeys >
2595 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002596 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002597 set_context_req->keyMaterial.numKeys);
2598 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002599 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002600 eSIR_SME_INVALID_PARAMETERS, NULL,
2601 sme_session_id, sme_transaction_id);
2602 goto end;
2603 }
2604
2605 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002606 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002607 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002608 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002609 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002610 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002611 eSIR_SME_INVALID_PARAMETERS, NULL,
2612 sme_session_id, sme_transaction_id);
2613 goto end;
2614 }
2615#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2616 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2617 session_entry, 0, 0);
2618#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2619
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002620 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002621 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2622 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002623 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002624 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2625 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302626 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002627 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002628 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002629 goto end;
2630 }
2631 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2632 mlm_set_key_req->numKeys =
2633 set_context_req->keyMaterial.numKeys;
2634 if (mlm_set_key_req->numKeys >
2635 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002636 pe_err("no.of keys exceeded max num of default keys limit");
Jingxiang Ge4168a232018-01-03 18:47:15 +08002637 qdf_mem_free(mlm_set_key_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002638 goto end;
2639 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302640 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002641 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002642
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302643 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002644 (uint8_t *) &set_context_req->keyMaterial.key,
2645 sizeof(tSirKeys) *
2646 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2647 numKeys : 1));
2648
2649 mlm_set_key_req->sessionId = session_id;
2650 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002651 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002652 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002653
2654 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2655 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2656 LIM_IS_AP_ROLE(session_entry)) {
2657 if (set_context_req->keyMaterial.key[0].keyLength) {
2658 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002659
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660 key_id =
2661 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302662 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002663 &session_entry->WEPKeyMaterial[key_id],
2664 (uint8_t *) &set_context_req->keyMaterial,
2665 sizeof(tSirKeyMaterial));
2666 } else {
2667 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002668
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002669 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2670 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302671 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002672 &mlm_set_key_req->key[i],
2673 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2674 sizeof(tSirKeys));
2675 }
2676 }
2677 }
2678 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2679 (uint32_t *) mlm_set_key_req);
2680 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002681 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002682 GET_LIM_SYSTEM_ROLE(session_entry),
2683 session_entry->limSmeState);
2684 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2685
2686 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002687 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002688 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2689 session_entry, sme_session_id,
2690 sme_transaction_id);
2691 }
2692end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302693 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002694 return;
2695}
2696
2697/**
2698 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2699 *
2700 * @mac_ctx: Pointer to Global MAC structure
2701 * @msg_buf: pointer to the SME message buffer
2702 *
2703 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2704 * from HDD or upper layer application.
2705 *
2706 * Return: None
2707 */
2708
Jeff Johnson801f1532016-10-07 07:54:50 -07002709static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2710 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002711{
2712 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2713 tpDphHashNode sta_ds = NULL;
2714 tpPESession session_entry = NULL;
2715 tSap_Event sap_event;
2716 tpWLAN_SAPEventCB sap_event_cb = NULL;
2717 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2718 uint8_t session_id = CSR_SESSION_ID_INVALID;
2719 uint8_t assoc_id = 0;
2720 uint8_t sta_cnt = 0;
2721
2722 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002723 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002724 return;
2725 }
2726
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302727 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002728 sizeof(struct sSirSmeGetAssocSTAsReq));
2729 /*
2730 * Get Associated stations from PE.
2731 * Find PE session Entry
2732 */
2733 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08002734 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002735 &session_id);
2736 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002737 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002738 goto lim_assoc_sta_end;
2739 }
2740
2741 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002742 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002743 session_entry->limSmeState,
2744 GET_LIM_SYSTEM_ROLE(session_entry));
2745 goto lim_assoc_sta_end;
2746 }
2747 /* Retrieve values obtained in the request message */
2748 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
2749 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2750
2751 if (NULL == assoc_sta_tmp)
2752 goto lim_assoc_sta_end;
2753 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
2754 assoc_id++) {
2755 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
2756 &session_entry->dph.dphHashTable);
2757 if (NULL == sta_ds)
2758 continue;
2759 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302760 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002761 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302762 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002763 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
2764 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
2765
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302766 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002767 (uint8_t *)&sta_ds->supportedRates,
2768 sizeof(tSirSupportedRates));
2769 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
2770 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
2771 assoc_sta_tmp->Support40Mhz =
2772 sta_ds->htDsssCckRate40MHzSupport;
2773
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002774 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002775 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002776 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002777 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002778 pe_debug("Association Id: %d Station Index: %d",
2779 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002780 assoc_sta_tmp++;
2781 sta_cnt++;
2782 }
2783 }
2784lim_assoc_sta_end:
2785 /*
2786 * Call hdd callback with sap event to send the list of
2787 * associated stations from PE
2788 */
2789 if (sap_event_cb != NULL) {
2790 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
2791 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302792 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002793 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
2794 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
2795 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2796 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
2797 }
2798}
2799
2800/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002801 * __lim_counter_measures()
2802 *
2803 * FUNCTION:
2804 * This function is called to "implement" MIC counter measure
2805 * and is *temporary* only
2806 *
2807 * LOGIC: on AP, disassoc all STA associated thru TKIP,
2808 * we don't do the proper STA disassoc sequence since the
2809 * BSS will be stoped anyway
2810 *
2811 ***ASSUMPTIONS:
2812 *
2813 ***NOTE:
2814 *
2815 * @param pMac Pointer to Global MAC structure
2816 * @return None
2817 */
2818
2819static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
2820{
2821 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002822
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002823 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002824 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
2825 mac, psessionEntry, false);
2826};
2827
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002828static void
2829__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2830{
2831 tSirSmeStopBssReq stopBssReq;
2832 tSirRetStatus status;
2833 tLimSmeStates prevState;
2834 tpPESession psessionEntry;
2835 uint8_t smesessionId;
2836 uint8_t sessionId;
2837 uint16_t smetransactionId;
2838 uint8_t i = 0;
2839 tpDphHashNode pStaDs = NULL;
2840
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302841 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002842 smesessionId = stopBssReq.sessionId;
2843 smetransactionId = stopBssReq.transactionId;
2844
2845 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002846 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002847 /* Send Stop BSS response to host */
2848 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2849 eSIR_SME_INVALID_PARAMETERS, smesessionId,
2850 smetransactionId);
2851 return;
2852 }
2853
2854 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08002855 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002856 &sessionId);
2857 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002858 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002859 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2860 eSIR_SME_INVALID_PARAMETERS, smesessionId,
2861 smetransactionId);
2862 return;
2863 }
2864#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2865 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
2866 0, 0);
2867#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2868
2869 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
2870 LIM_IS_STA_ROLE(psessionEntry)) {
2871 /**
2872 * Should not have received STOP_BSS_REQ in states
2873 * other than 'normal' state or on STA in Infrastructure
2874 * mode. Log error and return response to host.
2875 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002876 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002877 psessionEntry->limSmeState,
2878 GET_LIM_SYSTEM_ROLE(psessionEntry));
2879 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
2880 /* / Send Stop BSS response to host */
2881 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2882 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
2883 smetransactionId);
2884 return;
2885 }
2886
2887 if (LIM_IS_AP_ROLE(psessionEntry))
2888 lim_wpspbc_close(pMac, psessionEntry);
2889
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002890 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002891 stopBssReq.reasonCode);
2892
2893 prevState = psessionEntry->limSmeState;
2894
2895 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
2896 MTRACE(mac_trace
2897 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
2898 psessionEntry->limSmeState));
2899
2900 /* Update SME session Id and Transaction Id */
2901 psessionEntry->smeSessionId = smesessionId;
2902 psessionEntry->transactionId = smetransactionId;
2903
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002904 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
2905 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
2906 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002907 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002908
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002909 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
2910 /* Send disassoc all stations associated thru TKIP */
2911 __lim_counter_measures(pMac, psessionEntry);
2912 else
2913 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002914 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
2915 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002916 }
2917
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002918 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
2919 /* Free the buffer allocated in START_BSS_REQ */
2920 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
2921 psessionEntry->addIeParams.probeRespDataLen = 0;
2922 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002923
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002924 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
2925 psessionEntry->addIeParams.assocRespDataLen = 0;
2926 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002927
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002928 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
2929 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
2930 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002931
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002932 /*
2933 * lim_del_bss is also called as part of coalescing,
2934 * when we send DEL BSS followed by Add Bss msg.
2935 */
2936 pMac->lim.gLimIbssCoalescingHappened = false;
2937 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002938 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
2939 pStaDs =
2940 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
2941 if (NULL == pStaDs)
2942 continue;
2943 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
2944 if (eSIR_SUCCESS == status) {
2945 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
2946 pStaDs->assocId, psessionEntry);
2947 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
2948 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002949 pe_err("lim_del_sta failed with Status: %d", status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302950 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002951 }
2952 }
2953 /* send a delBss to HAL and wait for a response */
2954 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
2955
2956 if (status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002957 pe_err("delBss failed for bss %d", psessionEntry->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002958 psessionEntry->limSmeState = prevState;
2959
2960 MTRACE(mac_trace
2961 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
2962 psessionEntry->limSmeState));
2963
2964 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2965 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
2966 smetransactionId);
2967 }
2968}
2969
2970/**
2971 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
2972 * @pMac: Global MAC context
2973 * @pMsg: Message from SME
2974 *
2975 * Wrapper for the function __lim_handle_sme_stop_bss_request
2976 * This message will be defered until softmac come out of
2977 * scan mode. Message should be handled even if we have
2978 * detected radar in the current operating channel.
2979 *
2980 * Return: true - If we consumed the buffer
2981 * false - If have defered the message.
2982 */
2983
Rajeev Kumarfeb96382017-01-22 19:42:09 -08002984static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
2985 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002986{
2987 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
2988 /**
2989 * If message defered, buffer is not consumed yet.
2990 * So return false
2991 */
2992 return false;
2993 }
2994 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
2995 return true;
2996} /*** end __lim_process_sme_stop_bss_req() ***/
2997
2998void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
2999 uint32_t body, tpPESession psessionEntry)
3000{
3001
3002 (void)body;
3003 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3004 lim_ibss_delete(pMac, psessionEntry);
3005 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3006 lim_delete_pre_auth_list(pMac);
3007 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3008 psessionEntry->smeSessionId,
3009 psessionEntry->transactionId);
3010 return;
3011}
3012
3013/**
3014 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3015 *
3016 * @mac_ctx: pointer to mac context
3017 * @msg_type: message type
3018 * @msg_buf: pointer to the SME message buffer
3019 *
3020 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3021 * in BTAMP AP.
3022 *
3023 * Return: None
3024 */
3025
3026void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3027 uint32_t *msg_buf)
3028{
3029 tSirSmeAssocCnf assoc_cnf;
3030 tpDphHashNode sta_ds = NULL;
3031 tpPESession session_entry = NULL;
3032 uint8_t session_id;
3033 tpSirAssocReq assoc_req;
3034
3035 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003036 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003037 goto end;
3038 }
3039
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303040 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003041 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003042 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003043 goto end;
3044 }
3045
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003046 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003047 &session_id);
3048 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003049 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003050 goto end;
3051 }
3052
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003053 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003054 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3055 (session_entry->limSmeState !=
3056 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003057 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058 msg_type, session_entry->limSmeState,
3059 GET_LIM_SYSTEM_ROLE(session_entry));
3060 goto end;
3061 }
3062 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3063 &session_entry->dph.dphHashTable);
3064 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003065 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003066 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303067 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003068
3069 /*
3070 * send a DISASSOC_IND message to WSM to make sure
3071 * the state in WSM and LIM is the same
3072 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003073 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003074 eSIR_SME_STA_NOT_ASSOCIATED,
3075 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3076 session_entry->smeSessionId,
3077 session_entry->transactionId,
3078 session_entry);
3079 goto end;
3080 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303081 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003082 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303083 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003084 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003085 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303086 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003087 goto end;
3088 }
3089
3090 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3091 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3092 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3093 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3094 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003095 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3096 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003097 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303098 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003099 goto end;
3100 }
3101 /*
3102 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3103 * has been received
3104 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003105 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003106 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3107 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3108
3109 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3110 /*
3111 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3112 * when it had received Assoc Request frame. Now, PE just needs
3113 * to send association rsp frame to the requesting BTAMP-STA.
3114 */
3115 sta_ds->mlmStaContext.mlmState =
3116 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003117 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003118 sta_ds->assocId);
3119 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3120 sta_ds->assocId, sta_ds->staAddr,
3121 sta_ds->mlmStaContext.subType, sta_ds,
3122 session_entry);
3123 goto end;
3124 } else {
3125 /*
3126 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3127 * to be associated since the HAL sta entry is created for
3128 * denied STA we need to remove this HAL entry.
3129 * So to do that set updateContext to 1
3130 */
3131 if (!sta_ds->mlmStaContext.updateContext)
3132 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003133 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003134 assoc_cnf.statusCode, sta_ds->assocId);
3135 lim_reject_association(mac_ctx, sta_ds->staAddr,
3136 sta_ds->mlmStaContext.subType,
3137 true, sta_ds->mlmStaContext.authType,
3138 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003139 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003140 session_entry);
3141 }
3142end:
3143 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3144 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3145 assoc_req = (tpSirAssocReq)
3146 session_entry->parsedAssocReq[sta_ds->assocId];
3147 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303148 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003149 assoc_req->assocReqFrame = NULL;
3150 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303151 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003152 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3153 }
3154}
3155
3156static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3157{
3158 tpDphHashNode pStaDs;
3159 tSirMacAddr peerMac;
3160 tpSirAddtsReq pSirAddts;
3161 uint32_t timeout;
3162 tpPESession psessionEntry;
3163 uint8_t sessionId; /* PE sessionId */
3164 uint8_t smesessionId;
3165 uint16_t smetransactionId;
3166
3167 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003168 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003169 return;
3170 }
3171
3172 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3173 &smetransactionId);
3174
3175 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3176
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003177 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3178 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003179 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003180 pe_err("Session Does not exist for given bssId");
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303181 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3182 NULL, pSirAddts->req.tspec,
3183 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003184 return;
3185 }
3186#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3187 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3188 0);
3189#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3190
3191 /* if sta
3192 * - verify assoc state
3193 * - send addts request to ap
3194 * - wait for addts response from ap
3195 * if ap, just ignore with error log
3196 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003197 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3198 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3199 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003200
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003201 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003202 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303203 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003204 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003205
3206 pStaDs =
3207 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3208 &psessionEntry->dph.dphHashTable);
3209
3210 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003211 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303212 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003213 }
3214
3215 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3216 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003217 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303218 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003219 }
3220
3221 pSirAddts->req.wsmTspecPresent = 0;
3222 pSirAddts->req.wmeTspecPresent = 0;
3223 pSirAddts->req.lleTspecPresent = 0;
3224
3225 if ((pStaDs->wsmEnabled) &&
3226 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3227 SIR_MAC_ACCESSPOLICY_EDCA))
3228 pSirAddts->req.wsmTspecPresent = 1;
3229 else if (pStaDs->wmeEnabled)
3230 pSirAddts->req.wmeTspecPresent = 1;
3231 else if (pStaDs->lleEnabled)
3232 pSirAddts->req.lleTspecPresent = 1;
3233 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003234 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303235 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003236 }
3237
3238 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3239 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003240 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003241 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303242 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243 }
3244
3245 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003246 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003247 pMac->lim.gLimAddtsReq.req.dialogToken,
3248 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3249 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3250 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303251 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003252 }
3253
3254 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3255
3256 /* save the addts request */
3257 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303258 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003259 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3260
3261 /* ship out the message now */
3262 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3263 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303264 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003265 /* start a timer to wait for the response */
3266 if (pSirAddts->timeout)
3267 timeout = pSirAddts->timeout;
3268 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3269 eSIR_SUCCESS) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303270 pe_debug("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003271 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303272 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003273 }
3274
3275 timeout = SYS_MS_TO_TICKS(timeout);
3276 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3277 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003278 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303279 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003280 }
3281 pMac->lim.gLimAddtsRspTimerCount++;
3282 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3283 pMac->lim.gLimAddtsRspTimerCount) !=
3284 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003285 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303286 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003287 }
3288 MTRACE(mac_trace
3289 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3290 eLIM_ADDTS_RSP_TIMER));
3291
3292 /* add the sessionId to the timer object */
3293 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3294 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3295 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003296 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303297 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003298 }
3299 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303300
3301send_failure_addts_rsp:
3302 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3303 psessionEntry, pSirAddts->req.tspec,
3304 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003305}
3306
3307static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3308{
3309 tSirMacAddr peerMacAddr;
3310 uint8_t ac;
3311 tSirMacTSInfo *pTsinfo;
3312 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3313 tpDphHashNode pStaDs = NULL;
3314 tpPESession psessionEntry;
3315 uint8_t sessionId;
3316 uint32_t status = eSIR_SUCCESS;
3317 uint8_t smesessionId;
3318 uint16_t smetransactionId;
3319
3320 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3321 &smetransactionId);
3322
3323 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003324 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003325 &sessionId);
3326 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003327 pe_err("Session Does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003328 status = eSIR_FAILURE;
3329 goto end;
3330 }
3331#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3332 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3333 0);
3334#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3335
3336 if (eSIR_SUCCESS !=
3337 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003338 pe_err("lim_validate_delts_req failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003339 status = eSIR_FAILURE;
3340 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3341 smesessionId, smetransactionId);
3342 return;
3343 }
3344
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003345 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3346 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003347 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3348
3349 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3350 pDeltsReq->req.wmeTspecPresent,
3351 &pDeltsReq->req.tsinfo,
3352 &pDeltsReq->req.tspec, psessionEntry);
3353
3354 pTsinfo =
3355 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3356 tsinfo : &pDeltsReq->req.tsinfo;
3357
3358 /* We've successfully send DELTS frame to AP. Update the
3359 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3360 * is no longer trigger enabled or delivery enabled
3361 */
3362 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3363 pTsinfo, CLEAR_UAPSD_MASK);
3364
3365 /* We're deleting the TSPEC, so this particular AC is no longer
3366 * admitted. PE needs to downgrade the EDCA
3367 * parameters(for the AC for which TS is being deleted) to the
3368 * next best AC for which ACM is not enabled, and send the
3369 * updated values to HAL.
3370 */
3371 ac = upToAc(pTsinfo->traffic.userPrio);
3372
3373 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3374 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3375 ~(1 << ac);
3376 } else if (pTsinfo->traffic.direction ==
3377 SIR_MAC_DIRECTION_DNLINK) {
3378 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3379 ~(1 << ac);
3380 } else if (pTsinfo->traffic.direction ==
3381 SIR_MAC_DIRECTION_BIDIR) {
3382 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3383 ~(1 << ac);
3384 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3385 ~(1 << ac);
3386 }
3387
3388 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3389 psessionEntry);
3390
3391 pStaDs =
3392 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3393 &psessionEntry->dph.dphHashTable);
3394 if (pStaDs != NULL) {
3395 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3396 pStaDs->bssId);
3397 status = eSIR_SUCCESS;
3398 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003399 pe_err("Self entry missing in Hash Table");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003400 status = eSIR_FAILURE;
3401 }
3402#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003403 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003404#endif
3405
3406 /* send an sme response back */
3407end:
3408 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3409 smesessionId, smetransactionId);
3410}
3411
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303412void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003413{
3414 /* fetch the sessionEntry based on the sessionId */
3415 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003416
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003417 psessionEntry = pe_find_session_by_session_id(pMac,
3418 pMac->lim.limTimers.gLimAddtsRspTimer.
3419 sessionId);
3420 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003421 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003422 return;
3423 }
3424
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003425 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003426 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003427 GET_LIM_SYSTEM_ROLE(psessionEntry));
3428 pMac->lim.gLimAddtsSent = false;
3429 return;
3430 }
3431
3432 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003433 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434 return;
3435 }
3436
3437 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003438 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003439 pMac->lim.gLimAddtsRspTimerCount);
3440 return;
3441 }
3442 /* this a real response timeout */
3443 pMac->lim.gLimAddtsSent = false;
3444 pMac->lim.gLimAddtsRspTimerCount++;
3445
3446 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3447 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3448 psessionEntry->smeSessionId,
3449 psessionEntry->transactionId);
3450}
3451
3452/**
3453 * __lim_process_sme_get_statistics_request()
3454 *
3455 ***FUNCTION:
3456 *
3457 *
3458 ***NOTE:
3459 *
3460 * @param pMac Pointer to Global MAC structure
3461 * @param *pMsgBuf A pointer to the SME message buffer
3462 * @return None
3463 */
3464static void
3465__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3466{
3467 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003468 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003469
3470 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3471
3472 msgQ.type = WMA_GET_STATISTICS_REQ;
3473
3474 msgQ.reserved = 0;
3475 msgQ.bodyptr = pMsgBuf;
3476 msgQ.bodyval = 0;
3477 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3478
3479 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303480 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003481 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003482 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003483 return;
3484 }
3485
3486 return;
3487}
3488
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003489#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003490/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003491 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003492 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003493 * @pMac: Pointer to Global MAC structure
3494 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003495 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003496 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003497 */
3498static void
3499__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3500{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003501 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003502
3503 msgQ.type = WMA_TSM_STATS_REQ;
3504 msgQ.reserved = 0;
3505 msgQ.bodyptr = pMsgBuf;
3506 msgQ.bodyval = 0;
3507 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3508
3509 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303510 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003511 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003512 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003513 return;
3514 }
3515}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003516#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003517
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08003518static void lim_process_sme_set_addba_accept(tpAniSirGlobal mac_ctx,
3519 struct sme_addba_accept *msg)
3520{
3521 if (!msg) {
3522 pe_err("Msg Buffer is NULL");
3523 return;
3524 }
3525 if (!msg->addba_accept)
3526 mac_ctx->reject_addba_req = 1;
3527 else
3528 mac_ctx->reject_addba_req = 0;
3529}
3530
Naveen Rawat8029a402017-06-01 10:54:19 -07003531static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3532 struct update_config *msg)
3533{
3534 tpPESession pe_session;
3535
3536 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3537 if (msg == NULL) {
3538 pe_err("Buffer is Pointing to NULL");
3539 return;
3540 }
3541
3542 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3543 msg->sme_session_id);
3544 if (pe_session == NULL) {
3545 pe_warn("Session does not exist for given BSSID");
3546 return;
3547 }
3548
3549 switch (msg->capab) {
3550 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3551 pe_session->htConfig.ht_rx_ldpc = msg->value;
3552 break;
3553 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3554 pe_session->htConfig.ht_tx_stbc = msg->value;
3555 break;
3556 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3557 pe_session->htConfig.ht_rx_stbc = msg->value;
3558 break;
3559 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3560 pe_session->htConfig.ht_sgi20 = msg->value;
3561 break;
3562 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3563 pe_session->htConfig.ht_sgi40 = msg->value;
3564 break;
3565 }
3566
3567 if (LIM_IS_AP_ROLE(pe_session)) {
3568 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3569 lim_send_beacon_ind(mac_ctx, pe_session);
3570 }
3571}
3572
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003573void
3574lim_send_vdev_restart(tpAniSirGlobal pMac,
3575 tpPESession psessionEntry, uint8_t sessionId)
3576{
3577 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003578 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003579 tSirRetStatus retCode = eSIR_SUCCESS;
3580
3581 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003582 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003583 return;
3584 }
3585
3586 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303587 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003588 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003589 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003590 return;
3591 }
3592
3593 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3594 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003595 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003596
3597 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3598 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3599 msgQ.bodyval = 0;
3600
3601 retCode = wma_post_ctrl_msg(pMac, &msgQ);
3602 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003603 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303604 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003605 }
3606}
3607
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303608/**
3609 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3610 * @mac_ctx: Pointer to Global MAC structure
3611 * @msg_buf: Pointer to SME message buffer
3612 *
3613 * Return: None
3614 */
3615static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3616 uint32_t *msg_buf)
3617{
3618 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003619 struct scheduler_msg wma_msg = {0};
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303620 tSirRetStatus status;
3621 tSirRoamOffloadScanReq *req_buffer;
3622 uint16_t local_ie_len;
3623 uint8_t *local_ie_buf;
3624
3625 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3626 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3627 req_buffer->sessionId);
3628
3629 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3630 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003631 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303632 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303633 return;
3634 }
3635
3636 local_ie_len = req_buffer->assoc_ie.length;
3637 /* Update ext cap IE if present */
3638 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003639 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3640 local_ie_buf, &local_ie_len)) {
3641 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003642 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3643 req_buffer->assoc_ie.length = local_ie_len;
3644 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3645 local_ie_buf, local_ie_len);
3646 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303647 }
3648 qdf_mem_free(local_ie_buf);
3649
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303650 if (pe_session)
3651 lim_update_fils_rik(pe_session, req_buffer);
3652
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303653 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3654 wma_msg.bodyptr = req_buffer;
3655
3656 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
3657 if (eSIR_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003658 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303659 qdf_mem_free(req_buffer);
3660 }
3661}
3662
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303663/*
3664 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3665 * @mac_ctx: Pointer to global mac context
3666 * @session: Pointer to PE session
3667 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3668 * 1 - Disable broadcast SSID
3669 *
3670 * Return: None
3671 */
3672static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3673 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003674{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003675 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003676 session->ssidHidden, ssid_hidden);
3677
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003678 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303679 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003680 } else {
3681 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05303682 return;
3683 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003684
3685 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303686 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003687
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003688 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303689}
3690
3691/**
3692 * __lim_process_sme_session_update - process SME session update msg
3693 *
3694 * @mac_ctx: Pointer to global mac context
3695 * @msg_buf: Pointer to the received message buffer
3696 *
3697 * Return: None
3698 */
3699static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
3700 uint32_t *msg_buf)
3701{
3702 struct sir_update_session_param *msg;
3703 tpPESession session;
3704
3705 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003706 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303707 return;
3708 }
3709
3710 msg = (struct sir_update_session_param *) msg_buf;
3711
3712 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
3713 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003714 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303715 msg->session_id);
3716 return;
3717 }
3718
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003719 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303720 msg->param_type, msg->param_val);
3721 switch (msg->param_type) {
3722 case SIR_PARAM_SSID_HIDDEN:
3723 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
3724 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303725 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
3726 session->ignore_assoc_disallowed = msg->param_val;
3727 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303728 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003729 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303730 break;
3731 }
3732}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003733
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003734/*
3735 Update the beacon Interval dynamically if beaconInterval is different in MCC
3736 */
3737static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3738{
3739 tpSirChangeBIParams pChangeBIParams;
3740 tpPESession psessionEntry;
3741 uint8_t sessionId = 0;
3742 tUpdateBeaconParams beaconParams;
3743
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003744 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003745
3746 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003747 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003748 return;
3749 }
3750
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303751 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003752 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
3753
3754 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08003755 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003756 &sessionId);
3757 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003758 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003759 return;
3760 }
3761
3762 /*Update sessionEntry Beacon Interval */
3763 if (psessionEntry->beaconParams.beaconInterval !=
3764 pChangeBIParams->beaconInterval) {
3765 psessionEntry->beaconParams.beaconInterval =
3766 pChangeBIParams->beaconInterval;
3767 }
3768
3769 /*Update sch beaconInterval */
3770 if (pMac->sch.schObject.gSchBeaconInterval !=
3771 pChangeBIParams->beaconInterval) {
3772 pMac->sch.schObject.gSchBeaconInterval =
3773 pChangeBIParams->beaconInterval;
3774
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003775 pe_debug("LIM send update BeaconInterval Indication: %d",
3776 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003777
3778 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
3779 /* Update beacon */
3780 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3781
3782 beaconParams.bssIdx = psessionEntry->bssIdx;
3783 /* Set change in beacon Interval */
3784 beaconParams.beaconInterval =
3785 pChangeBIParams->beaconInterval;
3786 beaconParams.paramChangeBitmap =
3787 PARAM_BCN_INTERVAL_CHANGED;
3788 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
3789 }
3790 }
3791
3792 return;
3793} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
3794
3795#ifdef QCA_HT_2040_COEX
3796static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
3797 uint32_t *pMsgBuf)
3798{
3799 tpSirSetHT2040Mode pSetHT2040Mode;
3800 tpPESession psessionEntry;
3801 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003802 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003803 tUpdateVHTOpMode *pHtOpMode = NULL;
3804 uint16_t staId = 0;
3805 tpDphHashNode pStaDs = NULL;
3806
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003807 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003808 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003809 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003810 return;
3811 }
3812
3813 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
3814
3815 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08003816 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003817 &sessionId);
3818 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003819 pe_debug("Session does not exist for given BSSID");
3820 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003821 return;
3822 }
3823
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003824 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003825 pSetHT2040Mode->cbMode);
3826 /*Update sessionEntry HT related fields */
3827 switch (pSetHT2040Mode->cbMode) {
3828 case PHY_SINGLE_CHANNEL_CENTERED:
3829 psessionEntry->htSecondaryChannelOffset =
3830 PHY_SINGLE_CHANNEL_CENTERED;
3831 psessionEntry->htRecommendedTxWidthSet = 0;
3832 if (pSetHT2040Mode->obssEnabled)
3833 psessionEntry->htSupportedChannelWidthSet
3834 = eHT_CHANNEL_WIDTH_40MHZ;
3835 else
3836 psessionEntry->htSupportedChannelWidthSet
3837 = eHT_CHANNEL_WIDTH_20MHZ;
3838 break;
3839 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
3840 psessionEntry->htSecondaryChannelOffset =
3841 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3842 psessionEntry->htRecommendedTxWidthSet = 1;
3843 break;
3844 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
3845 psessionEntry->htSecondaryChannelOffset =
3846 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3847 psessionEntry->htRecommendedTxWidthSet = 1;
3848 break;
3849 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003850 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003851 return;
3852 }
3853
3854 /* Update beacon */
3855 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3856 lim_send_beacon_ind(pMac, psessionEntry);
3857
3858 /* update OP Mode for each associated peer */
3859 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
3860 pStaDs = dph_get_hash_entry(pMac, staId,
3861 &psessionEntry->dph.dphHashTable);
3862 if (NULL == pStaDs)
3863 continue;
3864
3865 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303866 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003867 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003868 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003869 return;
3870 }
3871 pHtOpMode->opMode =
3872 (psessionEntry->htSecondaryChannelOffset ==
3873 PHY_SINGLE_CHANNEL_CENTERED) ?
3874 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
3875 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303876 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003877 sizeof(tSirMacAddr));
3878 pHtOpMode->smesessionId = sessionId;
3879
3880 msg.type = WMA_UPDATE_OP_MODE;
3881 msg.reserved = 0;
3882 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003883 if (!QDF_IS_STATUS_SUCCESS
3884 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
3885 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303886 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003887 return;
3888 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003889 pe_debug("Notifed FW about OP mode: %d for staId=%d",
3890 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003891
3892 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003893 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003894 }
3895
3896 return;
3897}
3898#endif
3899
3900/* -------------------------------------------------------------------- */
3901/**
3902 * __lim_process_report_message
3903 *
3904 * FUNCTION: Processes the next received Radio Resource Management message
3905 *
3906 * LOGIC:
3907 *
3908 * ASSUMPTIONS:
3909 *
3910 * NOTE:
3911 *
3912 * @param None
3913 * @return None
3914 */
3915
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003916static void __lim_process_report_message(tpAniSirGlobal pMac,
3917 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003918{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003919 switch (pMsg->type) {
3920 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
3921 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
3922 break;
3923 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003924 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08003925 break;
3926 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003927 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003928 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003929}
3930
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003931/* -------------------------------------------------------------------- */
3932/**
3933 * lim_send_set_max_tx_power_req
3934 *
3935 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
3936 *
3937 * LOGIC:
3938 *
3939 * ASSUMPTIONS:
3940 *
3941 * NOTE:
3942 *
3943 * @param txPower txPower to be set.
3944 * @param pSessionEntry session entry.
3945 * @return None
3946 */
3947tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07003948lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003949 tpPESession pSessionEntry)
3950{
3951 tpMaxTxPowerParams pMaxTxParams = NULL;
3952 tSirRetStatus retCode = eSIR_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003953 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003954
3955 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003956 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003957 return eSIR_FAILURE;
3958 }
3959
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303960 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003961 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003962 pe_err("Unable to allocate memory for pMaxTxParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003963 return eSIR_MEM_ALLOC_FAILED;
3964
3965 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003966 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303967 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303968 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303969 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07003970 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303971 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003972
3973 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
3974 msgQ.bodyptr = pMaxTxParams;
3975 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003976 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003977 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
3978 retCode = wma_post_ctrl_msg(pMac, &msgQ);
3979 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003980 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303981 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003982 }
3983 return retCode;
3984}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003985
3986/**
3987 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
3988 *
3989 * @mac_ctx: Pointer to Global MAC structure
3990 * @msg_buf: pointer to the SME message buffer
3991 *
3992 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
3993 * from SME. It Register this information within PE.
3994 *
3995 * Return: None
3996 */
3997static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
3998 uint32_t *msg_buf)
3999{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304000 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004001 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4002 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4003 struct mgmt_frm_reg_info *next = NULL;
4004 bool match = false;
4005
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004006 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004007 sme_req->registerFrame, sme_req->frameType,
4008 sme_req->matchLen);
4009 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304010 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304011 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4012 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304013 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004014
4015 while (lim_mgmt_regn != NULL) {
4016 if (lim_mgmt_regn->frameType != sme_req->frameType)
4017 goto skip_match;
4018 if (sme_req->matchLen) {
4019 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304020 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004021 sme_req->matchData,
4022 lim_mgmt_regn->matchLen))) {
4023 /* found match! */
4024 match = true;
4025 break;
4026 }
4027 } else {
4028 /* found match! */
4029 match = true;
4030 break;
4031 }
4032skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304033 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304034 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004035 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304036 (qdf_list_node_t *)lim_mgmt_regn,
4037 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304038 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004039 lim_mgmt_regn = next;
4040 next = NULL;
4041 }
4042 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304043 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004044 if (QDF_STATUS_SUCCESS ==
4045 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004046 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004047 (qdf_list_node_t *)lim_mgmt_regn))
4048 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304049 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004050 }
4051
4052 if (sme_req->registerFrame) {
4053 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304054 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004055 sme_req->matchLen);
4056 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004057 lim_mgmt_regn->frameType = sme_req->frameType;
4058 lim_mgmt_regn->matchLen = sme_req->matchLen;
4059 lim_mgmt_regn->sessionId = sme_req->sessionId;
4060 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304061 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004062 sme_req->matchData,
4063 sme_req->matchLen);
4064 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304065 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004066 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304067 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004068 gLimMgmtFrameRegistratinQueue,
4069 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304070 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004071 &mac_ctx->lim.lim_frame_register_lock);
4072 }
4073 }
4074 return;
4075}
4076
4077static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4078{
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004079 pe_debug("Dereg msgType %d", pMac->lim.gDeferMsgTypeForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004080 pMac->lim.gDeferMsgTypeForNOA = 0;
4081 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4082 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304083 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004084 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4085 }
4086}
4087
4088/**
4089 * lim_process_regd_defd_sme_req_after_noa_start()
4090 *
4091 * mac_ctx: Pointer to Global MAC structure
4092 *
4093 * This function is called to process deferred sme req message
4094 * after noa start.
4095 *
4096 * Return: None
4097 */
4098void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4099{
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004100 pe_debug("Process defd sme req %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004101 mac_ctx->lim.gDeferMsgTypeForNOA);
4102
4103 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4104 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004105 pe_warn("start rcvd from FW when no sme deferred msg pending. Do nothing");
4106 pe_warn("It may happen when NOA start ind and timeout happen at the same time");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004107 return;
4108 }
4109 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004110 case eWNI_SME_JOIN_REQ:
4111 __lim_process_sme_join_req(mac_ctx,
4112 mac_ctx->lim.gpDefdSmeMsgForNOA);
4113 break;
4114 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004115 pe_err("Unknown deferred msg type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004116 mac_ctx->lim.gDeferMsgTypeForNOA);
4117 break;
4118 }
4119 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4120}
4121
4122static void
4123__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4124{
4125 tpSirResetAPCapsChange pResetCapsChange;
4126 tpPESession psessionEntry;
4127 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004128
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004129 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004130 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004131 return;
4132 }
4133
4134 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4135 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004136 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4137 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004138 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004139 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004140 return;
4141 }
4142
4143 psessionEntry->limSentCapsChangeNtf = false;
4144 return;
4145}
4146
4147/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304148 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4149 * indication callback in PE.
4150 * @mac_ptr: Mac pointer
4151 * @msg_buf: Msg pointer containing the callback
4152 *
4153 * This function is used save the Management frame
4154 * indication callback in PE.
4155 *
4156 * Return: None
4157 */
4158static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4159 uint32_t *msg_buf)
4160{
4161 struct sir_sme_mgmt_frame_cb_req *sme_req =
4162 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4163
4164 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004165 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304166 return;
4167 }
4168 if (sme_req->callback)
4169 mac_ctx->mgmt_frame_ind_cb =
4170 (sir_mgmt_frame_ind_callback)sme_req->callback;
4171 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004172 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304173}
4174
4175/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304176 *__lim_process_send_disassoc_frame: function processes disassoc frame
4177 * @mac_ctx: pointer to mac context
4178 * @msg_buf: message buffer
4179 *
4180 * function processes disassoc request received from SME
4181 *
4182 * return: none
4183 */
4184static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4185 uint32_t *msg_buf)
4186{
4187 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4188 tSirRetStatus status;
4189 tpPESession session_entry = NULL;
4190 uint8_t sme_session_id;
4191 uint16_t sme_trans_id;
4192
4193 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004194 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304195 return;
4196 }
4197
4198 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4199 &sme_trans_id);
4200
4201 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4202 &sme_send_disassoc_frame_req,
4203 (uint8_t *)msg_buf);
4204
4205 if ((eSIR_FAILURE == status) ||
4206 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4207 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004208 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304209 return;
4210 }
4211
4212 session_entry = pe_find_session_by_sme_session_id(
4213 mac_ctx, sme_session_id);
4214 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004215 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304216 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4217 return;
4218 }
4219
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004220 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 +05304221 sme_send_disassoc_frame_req.msg_type,
4222 sme_send_disassoc_frame_req.length,
4223 sme_send_disassoc_frame_req.session_id,
4224 sme_send_disassoc_frame_req.trans_id,
4225 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4226 sme_send_disassoc_frame_req.reason,
4227 sme_send_disassoc_frame_req.wait_for_ack);
4228
4229 lim_send_disassoc_mgmt_frame(mac_ctx,
4230 sme_send_disassoc_frame_req.reason,
4231 sme_send_disassoc_frame_req.peer_mac,
4232 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4233}
4234
4235/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004236 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4237 * @mac_ctx: Pointer to Global MAC structure
4238 * @pdev_id: pdev id to set the IE.
4239 * @nss: Nss values to prepare the HT IE.
4240 *
4241 * Prepares the HT IE with self capabilities for different
4242 * Nss values and sends the set HT IE req to FW.
4243 *
4244 * Return: None
4245 */
4246static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4247 uint8_t nss)
4248{
4249 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004250 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004251 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004252 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004253 tHtCaps *p_ht_cap;
4254 int i;
4255
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004256 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004257 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4258 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004259 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004260 return;
4261 }
4262 ie_params->nss = i;
4263 ie_params->pdev_id = pdev_id;
4264 ie_params->ie_type = DOT11_HT_IE;
4265 /* 2 for IE len and EID */
4266 ie_params->ie_len = 2 + sizeof(tHtCaps);
4267 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4268 if (NULL == ie_params->ie_ptr) {
4269 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004270 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004271 return;
4272 }
4273 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4274 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4275 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4276 ie_params->ie_len);
4277
4278 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004279 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4280 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004281 if (NULL == p_ie) {
4282 qdf_mem_free(ie_params->ie_ptr);
4283 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004284 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004285 return;
4286 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004287 p_ht_cap = (tHtCaps *)&p_ie[2];
4288 p_ht_cap->supportedMCSSet[1] = 0;
4289 p_ht_cap->txSTBC = 0;
4290 }
4291
4292 msg.type = WMA_SET_PDEV_IE_REQ;
4293 msg.bodyptr = ie_params;
4294 msg.bodyval = 0;
4295
4296 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4297 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004298 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004299 qdf_mem_free(ie_params->ie_ptr);
4300 qdf_mem_free(ie_params);
4301 return;
4302 }
4303 }
4304}
4305
4306/**
4307 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4308 * @mac_ctx: Pointer to Global MAC structure
4309 * @pdev_id: pdev id to set the IE.
4310 * @nss: Nss values to prepare the VHT IE.
4311 *
4312 * Prepares the VHT IE with self capabilities for different
4313 * Nss values and sends the set VHT IE req to FW.
4314 *
4315 * Return: None
4316 */
4317static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4318 uint8_t nss)
4319{
4320 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004321 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004322 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004323 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004324 tSirMacVHTCapabilityInfo *vht_cap;
4325 int i;
4326 tSirVhtMcsInfo *vht_mcs;
4327
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004328 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004329 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4330 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004331 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004332 return;
4333 }
4334 ie_params->nss = i;
4335 ie_params->pdev_id = pdev_id;
4336 ie_params->ie_type = DOT11_VHT_IE;
4337 /* 2 for IE len and EID */
4338 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4339 sizeof(tSirVhtMcsInfo);
4340 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4341 if (NULL == ie_params->ie_ptr) {
4342 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004343 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004344 return;
4345 }
4346 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4347 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4348 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4349 ie_params->ie_len);
4350
4351 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004352 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4353 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004354 if (NULL == p_ie) {
4355 qdf_mem_free(ie_params->ie_ptr);
4356 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004357 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004358 return;
4359 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004360 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4361 vht_cap->txSTBC = 0;
4362 vht_mcs =
4363 (tSirVhtMcsInfo *)&p_ie[2 +
4364 sizeof(tSirMacVHTCapabilityInfo)];
4365 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4366 vht_mcs->rxHighest =
4367 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4368 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4369 vht_mcs->txHighest =
4370 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4371 }
4372 msg.type = WMA_SET_PDEV_IE_REQ;
4373 msg.bodyptr = ie_params;
4374 msg.bodyval = 0;
4375
4376 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4377 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004378 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004379 qdf_mem_free(ie_params->ie_ptr);
4380 qdf_mem_free(ie_params);
4381 return;
4382 }
4383 }
4384}
4385
4386/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004387 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4388 * @mac_ctx: Pointer to Global MAC structure
4389 * @msg_buf: Pointer to the SME message buffer
4390 *
4391 * This function is called by limProcessMessageQueue(). This function sets the
4392 * VDEV IEs to the FW.
4393 *
4394 * Return: None
4395 */
4396static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4397 uint32_t *msg_buf)
4398{
4399 struct sir_set_vdev_ies_per_band *p_msg =
4400 (struct sir_set_vdev_ies_per_band *)msg_buf;
4401
4402 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004403 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004404 return;
4405 }
4406
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004407 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004408 p_msg->vdev_id);
4409 /* intentionally using NULL here so that self capabilty are sent */
4410 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4411 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004412 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004413}
4414
4415/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004416 * lim_process_set_pdev_IEs() - process the set pdev IE req
4417 * @mac_ctx: Pointer to Global MAC structure
4418 * @msg_buf: Pointer to the SME message buffer
4419 *
4420 * This function is called by limProcessMessageQueue(). This
4421 * function sets the PDEV IEs to the FW.
4422 *
4423 * Return: None
4424 */
4425static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4426{
4427 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4428
4429 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4430
4431 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004432 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004433 return;
4434 }
4435
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004436 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004437 ht_vht_cfg->nss);
4438 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4439
4440 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4441 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4442 ht_vht_cfg->nss);
4443}
4444
4445/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304446 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4447 *
4448 * access policy
4449 * @mac_ctx: pointer to mac context
4450 * @msg: message buffer
4451 *
4452 * function processes vendor IE and access policy from SME and updates PE
4453 *
4454 * session entry
4455 *
4456 * return: none
4457*/
4458static void lim_process_sme_update_access_policy_vendor_ie(
4459 tpAniSirGlobal mac_ctx,
4460 uint32_t *msg)
4461{
4462 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4463 struct sPESession *pe_session_entry;
4464 uint8_t num_bytes;
4465
4466 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004467 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304468 return;
4469 }
4470 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4471 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4472 update_vendor_ie->sme_session_id);
4473
4474 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004475 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304476 update_vendor_ie->sme_session_id);
4477 return;
4478 }
4479 if (pe_session_entry->access_policy_vendor_ie)
4480 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4481
4482 num_bytes = update_vendor_ie->ie[1] + 2;
4483 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4484
4485 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004486 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304487 return;
4488 }
4489 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4490 &update_vendor_ie->ie[0], num_bytes);
4491
4492 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4493}
4494
4495/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004496 * lim_process_sme_req_messages()
4497 *
4498 ***FUNCTION:
4499 * This function is called by limProcessMessageQueue(). This
4500 * function processes SME request messages from HDD or upper layer
4501 * application.
4502 *
4503 ***LOGIC:
4504 *
4505 ***ASSUMPTIONS:
4506 *
4507 ***NOTE:
4508 *
4509 * @param pMac Pointer to Global MAC structure
4510 * @param msgType Indicates the SME message type
4511 * @param *pMsgBuf A pointer to the SME message buffer
4512 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4513 * false - if pMsgBuf is not to be freed.
4514 */
4515
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004516bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4517 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004518{
4519 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
4520 uint32_t *pMsgBuf = pMsg->bodyptr;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004521
4522 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004523 lim_msg_str(pMsg->type), pMsg->type,
4524 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4525 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004526
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004527 /* If no insert NOA required then execute the code below */
4528
4529 switch (pMsg->type) {
4530 case eWNI_SME_SYS_READY_IND:
4531 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4532 break;
4533
4534 case eWNI_SME_START_BSS_REQ:
4535 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4536 break;
4537
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004538 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4539 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4540 break;
4541 case eWNI_SME_JOIN_REQ:
4542 __lim_process_sme_join_req(pMac, pMsgBuf);
4543 break;
4544
4545 case eWNI_SME_REASSOC_REQ:
4546 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4547 break;
4548
4549 case eWNI_SME_DISASSOC_REQ:
4550 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4551 break;
4552
4553 case eWNI_SME_DISASSOC_CNF:
4554 case eWNI_SME_DEAUTH_CNF:
4555 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4556 break;
4557
4558 case eWNI_SME_DEAUTH_REQ:
4559 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4560 break;
4561
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304562 case eWNI_SME_SEND_DISASSOC_FRAME:
4563 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4564 break;
4565
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004566 case eWNI_SME_SETCONTEXT_REQ:
4567 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4568 break;
4569
4570 case eWNI_SME_STOP_BSS_REQ:
4571 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4572 break;
4573
4574 case eWNI_SME_ASSOC_CNF:
4575 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004576 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004577 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4578 pMsgBuf);
4579 break;
4580
4581 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004582 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004583 __lim_process_sme_addts_req(pMac, pMsgBuf);
4584 break;
4585
4586 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004587 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004588 __lim_process_sme_delts_req(pMac, pMsgBuf);
4589 break;
4590
4591 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004592 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004593 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4594 break;
4595
4596 case eWNI_SME_GET_STATISTICS_REQ:
4597 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4598 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4599 bufConsumed = false;
4600 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004601#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004602 case eWNI_SME_GET_TSM_STATS_REQ:
4603 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4604 bufConsumed = false;
4605 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004606#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004607 case eWNI_SME_GET_ASSOC_STAS_REQ:
4608 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4609 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304610 case eWNI_SME_SESSION_UPDATE_PARAM:
4611 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004612 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304613 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4614 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4615 bufConsumed = false;
4616 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004617 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4618 /* Update the beaconInterval */
4619 __lim_process_sme_change_bi(pMac, pMsgBuf);
4620 break;
4621
4622#ifdef QCA_HT_2040_COEX
4623 case eWNI_SME_SET_HT_2040_MODE:
4624 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4625 break;
4626#endif
4627
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004628 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4629 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4630 __lim_process_report_message(pMac, pMsg);
4631 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004632
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004633 case eWNI_SME_FT_PRE_AUTH_REQ:
4634 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4635 break;
4636 case eWNI_SME_FT_UPDATE_KEY:
4637 lim_process_ft_update_key(pMac, pMsgBuf);
4638 break;
4639
4640 case eWNI_SME_FT_AGGR_QOS_REQ:
4641 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4642 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004643
4644 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4645 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4646 break;
4647#ifdef FEATURE_WLAN_TDLS
4648 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4649 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4650 break;
4651 case eWNI_SME_TDLS_ADD_STA_REQ:
4652 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4653 break;
4654 case eWNI_SME_TDLS_DEL_STA_REQ:
4655 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4656 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004657#endif
4658 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4659 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4660 break;
4661
4662 case eWNI_SME_CHANNEL_CHANGE_REQ:
4663 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4664 break;
4665
4666 case eWNI_SME_START_BEACON_REQ:
4667 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4668 break;
4669
4670 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4671 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4672 break;
4673
4674 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4675 lim_process_update_add_ies(pMac, pMsgBuf);
4676 break;
4677
4678 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4679 lim_process_modify_add_ies(pMac, pMsgBuf);
4680 break;
4681 case eWNI_SME_SET_HW_MODE_REQ:
4682 lim_process_set_hw_mode(pMac, pMsgBuf);
4683 break;
4684 case eWNI_SME_NSS_UPDATE_REQ:
4685 lim_process_nss_update_request(pMac, pMsgBuf);
4686 break;
4687 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4688 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4689 break;
4690 case eWNI_SME_SET_IE_REQ:
4691 lim_process_set_ie_req(pMac, pMsgBuf);
4692 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304693 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4694 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
4695 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304696 case eWNI_SME_EXT_CHANGE_CHANNEL:
4697 lim_process_ext_change_channel(pMac, pMsgBuf);
4698 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08004699 case eWNI_SME_SET_ANTENNA_MODE_REQ:
4700 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
4701 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004702 case eWNI_SME_PDEV_SET_HT_VHT_IE:
4703 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07004704 break;
4705 case eWNI_SME_SET_VDEV_IES_PER_BAND:
4706 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
4707 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304708 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
4709 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
4710 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07004711 case eWNI_SME_UPDATE_CONFIG:
4712 lim_process_sme_update_config(pMac,
4713 (struct update_config *)pMsgBuf);
4714 break;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004715 case eWNI_SME_SET_ADDBA_ACCEPT:
4716 lim_process_sme_set_addba_accept(pMac,
4717 (struct sme_addba_accept *)pMsgBuf);
4718 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004719 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304720 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004721 pMsg->bodyptr = NULL;
4722 break;
4723 } /* switch (msgType) */
4724
4725 return bufConsumed;
4726} /*** end lim_process_sme_req_messages() ***/
4727
4728/**
4729 * lim_process_sme_start_beacon_req()
4730 *
4731 ***FUNCTION:
4732 * This function is called by limProcessMessageQueue(). This
4733 * function processes SME request messages from HDD or upper layer
4734 * application.
4735 *
4736 ***LOGIC:
4737 *
4738 ***ASSUMPTIONS:
4739 *
4740 ***NOTE:
4741 *
4742 * @param pMac Pointer to Global MAC structure
4743 * @param msgType Indicates the SME message type
4744 * @param *pMsgBuf A pointer to the SME message buffer
4745 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4746 * false - if pMsgBuf is not to be freed.
4747 */
4748static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
4749{
4750 tpSirStartBeaconIndication pBeaconStartInd;
4751 tpPESession psessionEntry;
4752 uint8_t sessionId; /* PE sessionID */
4753
4754 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004755 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004756 return;
4757 }
4758
4759 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
4760 psessionEntry = pe_find_session_by_bssid(pMac,
4761 pBeaconStartInd->bssid,
4762 &sessionId);
4763 if (psessionEntry == NULL) {
4764 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004765 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004766 return;
4767 }
4768
4769 if (pBeaconStartInd->beaconStartStatus == true) {
4770 /*
4771 * Currently this Indication comes from SAP
4772 * to start Beacon Tx on a DFS channel
4773 * since beaconing has to be done on DFS
4774 * channel only after CAC WAIT is completed.
4775 * On a DFS Channel LIM does not start beacon
4776 * Tx right after the WMA_ADD_BSS_RSP.
4777 */
4778 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05304779 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004780 FL("Start Beacon with ssid %s Ch %d"),
4781 psessionEntry->ssId.ssId,
4782 psessionEntry->currentOperChannel);
4783 lim_send_beacon_ind(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08004784 lim_enable_obss_detection_config(pMac, psessionEntry);
Arif Hussain05fb4872018-01-03 16:02:55 -08004785 lim_send_obss_color_collision_cfg(pMac, psessionEntry,
4786 OBSS_COLOR_COLLISION_DETECTION);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004787 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004788 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004789 return;
4790 }
4791}
4792
4793/**
4794 * lim_process_sme_channel_change_request() - process sme ch change req
4795 *
4796 * @mac_ctx: Pointer to Global MAC structure
4797 * @msg_buf: pointer to the SME message buffer
4798 *
4799 * This function is called to process SME_CHANNEL_CHANGE_REQ message
4800 *
4801 * Return: None
4802 */
4803static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
4804 uint32_t *msg_buf)
4805{
4806 tpSirChanChangeRequest ch_change_req;
4807 tpPESession session_entry;
4808 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07004809 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004810 uint32_t val = 0;
4811
4812 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004813 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004814 return;
4815 }
4816 ch_change_req = (tpSirChanChangeRequest)msg_buf;
4817
4818 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
4819 ch_change_req->targetChannel);
4820
4821 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
4822 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004823 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004824 return;
4825 }
4826
4827 session_entry = pe_find_session_by_bssid(mac_ctx,
4828 ch_change_req->bssid, &session_id);
4829 if (session_entry == NULL) {
4830 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004831 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004832 return;
4833 }
4834
Manjunathappa Prakash34fda792018-02-07 18:23:42 -08004835 if ((session_entry->currentOperChannel ==
4836 ch_change_req->targetChannel) &&
4837 (session_entry->ch_width == ch_change_req->ch_width)) {
4838 pe_err("Target channel and mode is same as current channel and mode channel %d and mode %d",
4839 session_entry->currentOperChannel, session_entry->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004840 return;
4841 }
4842
4843 if (LIM_IS_AP_ROLE(session_entry))
4844 session_entry->channelChangeReasonCode =
4845 LIM_SWITCH_CHANNEL_SAP_DFS;
4846 else
4847 session_entry->channelChangeReasonCode =
4848 LIM_SWITCH_CHANNEL_OPERATION;
4849
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004850 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004851 session_entry->currentOperChannel,
4852 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004853 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004854
4855 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004856 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004857 session_entry->ch_center_freq_seg0 =
4858 ch_change_req->center_freq_seg_0;
4859 session_entry->ch_center_freq_seg1 =
4860 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004861 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004862 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004863 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004864 session_entry->htRecommendedTxWidthSet =
4865 session_entry->htSupportedChannelWidthSet;
4866 session_entry->currentOperChannel =
4867 ch_change_req->targetChannel;
4868 session_entry->limRFBand =
4869 lim_get_rf_band(session_entry->currentOperChannel);
4870 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08004871 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004872 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004873 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
4874 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004875 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004876 }
4877
4878 session_entry->lim11hEnable = val;
4879 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304880 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004881 &ch_change_req->operational_rateset,
4882 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304883 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004884 &ch_change_req->extended_rateset,
4885 sizeof(session_entry->extRateSet));
4886 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
4887 session_entry->ch_center_freq_seg0,
4888 session_entry->ch_center_freq_seg1,
4889 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07004890 max_tx_pwr, session_entry->peSessionId,
4891 ch_change_req->cac_duration_ms,
4892 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004893}
4894
4895/******************************************************************************
4896* lim_start_bss_update_add_ie_buffer()
4897*
4898***FUNCTION:
4899* This function checks the src buffer and its length and then malloc for
4900* dst buffer update the same
4901*
4902***LOGIC:
4903*
4904***ASSUMPTIONS:
4905*
4906***NOTE:
4907*
4908* @param pMac Pointer to Global MAC structure
4909* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
4910* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
4911* @param *pSrcData_buff A pointer of uint8_t src buffer
4912* @param srcDataLen src buffer length
4913******************************************************************************/
4914
4915static void
4916lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
4917 uint8_t **pDstData_buff,
4918 uint16_t *pDstDataLen,
4919 uint8_t *pSrcData_buff, uint16_t srcDataLen)
4920{
4921
4922 if (srcDataLen > 0 && pSrcData_buff != NULL) {
4923 *pDstDataLen = srcDataLen;
4924
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304925 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004926
4927 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004928 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004929 return;
4930 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304931 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004932 } else {
4933 *pDstData_buff = NULL;
4934 *pDstDataLen = 0;
4935 }
4936}
4937
4938/******************************************************************************
4939* lim_update_add_ie_buffer()
4940*
4941***FUNCTION:
4942* This function checks the src buffer and length if src buffer length more
4943* than dst buffer length then free the dst buffer and malloc for the new src
4944* length, and update the dst buffer and length. But if dst buffer is bigger
4945* than src buffer length then it just update the dst buffer and length
4946*
4947***LOGIC:
4948*
4949***ASSUMPTIONS:
4950*
4951***NOTE:
4952*
4953* @param pMac Pointer to Global MAC structure
4954* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
4955* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
4956* @param *pSrcData_buff A pointer of uint8_t src buffer
4957* @param srcDataLen src buffer length
4958******************************************************************************/
4959
4960static void
4961lim_update_add_ie_buffer(tpAniSirGlobal pMac,
4962 uint8_t **pDstData_buff,
4963 uint16_t *pDstDataLen,
4964 uint8_t *pSrcData_buff, uint16_t srcDataLen)
4965{
4966
4967 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004968 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004969 return;
4970 }
4971
4972 if (srcDataLen > *pDstDataLen) {
4973 *pDstDataLen = srcDataLen;
4974 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304975 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004976 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304977 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004978
4979 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004980 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004981 *pDstDataLen = 0;
4982 return;
4983 }
4984 }
4985
4986 /* copy the content of buffer into dst buffer
4987 */
4988 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304989 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004990
4991}
4992
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004993/**
4994 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
4995 * @pMac : Pointer to Global MAC structure
4996 * @pDstData_buff : A pointer to pointer of dst buffer
4997 * @pDstDataLen : A pointer to pointer of dst buffer length
4998 * @pModifyIE : A pointer to tSirModifyIE
4999 *
5000 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5001 *
5002 * Return:
5003 * True or false depending upon whether IE is updated or not
5004 */
5005static bool
5006lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5007 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5008{
Hong Shi1553d692016-09-28 12:16:19 +08005009 int32_t oui_length;
5010 uint8_t *ibss_ie = NULL;
5011 uint8_t *vendor_ie;
5012#define MAC_VENDOR_OUI "\x00\x16\x32"
5013#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005014
5015 ibss_ie = pModifyIE->pIEBuffer;
5016 oui_length = pModifyIE->oui_length;
5017
5018 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005019 pe_err("Invalid set IBSS vendor IE command length %d",
5020 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005021 return false;
5022 }
5023
Hong Shi1553d692016-09-28 12:16:19 +08005024 /*
5025 * Why replace only beacon OUI data here:
5026 * 1. other ie (such as wpa) shall not be overwritten here.
5027 * 2. per spec, beacon oui ie might be set twice and original one
5028 * shall be updated.
5029 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005030 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005031 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5032 if (vendor_ie) {
5033 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5034 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5035 pModifyIE->ieBufferlength);
5036 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005037 uint16_t new_length;
5038 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005039
Naveen Rawat668dee32017-09-29 14:39:40 -07005040 /*
5041 * check for uint16 overflow before using sum of two numbers as
5042 * length of size to malloc
5043 */
5044 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5045 pe_err("U16 overflow due to %d + %d",
5046 pModifyIE->ieBufferlength, *pDstDataLen);
5047 return false;
5048 }
5049
5050 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5051 new_ptr = qdf_mem_malloc(new_length);
Hong Shi1553d692016-09-28 12:16:19 +08005052 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005053 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005054 return false;
5055 }
5056 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5057 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5058 pModifyIE->ieBufferlength);
5059 qdf_mem_free(*pDstData_buff);
5060 *pDstDataLen = new_length;
5061 *pDstData_buff = new_ptr;
5062 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005063 return true;
5064}
5065
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005066/*
5067* lim_process_modify_add_ies() - process modify additional IE req.
5068*
5069* @mac_ctx: Pointer to Global MAC structure
5070* @msg_buf: pointer to the SME message buffer
5071*
5072* This function update the PE buffers for additional IEs.
5073*
5074* Return: None
5075*/
5076static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5077 uint32_t *msg_buf)
5078{
5079 tpSirModifyIEsInd modify_add_ies;
5080 tpPESession session_entry;
5081 uint8_t session_id;
5082 bool ret = false;
5083 tSirAddIeParams *add_ie_params;
5084
5085 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005086 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005087 return;
5088 }
5089
5090 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5091 /* Incoming message has smeSession, use BSSID to find PE session */
5092 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005093 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005094
5095 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005096 pe_err("Session not found for given bssid"
5097 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005098 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005099 goto end;
5100 }
5101 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5102 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5103 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005104 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005105 modify_add_ies->modifyIE.pIEBuffer,
5106 modify_add_ies->modifyIE.ieBufferlength,
5107 modify_add_ies->modifyIE.ieID,
5108 modify_add_ies->modifyIE.ieIDLen,
5109 modify_add_ies->updateType);
5110 goto end;
5111 }
5112 add_ie_params = &session_entry->addIeParams;
5113 switch (modify_add_ies->updateType) {
5114 case eUPDATE_IE_PROBE_RESP:
5115 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005116 if (LIM_IS_IBSS_ROLE(session_entry)) {
5117 lim_update_ibss_prop_add_ies(mac_ctx,
5118 &add_ie_params->probeRespData_buff,
5119 &add_ie_params->probeRespDataLen,
5120 &modify_add_ies->modifyIE);
5121 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005122 break;
5123 case eUPDATE_IE_ASSOC_RESP:
5124 /* assoc resp IE */
5125 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305126 QDF_TRACE(QDF_MODULE_ID_PE,
5127 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005128 "assoc resp add ie not present %d"),
5129 add_ie_params->assocRespDataLen);
5130 }
5131 /* search through the buffer and modify the IE */
5132 break;
5133 case eUPDATE_IE_PROBE_BCN:
5134 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005135 if (LIM_IS_IBSS_ROLE(session_entry)) {
5136 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5137 &add_ie_params->probeRespBCNData_buff,
5138 &add_ie_params->probeRespBCNDataLen,
5139 &modify_add_ies->modifyIE);
5140 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005141 if (ret == true && modify_add_ies->modifyIE.notify) {
5142 lim_handle_param_update(mac_ctx,
5143 modify_add_ies->updateType);
5144 }
5145 break;
5146 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005147 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005148 modify_add_ies->updateType);
5149 break;
5150 }
5151end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305152 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005153 modify_add_ies->modifyIE.pIEBuffer = NULL;
5154}
5155
5156/*
5157* lim_process_update_add_ies() - process additional IE update req
5158*
5159* @mac_ctx: Pointer to Global MAC structure
5160* @msg_buf: pointer to the SME message buffer
5161*
5162* This function update the PE buffers for additional IEs.
5163*
5164* Return: None
5165*/
5166static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5167 uint32_t *msg_buf)
5168{
5169 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5170 uint8_t session_id;
5171 tpPESession session_entry;
5172 tSirAddIeParams *addn_ie;
5173 uint16_t new_length = 0;
5174 uint8_t *new_ptr = NULL;
5175 tSirUpdateIE *update_ie;
5176
5177 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005178 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005179 return;
5180 }
5181 update_ie = &update_add_ies->updateIE;
5182 /* incoming message has smeSession, use BSSID to find PE session */
5183 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005184 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005185
5186 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005187 pe_err("Session not found for given bssid"
5188 MAC_ADDRESS_STR,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005189 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005190 goto end;
5191 }
5192 addn_ie = &session_entry->addIeParams;
5193 /* if len is 0, upper layer requested freeing of buffer */
5194 if (0 == update_ie->ieBufferlength) {
5195 switch (update_add_ies->updateType) {
5196 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305197 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005198 addn_ie->probeRespData_buff = NULL;
5199 addn_ie->probeRespDataLen = 0;
5200 break;
5201 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305202 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005203 addn_ie->assocRespData_buff = NULL;
5204 addn_ie->assocRespDataLen = 0;
5205 break;
5206 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305207 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005208 addn_ie->probeRespBCNData_buff = NULL;
5209 addn_ie->probeRespBCNDataLen = 0;
5210
5211 if (update_ie->notify)
5212 lim_handle_param_update(mac_ctx,
5213 update_add_ies->updateType);
5214 break;
5215 default:
5216 break;
5217 }
5218 return;
5219 }
5220 switch (update_add_ies->updateType) {
5221 case eUPDATE_IE_PROBE_RESP:
5222 if (update_ie->append) {
5223 /*
5224 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005225 * with combined length.
5226 * Multiple back to back append commands
5227 * can lead to a huge length.So, check
5228 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005229 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005230 if (addn_ie->probeRespDataLen >
5231 (USHRT_MAX - update_ie->ieBufferlength)) {
5232 pe_err("IE Length overflow, curr:%d, new:%d",
5233 addn_ie->probeRespDataLen,
5234 update_ie->ieBufferlength);
5235 goto end;
5236 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005237 new_length = update_ie->ieBufferlength +
5238 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305239 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005240 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005241 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005242 goto end;
5243 }
5244 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305245 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005246 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305247 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005248 update_ie->pAdditionIEBuffer,
5249 update_ie->ieBufferlength);
5250 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305251 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005252 /* adjust length accordingly */
5253 addn_ie->probeRespDataLen = new_length;
5254 /* save refernece of local buffer in PE session */
5255 addn_ie->probeRespData_buff = new_ptr;
5256 goto end;
5257 }
5258 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5259 &addn_ie->probeRespDataLen,
5260 update_ie->pAdditionIEBuffer,
5261 update_ie->ieBufferlength);
5262 break;
5263 case eUPDATE_IE_ASSOC_RESP:
5264 /* assoc resp IE */
5265 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5266 &addn_ie->assocRespDataLen,
5267 update_ie->pAdditionIEBuffer,
5268 update_ie->ieBufferlength);
5269 break;
5270 case eUPDATE_IE_PROBE_BCN:
5271 /* probe resp Bcn IE */
5272 lim_update_add_ie_buffer(mac_ctx,
5273 &addn_ie->probeRespBCNData_buff,
5274 &addn_ie->probeRespBCNDataLen,
5275 update_ie->pAdditionIEBuffer,
5276 update_ie->ieBufferlength);
5277 if (update_ie->notify)
5278 lim_handle_param_update(mac_ctx,
5279 update_add_ies->updateType);
5280 break;
5281 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005282 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005283 break;
5284 }
5285end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305286 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005287 update_ie->pAdditionIEBuffer = NULL;
5288}
5289
5290/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305291 * send_extended_chan_switch_action_frame()- function to send ECSA
5292 * action frame for each sta connected to SAP/GO and AP in case of
5293 * STA .
5294 * @mac_ctx: pointer to global mac structure
5295 * @new_channel: new channel to switch to.
5296 * @ch_bandwidth: BW of channel to calculate op_class
5297 * @session_entry: pe session
5298 *
5299 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5300 *
5301 * Return: void
5302 */
5303
5304static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5305 uint16_t new_channel, uint8_t ch_bandwidth,
5306 tpPESession session_entry)
5307{
5308 uint16_t op_class;
5309 uint8_t switch_mode = 0, i;
5310 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005311 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305312
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005313 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305314 mac_ctx->scan.countryCodeCurrent,
5315 new_channel,
5316 ch_bandwidth);
5317
5318 if (LIM_IS_AP_ROLE(session_entry) &&
5319 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005320 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305321
gaoleze2920bd2017-03-21 17:38:42 +08005322 switch_count = session_entry->gLimChannelSwitch.switchCount;
5323
Abhishek Singh518323d2015-10-19 17:42:01 +05305324 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005325 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305326 psta =
5327 session_entry->dph.dphHashTable.pDphNodeArray + i;
5328 if (psta && psta->added)
5329 lim_send_extended_chan_switch_action_frame(
5330 mac_ctx,
5331 psta->staAddr,
5332 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005333 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305334 }
5335 } else if (LIM_IS_STA_ROLE(session_entry)) {
5336 lim_send_extended_chan_switch_action_frame(mac_ctx,
5337 session_entry->bssId,
5338 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005339 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305340 }
5341
5342}
5343
gaolez76d2a162017-03-21 19:23:58 +08005344void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5345 uint16_t new_channel,
5346 uint8_t ch_bandwidth,
5347 tpPESession session_entry)
5348{
5349 uint16_t op_class;
5350 uint8_t switch_mode = 0, i;
5351 uint8_t switch_count;
5352 tpDphHashNode psta;
5353 tpDphHashNode dph_node_array_ptr;
5354
5355 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5356
5357 op_class = wlan_reg_dmn_get_opclass_from_channel(
5358 mac_ctx->scan.countryCodeCurrent,
5359 new_channel, ch_bandwidth);
5360
5361 if (LIM_IS_AP_ROLE(session_entry) &&
5362 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5363 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5364
5365 switch_count = session_entry->gLimChannelSwitch.switchCount;
5366
5367 if (LIM_IS_AP_ROLE(session_entry)) {
5368 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5369 psta = dph_node_array_ptr + i;
5370 if (!(psta && psta->added))
5371 continue;
5372 if (session_entry->lim_non_ecsa_cap_num == 0)
5373 lim_send_extended_chan_switch_action_frame
5374 (mac_ctx, psta->staAddr, switch_mode,
5375 op_class, new_channel, switch_count,
5376 session_entry);
5377 else
5378 lim_send_channel_switch_mgmt_frame
5379 (mac_ctx, psta->staAddr, switch_mode,
5380 new_channel, switch_count,
5381 session_entry);
5382 }
5383 } else if (LIM_IS_STA_ROLE(session_entry)) {
5384 lim_send_extended_chan_switch_action_frame
5385 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5386 new_channel, switch_count, session_entry);
5387 }
5388}
5389
5390/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005391 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5392 *
5393 * @mac_ctx: Pointer to Global MAC structure
5394 * @msg_buf: pointer to the SME message buffer
5395 *
5396 * This function processes SME request messages from HDD or upper layer
5397 * application.
5398 *
5399 * Return: None
5400 */
5401static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5402 uint32_t *msg_buf)
5403{
5404 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5405 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005406 uint8_t session_id;
5407 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005408 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005409
5410 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005411 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005412 return;
5413 }
5414
5415 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5416 session_entry = pe_find_session_by_bssid(mac_ctx,
5417 dfs_csa_ie_req->bssid, &session_id);
5418 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005419 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005420 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5421 return;
5422 }
5423
5424 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005425 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005426 GET_LIM_SYSTEM_ROLE(session_entry));
5427 return;
5428 }
5429
5430 /* target channel */
5431 session_entry->gLimChannelSwitch.primaryChannel =
5432 dfs_csa_ie_req->targetChannel;
5433
5434 /* Channel switch announcement needs to be included in beacon */
5435 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005436 session_entry->gLimChannelSwitch.switchCount =
5437 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005438 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005439 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305440 session_entry->gLimChannelSwitch.sec_ch_offset =
5441 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005442 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005443 session_entry->gLimChannelSwitch.switchMode =
5444 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005445
5446 /*
5447 * Validate if SAP is operating HT or VHT mode and set the Channel
5448 * Switch Wrapper element with the Wide Band Switch subelement.
5449 */
5450 if (true != session_entry->vhtCapability)
5451 goto skip_vht;
5452
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005453 /* Now encode the Wider Ch BW element depending on the ch width */
5454 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005455 switch (dfs_csa_ie_req->ch_params.ch_width) {
5456 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005457 /*
5458 * Wide channel BW sublement in channel wrapper element is not
5459 * required in case of 20 Mhz operation. Currently It is set
5460 * only set in case of 40/80 Mhz Operation.
5461 */
5462 session_entry->dfsIncludeChanWrapperIe = false;
5463 wider_bw_ch_switch->newChanWidth =
5464 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5465 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005466 case CH_WIDTH_40MHZ:
5467 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005468 wider_bw_ch_switch->newChanWidth =
5469 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5470 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005471 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005472 session_entry->dfsIncludeChanWrapperIe = true;
5473 wider_bw_ch_switch->newChanWidth =
5474 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5475 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005476 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005477 session_entry->dfsIncludeChanWrapperIe = true;
5478 wider_bw_ch_switch->newChanWidth =
5479 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5480 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005481 case CH_WIDTH_80P80MHZ:
5482 session_entry->dfsIncludeChanWrapperIe = true;
5483 wider_bw_ch_switch->newChanWidth =
5484 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005485 /*
5486 * This is not applicable for 20/40/80 Mhz.
5487 * Only used when we support 80+80 Mhz operation.
5488 * In case of 80+80 Mhz, this parameter indicates
5489 * center channel frequency index of 80 Mhz channel of
5490 * frequency segment 1.
5491 */
5492 wider_bw_ch_switch->newCenterChanFreq1 =
5493 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005494 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005495 default:
5496 session_entry->dfsIncludeChanWrapperIe = false;
5497 /*
5498 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5499 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5500 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005501 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005502 break;
5503 }
5504 /* Fetch the center channel based on the channel width */
5505 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005506 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005507skip_vht:
5508 /* Send CSA IE request from here */
5509 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5510 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005511 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005512 return;
5513 }
5514
5515 /*
5516 * First beacon update request is sent here, the remaining updates are
5517 * done when the FW responds back after sending the first beacon after
5518 * the template update
5519 */
5520 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305521
5522 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5523 ch_offset = BW80;
5524 else
5525 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5526
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005527 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305528 session_entry->gLimChannelSwitch.switchCount,
5529 session_entry->gLimChannelSwitch.primaryChannel,
5530 session_entry->gLimChannelSwitch.ch_width,
5531 session_entry->dfsIncludeChanWrapperIe,
5532 ch_offset);
5533
gaolez76d2a162017-03-21 19:23:58 +08005534 /* Send ECSA/CSA Action frame after updating the beacon */
5535 if (CHAN_HOP_ALL_BANDS_ENABLE)
5536 lim_send_chan_switch_action_frame(mac_ctx,
5537 session_entry->gLimChannelSwitch.primaryChannel,
5538 ch_offset, session_entry);
5539 else
5540 send_extended_chan_switch_action_frame(mac_ctx,
5541 session_entry->gLimChannelSwitch.primaryChannel,
5542 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005543}
5544
5545/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305546 * lim_process_ext_change_channel()- function to send ECSA
5547 * action frame for STA/CLI .
5548 * @mac_ctx: pointer to global mac structure
5549 * @msg: params from sme for new channel.
5550 *
5551 * This function is called to send ECSA frame for STA/CLI.
5552 *
5553 * Return: void
5554 */
5555
5556static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5557 uint32_t *msg)
5558{
5559 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5560 (struct sir_sme_ext_cng_chan_req *) msg;
5561 tpPESession session_entry = NULL;
5562
5563 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005564 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305565 return;
5566 }
5567 session_entry =
5568 pe_find_session_by_sme_session_id(mac_ctx,
5569 ext_chng_channel->session_id);
5570 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005571 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305572 ext_chng_channel->session_id);
5573 return;
5574 }
5575 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005576 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305577 return;
5578 }
5579 send_extended_chan_switch_action_frame(mac_ctx,
5580 ext_chng_channel->new_channel,
5581 0, session_entry);
5582}
5583
5584/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005585 * lim_process_nss_update_request() - process sme nss update req
5586 *
5587 * @mac_ctx: Pointer to Global MAC structure
5588 * @msg_buf: pointer to the SME message buffer
5589 *
5590 * This function processes SME request messages from HDD or upper layer
5591 * application.
5592 *
5593 * Return: None
5594 */
5595static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5596 uint32_t *msg_buf)
5597{
5598 struct sir_nss_update_request *nss_update_req_ptr;
5599 tpPESession session_entry = NULL;
5600
5601 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005602 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005603 return;
5604 }
5605
5606 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305607 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005608 nss_update_req_ptr->vdev_id);
5609 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005610 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005611 nss_update_req_ptr->vdev_id);
5612 return;
5613 }
5614
5615 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005616 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005617 GET_LIM_SYSTEM_ROLE(session_entry));
5618 return;
5619 }
5620
5621 /* populate nss field in the beacon */
5622 session_entry->gLimOperatingMode.present = 1;
5623 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05305624 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
5625
5626 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
5627 (session_entry->ch_width > CH_WIDTH_80MHZ))
5628 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
5629
5630 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
5631
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005632 /* Send nss update request from here */
5633 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5634 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005635 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005636 return;
5637 }
5638
5639 lim_send_beacon_ind(mac_ctx, session_entry);
5640}
5641
5642/**
5643 * lim_process_set_ie_req() - process sme set IE request
5644 *
5645 * @mac_ctx: Pointer to Global MAC structure
5646 * @msg_buf: pointer to the SME message buffer
5647 *
5648 * This function processes SME request messages from HDD or upper layer
5649 * application.
5650 *
5651 * Return: None
5652 */
5653static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5654{
5655 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305656 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005657
5658 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005659 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005660 return;
5661 }
5662
5663 msg = (struct send_extcap_ie *)msg_buf;
5664 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305665 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005666 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005667
5668}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005669
5670#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Arif Hussain05fb4872018-01-03 16:02:55 -08005671
5672/**
5673 * obss_color_collision_process_color_disable() - Disable bss color
5674 * @mac_ctx: Pointer to Global MAC structure
5675 * @session: pointer to session
5676 *
5677 * This function will disbale bss color.
5678 *
5679 * Return: None
5680 */
5681static void obss_color_collision_process_color_disable(tpAniSirGlobal mac_ctx,
5682 tpPESession session)
5683{
5684 tUpdateBeaconParams beacon_params;
5685
5686 if (!session) {
5687 pe_err("Invalid session");
5688 return;
5689 }
5690
5691 if (session->valid && !LIM_IS_AP_ROLE(session)) {
5692 pe_err("Invalid SystemRole %d",
5693 GET_LIM_SYSTEM_ROLE(session));
5694 return;
5695 }
5696
5697 if (session->bss_color_changing == 1) {
5698 pe_warn("%d: color change in progress", session->smeSessionId);
5699 /* Continue color collision detection */
5700 lim_send_obss_color_collision_cfg(mac_ctx, session,
5701 OBSS_COLOR_COLLISION_DETECTION);
5702 return;
5703 }
5704
5705 if (session->he_op.bss_col_disabled == 1) {
5706 pe_warn("%d: bss color already disabled",
5707 session->smeSessionId);
5708 /* Continue free color detection */
5709 lim_send_obss_color_collision_cfg(mac_ctx, session,
5710 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5711 return;
5712 }
5713
5714 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5715 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5716 session->he_op.bss_col_disabled = 1;
Arif Hussain05fb4872018-01-03 16:02:55 -08005717 beacon_params.bss_color_disabled = 1;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005718 beacon_params.bss_color = session->he_op.bss_color;
Arif Hussain05fb4872018-01-03 16:02:55 -08005719
5720 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
5721 eSIR_SUCCESS) {
5722 pe_err("Unable to set op mode IE in beacon");
5723 return;
5724 }
5725
5726 lim_send_beacon_params(mac_ctx, &beacon_params, session);
5727 lim_send_obss_color_collision_cfg(mac_ctx, session,
5728 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5729}
5730
5731/**
5732 * obss_color_collision_process_color_change() - Process bss color change
5733 * @mac_ctx: Pointer to Global MAC structure
5734 * @session: pointer to session
5735 * @obss_color_info: obss color collision/free slot indication info
5736 *
5737 * This function selects new color ib case of bss color collision.
5738 *
5739 * Return: None
5740 */
5741static void obss_color_collision_process_color_change(tpAniSirGlobal mac_ctx,
5742 tpPESession session,
5743 struct wmi_obss_color_collision_info *obss_color_info)
5744{
5745 int i, num_bss_color = 0;
5746 uint32_t bss_color_bitmap;
5747 uint8_t bss_color_index_array[MAX_BSS_COLOR_VALUE];
5748 uint32_t rand_byte = 0;
5749 struct sir_set_he_bss_color he_bss_color;
5750 bool is_color_collision = false;
5751
5752
5753 if (session->bss_color_changing == 1) {
5754 pe_err("%d: color change in progress", session->smeSessionId);
5755 return;
5756 }
5757
5758 if (!session->he_op.bss_col_disabled) {
5759 if (session->he_op.bss_color < 32)
5760 is_color_collision = (obss_color_info->
5761 obss_color_bitmap_bit0to31 >>
5762 session->he_op.bss_color) & 0x01;
5763 else
5764 is_color_collision = (obss_color_info->
5765 obss_color_bitmap_bit32to63 >>
5766 (session->he_op.bss_color -
5767 31)) & 0x01;
5768 if (!is_color_collision) {
5769 pe_err("%d: color collision not found, curr_color: %d",
5770 session->smeSessionId,
5771 session->he_op.bss_color);
5772 return;
5773 }
5774 }
5775
5776 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit0to31;
5777
5778 /* Skip color zero */
5779 bss_color_bitmap = bss_color_bitmap >> 1;
5780 for (i = 0; (i < 31) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5781 if (!(bss_color_bitmap & 0x01)) {
5782 bss_color_index_array[num_bss_color] = i + 1;
5783 num_bss_color++;
5784 }
5785 bss_color_bitmap = bss_color_bitmap >> 1;
5786 }
5787
5788 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit32to63;
5789 for (i = 0; (i < 32) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5790 if (!(bss_color_bitmap & 0x01)) {
5791 bss_color_index_array[num_bss_color] = i + 32;
5792 num_bss_color++;
5793 }
5794 bss_color_bitmap = bss_color_bitmap >> 1;
5795 }
5796
5797 if (num_bss_color) {
5798 qdf_get_random_bytes((void *) &rand_byte, 1);
5799 i = (rand_byte + qdf_mc_timer_get_system_ticks()) %
5800 num_bss_color;
5801 pe_debug("New bss color = %d", bss_color_index_array[i]);
5802 he_bss_color.session_id = obss_color_info->vdev_id;
5803 he_bss_color.bss_color = bss_color_index_array[i];
5804 lim_process_set_he_bss_color(mac_ctx,
5805 (uint32_t *)&he_bss_color);
5806 } else {
5807 pe_err("Unable to find bss color from bitmasp");
5808 if (obss_color_info->evt_type ==
5809 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY &&
5810 session->obss_color_collision_dec_evt ==
5811 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
5812 /* In dot11BSSColorCollisionAPPeriod and
5813 * timer expired, time to disable bss color.
5814 */
5815 obss_color_collision_process_color_disable(mac_ctx,
5816 session);
5817 else
5818 /*
5819 * Enter dot11BSSColorCollisionAPPeriod period.
5820 */
5821 lim_send_obss_color_collision_cfg(mac_ctx, session,
5822 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY);
5823 }
5824}
5825
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005826void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5827{
5828 struct sir_set_he_bss_color *bss_color;
5829 tpPESession session_entry = NULL;
5830 tUpdateBeaconParams beacon_params;
5831
5832 if (!msg_buf) {
5833 pe_err("Buffer is Pointing to NULL");
5834 return;
5835 }
5836
5837 bss_color = (struct sir_set_he_bss_color *)msg_buf;
5838 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5839 bss_color->session_id);
5840 if (!session_entry) {
5841 pe_err("Session not found for given session_id %d",
5842 bss_color->session_id);
5843 return;
5844 }
5845
5846 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5847 pe_err("Invalid SystemRole %d",
5848 GET_LIM_SYSTEM_ROLE(session_entry));
5849 return;
5850 }
5851
5852 if (bss_color->bss_color == session_entry->he_op.bss_color) {
5853 pe_err("No change in BSS color, current BSS color %d",
5854 bss_color->bss_color);
5855 return;
5856 }
5857 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5858 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5859 session_entry->he_op.bss_col_disabled = 1;
5860 session_entry->he_bss_color_change.countdown =
5861 BSS_COLOR_SWITCH_COUNTDOWN;
5862 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005863 beacon_params.bss_color_disabled = 1;
5864 beacon_params.bss_color = session_entry->he_op.bss_color;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005865 session_entry->bss_color_changing = 1;
5866
5867 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5868 eSIR_SUCCESS) {
5869 pe_err("Unable to set op mode IE in beacon");
5870 return;
5871 }
5872
5873 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
Arif Hussain05fb4872018-01-03 16:02:55 -08005874 lim_send_obss_color_collision_cfg(mac_ctx, session_entry,
5875 OBSS_COLOR_COLLISION_DETECTION_DISABLE);
5876}
5877
5878void lim_send_obss_color_collision_cfg(tpAniSirGlobal mac_ctx,
5879 tpPESession session,
5880 enum wmi_obss_color_collision_evt_type
5881 event_type)
5882{
5883 struct wmi_obss_color_collision_cfg_param *cfg_param;
5884 struct scheduler_msg msg = {0};
5885
5886 if (!session) {
5887 pe_err("Invalid session");
5888 return;
5889 }
5890
5891 if (!session->he_capable ||
5892 !session->is_session_obss_color_collision_det_enabled) {
5893 pe_debug("%d: obss color det not enabled, he_cap:%d, sup:%d:%d",
5894 session->smeSessionId, session->he_capable,
5895 session->is_session_obss_color_collision_det_enabled,
5896 mac_ctx->lim.global_obss_color_collision_det_offload);
5897 return;
5898 }
5899
5900 cfg_param = qdf_mem_malloc(sizeof(*cfg_param));
5901 if (!cfg_param) {
5902 pe_err("Failed to allocate memory");
5903 return;
5904 }
5905
5906 pe_debug("%d: sending event:%d", session->smeSessionId, event_type);
5907 qdf_mem_zero(cfg_param, sizeof(*cfg_param));
5908 cfg_param->vdev_id = session->smeSessionId;
5909 cfg_param->evt_type = event_type;
5910 if (LIM_IS_AP_ROLE(session))
5911 cfg_param->detection_period_ms =
5912 OBSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS;
5913 else
5914 cfg_param->detection_period_ms =
5915 OBSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS;
5916
5917 cfg_param->scan_period_ms = OBSS_COLOR_COLLISION_SCAN_PERIOD_MS;
5918 if (event_type == OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
5919 cfg_param->free_slot_expiry_time_ms =
5920 OBSS_COLOR_COLLISION_FREE_SLOT_EXPIRY_MS;
5921
5922 msg.type = WMA_OBSS_COLOR_COLLISION_REQ;
5923 msg.bodyptr = cfg_param;
5924 msg.reserved = 0;
5925
5926 if (QDF_IS_STATUS_ERROR(scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
5927 pe_err("Failed to post WMA_OBSS_COLOR_COLLISION_REQ to WMA");
5928 qdf_mem_free(cfg_param);
5929 } else {
5930 session->obss_color_collision_dec_evt = event_type;
5931 }
5932}
5933
5934void lim_process_obss_color_collision_info(tpAniSirGlobal mac_ctx,
5935 uint32_t *msg_buf)
5936{
5937 struct wmi_obss_color_collision_info *obss_color_info;
5938 tpPESession session;
5939
5940 if (!msg_buf) {
5941 pe_err("Buffer is Pointing to NULL");
5942 return;
5943 }
5944
5945 obss_color_info = (struct wmi_obss_color_collision_info *)msg_buf;
5946 session = pe_find_session_by_sme_session_id(mac_ctx,
5947 obss_color_info->vdev_id);
5948 if (!session) {
5949 pe_err("Session not found for given session_id %d",
5950 obss_color_info->vdev_id);
5951 return;
5952 }
5953
5954 pe_debug("vdev_id:%d, evt:%d:%d, 0to31:0x%x, 32to63:0x%x, cap:%d:%d:%d",
5955 obss_color_info->vdev_id,
5956 obss_color_info->evt_type,
5957 session->obss_color_collision_dec_evt,
5958 obss_color_info->obss_color_bitmap_bit0to31,
5959 obss_color_info->obss_color_bitmap_bit32to63,
5960 session->he_capable,
5961 session->is_session_obss_color_collision_det_enabled,
5962 mac_ctx->lim.global_obss_color_collision_det_offload);
5963
5964 if (!session->he_capable ||
5965 !session->is_session_obss_color_collision_det_enabled) {
5966 return;
5967 }
5968
5969 switch (obss_color_info->evt_type) {
5970 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
5971 pe_err("%d: FW disabled obss color det. he_cap:%d, sup:%d:%d",
5972 session->smeSessionId, session->he_capable,
5973 session->is_session_obss_color_collision_det_enabled,
5974 mac_ctx->lim.global_obss_color_collision_det_offload);
5975 session->is_session_obss_color_collision_det_enabled = false;
5976 return;
5977 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
5978 case OBSS_COLOR_COLLISION_DETECTION:
5979 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
5980 if (session->valid && !LIM_IS_AP_ROLE(session)) {
5981 pe_debug("Invalid System Role %d",
5982 GET_LIM_SYSTEM_ROLE(session));
5983 return;
5984 }
5985
5986 if (session->obss_color_collision_dec_evt !=
5987 obss_color_info->evt_type) {
5988 pe_debug("%d: Wrong event: %d, skiping",
5989 obss_color_info->vdev_id,
5990 obss_color_info->evt_type);
5991 return;
5992 }
5993 obss_color_collision_process_color_change(mac_ctx, session,
5994 obss_color_info);
5995 break;
5996 default:
5997 pe_err("%d: Invalid event type %d",
5998 obss_color_info->vdev_id, obss_color_info->evt_type);
5999 return;
6000 }
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006001}
6002#endif