blob: c3dde63034b57478563a690c40913da8d86fbf18 [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);
Abhinav Kumard528d192018-03-09 17:31:12 +05301610 session->def_max_tx_pwr = session->maxTxPower;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301611
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001612 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301613 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001614
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301615 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1616 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1617 pe_debug("Update MaxTxPower in join Req to %d",
1618 sme_join_req->powerCap.maxTxPower);
1619 }
1620
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001621 if (session->gLimCurrentBssUapsd) {
1622 session->gUapsdPerAcBitmask =
1623 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001624 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001625 session->gUapsdPerAcBitmask);
1626
1627 /* resetting the dynamic uapsd mask */
1628 session->gUapsdPerAcDeliveryEnableMask = 0;
1629 session->gUapsdPerAcTriggerEnableMask = 0;
1630 }
1631
1632 session->limRFBand =
1633 lim_get_rf_band(session->currentOperChannel);
1634
1635 /* Initialize 11h Enable Flag */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001636 if (BAND_5G == session->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1638 &val) != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001639 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001640 session->lim11hEnable =
1641 WNI_CFG_11H_ENABLED_STADEF;
1642 } else {
1643 session->lim11hEnable = val;
1644 }
1645 } else {
1646 session->lim11hEnable = 0;
1647 }
1648
1649 /*
1650 * To care of the scenario when STA transitions from
1651 * IBSS to Infrastructure mode.
1652 */
1653 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1654
1655 session->limPrevSmeState = session->limSmeState;
1656 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1657 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1658 session->peSessionId,
1659 session->limSmeState));
1660
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001661 /* Indicate whether spectrum management is enabled */
1662 session->spectrumMgtEnabled =
1663 sme_join_req->spectrumMgtIndicator;
1664
1665 /* Enable the spectrum management if this is a DFS channel */
1666 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001667 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001668 session->currentOperChannel))
1669 session->spectrumMgtEnabled = true;
1670
1671 session->isOSENConnection = sme_join_req->isOSENConnection;
1672
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001673 /* Issue LIM_MLM_JOIN_REQ to MLM */
1674 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1675 (uint32_t *) mlm_join_req);
1676 return;
1677
1678 } else {
1679 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001680 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001681 mac_ctx->lim.gLimSmeState);
1682 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1683 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1684 session = NULL;
1685 goto end;
1686 }
1687
1688end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301689 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1690 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001691
1692 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301693 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001694 sme_join_req = NULL;
1695 if (NULL != session)
1696 session->pLimJoinReq = NULL;
1697 }
1698 if (ret_code != eSIR_SME_SUCCESS) {
1699 if (NULL != session) {
1700 pe_delete_session(mac_ctx, session);
1701 session = NULL;
1702 }
1703 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001704 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001705 sme_session_id, ret_code);
1706 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1707 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1708 sme_transaction_id);
1709}
1710
Amar Singhala297bfa2015-10-15 15:07:29 -07001711uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001712 uint8_t iniTxPower)
1713{
1714 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301715 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001716
Anurag Chouhan6d760662016-02-20 16:05:43 +05301717 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1719 maxTxPower = txPower;
1720 else if (txPower < MIN_TX_PWR_CAP)
1721 maxTxPower = MIN_TX_PWR_CAP;
1722 else
1723 maxTxPower = MAX_TX_PWR_CAP;
1724
1725 return maxTxPower;
1726}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001727
1728/**
1729 * __lim_process_sme_reassoc_req() - process reassoc req
1730 *
1731 * @mac_ctx: Pointer to Global MAC structure
1732 * @msg_buf: pointer to the SME message buffer
1733 *
1734 * This function is called to process SME_REASSOC_REQ message
1735 * from HDD or upper layer application.
1736 *
1737 * Return: None
1738 */
1739
1740static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
1741 uint32_t *msg_buf)
1742{
1743 uint16_t caps;
1744 uint32_t val;
1745 tpSirSmeJoinReq reassoc_req = NULL;
1746 tLimMlmReassocReq *mlm_reassoc_req;
1747 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1748 tpPESession session_entry = NULL;
1749 uint8_t session_id;
1750 uint8_t sme_session_id;
1751 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001752 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001753 uint32_t tele_bcn_en = 0;
1754 uint16_t size;
1755
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301757 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001759 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001760
1761 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1762 goto end;
1763 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301764 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001765
1766 if (!lim_is_sme_join_req_valid(mac_ctx,
1767 (tpSirSmeJoinReq)reassoc_req)) {
1768 /*
1769 * Received invalid eWNI_SME_REASSOC_REQ
1770 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001771 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001772
1773 ret_code = eSIR_SME_INVALID_PARAMETERS;
1774 goto end;
1775 }
1776
1777 session_entry = pe_find_session_by_bssid(mac_ctx,
1778 reassoc_req->bssDescription.bssId,
1779 &session_id);
1780 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001781 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001782 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
1783 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001785 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
1786 &sme_session_id, &transaction_id);
1787 session_entry =
1788 pe_find_session_by_sme_session_id(mac_ctx,
1789 sme_session_id);
1790 if (session_entry != NULL)
1791 lim_handle_sme_join_result(mac_ctx,
1792 eSIR_SME_INVALID_PARAMETERS,
1793 eSIR_MAC_UNSPEC_FAILURE_STATUS,
1794 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001795 goto end;
1796 }
1797#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
1798 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
1799 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
1800#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1801 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
1802
1803 /* Store the reassoc handle in the session Table */
1804 session_entry->pLimReAssocReq = reassoc_req;
1805
1806 session_entry->dot11mode = reassoc_req->dot11mode;
1807 session_entry->vhtCapability =
1808 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001809
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301810 if (session_entry->vhtCapability) {
1811 if (session_entry->pePersona == QDF_STA_MODE) {
1812 session_entry->vht_config.su_beam_formee =
1813 reassoc_req->vht_config.su_beam_formee;
1814 } else {
1815 reassoc_req->vht_config.su_beam_formee = 0;
1816 }
1817 session_entry->enableVhtpAid =
1818 reassoc_req->enableVhtpAid;
1819 session_entry->enableVhtGid =
1820 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001821 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301822 }
1823
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001824 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301825 session_entry->vhtCapability,
1826 session_entry->vht_config.su_beam_formee,
1827 session_entry->vht_config.su_beam_former);
1828
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001829 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
1830 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001831 session_entry->send_smps_action =
1832 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001833 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001834 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001835 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001836 session_entry->send_smps_action,
1837 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001838 /*
1839 * Reassociate request is expected
1840 * in link established state only.
1841 */
1842
1843 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001844 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
1845 /*
1846 * May be from 11r FT pre-auth. So lets check it
1847 * before we bail out
1848 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001849 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001850 session_entry->peSessionId);
1851
1852 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301853 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001854 session_entry->limReAssocbssId,
1855 6)) {
1856 lim_print_mac_addr(mac_ctx,
1857 reassoc_req->bssDescription.
1858 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001859 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001860 ret_code = eSIR_SME_INVALID_PARAMETERS;
1861 goto end;
1862 }
1863
1864 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
1865 session_entry);
1866 return;
1867 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868 /*
1869 * Should not have received eWNI_SME_REASSOC_REQ
1870 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001871 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001872 session_entry->limSmeState);
1873 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
1874
1875 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1876 goto end;
1877 }
1878
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301879 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001880 session_entry->pLimReAssocReq->bssDescription.bssId,
1881 sizeof(tSirMacAddr));
1882
1883 session_entry->limReassocChannelId =
1884 session_entry->pLimReAssocReq->bssDescription.channelId;
1885
1886 session_entry->reAssocHtSupportedChannelWidthSet =
1887 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
1888 session_entry->reAssocHtRecommendedTxWidthSet =
1889 session_entry->reAssocHtSupportedChannelWidthSet;
1890 session_entry->reAssocHtSecondaryChannelOffset =
1891 session_entry->pLimReAssocReq->cbMode;
1892
1893 session_entry->limReassocBssCaps =
1894 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
1895 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1896 session_entry->currentOperChannel);
1897 local_pwr_constraint = reg_max;
1898
1899 lim_extract_ap_capability(mac_ctx,
1900 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
1901 lim_get_ielen_from_bss_description(
1902 &session_entry->pLimReAssocReq->bssDescription),
1903 &session_entry->limReassocBssQosCaps,
1904 &session_entry->limReassocBssPropCap,
1905 &session_entry->gLimCurrentBssUapsd,
1906 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05301907 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001908 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301909 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001910 /* Copy the SSID from session entry to local variable */
1911 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301912 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001913 reassoc_req->ssId.ssId,
1914 session_entry->limReassocSSID.length);
1915 if (session_entry->gLimCurrentBssUapsd) {
1916 session_entry->gUapsdPerAcBitmask =
1917 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001918 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001919 session_entry->gUapsdPerAcBitmask);
1920 }
1921
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301922 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001923 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001924 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001925
1926 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1927 goto end;
1928 }
1929
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301930 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001931 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
1932
1933 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
1934 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001935 eSIR_SUCCESS)
1936 pe_err("could not retrieve ReassocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001937
1938 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001939 eSIR_SUCCESS)
1940 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301941
1942 lim_update_caps_info_for_bss(mac_ctx, &caps,
1943 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001944 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301945
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001946 mlm_reassoc_req->capabilityInfo = caps;
1947
1948 /* Update PE session_id */
1949 mlm_reassoc_req->sessionId = session_id;
1950
1951 /*
1952 * If telescopic beaconing is enabled, set listen interval to
1953 * WNI_CFG_TELE_BCN_MAX_LI
1954 */
1955 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
1956 &tele_bcn_en) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001957 pe_err("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001958
1959 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
1960
1961 if (tele_bcn_en) {
1962 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
1963 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001964 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001965 } else {
1966 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
1967 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001968 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001969 }
1970
1971 mlm_reassoc_req->listenInterval = (uint16_t) val;
1972
1973 /* Indicate whether spectrum management is enabled */
1974 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
1975
1976 /* Enable the spectrum management if this is a DFS channel */
1977 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001978 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001979 session_entry->currentOperChannel))
1980 session_entry->spectrumMgtEnabled = true;
1981
1982 session_entry->limPrevSmeState = session_entry->limSmeState;
1983 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
1984
1985 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1986 session_entry->peSessionId,
1987 session_entry->limSmeState));
1988
1989 lim_post_mlm_message(mac_ctx,
1990 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
1991 return;
1992end:
1993 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301994 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995 if (session_entry)
1996 session_entry->pLimReAssocReq = NULL;
1997 }
1998
1999 if (session_entry) {
2000 /*
2001 * error occurred after we determined the session so extract
2002 * session and transaction info from there
2003 */
2004 sme_session_id = session_entry->smeSessionId;
2005 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002006 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002007 /*
2008 * error occurred before or during the time we determined
2009 * the session so extract the session and transaction info
2010 * from the message
2011 */
2012 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2013 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002014 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002015 /*
2016 * Send Reassoc failure response to host
2017 * (note session_entry may be NULL, but that's OK)
2018 */
2019 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2020 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2021 session_entry, sme_session_id,
2022 transaction_id);
2023}
2024
2025bool send_disassoc_frame = 1;
2026/**
2027 * __lim_process_sme_disassoc_req()
2028 *
2029 ***FUNCTION:
2030 * This function is called to process SME_DISASSOC_REQ message
2031 * from HDD or upper layer application.
2032 *
2033 ***LOGIC:
2034 *
2035 ***ASSUMPTIONS:
2036 *
2037 ***NOTE:
2038 *
2039 * @param pMac Pointer to Global MAC structure
2040 * @param *pMsgBuf A pointer to the SME message buffer
2041 * @return None
2042 */
2043
2044static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2045{
2046 uint16_t disassocTrigger, reasonCode;
2047 tLimMlmDisassocReq *pMlmDisassocReq;
2048 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2049 tSirSmeDisassocReq smeDisassocReq;
2050 tpPESession psessionEntry = NULL;
2051 uint8_t sessionId;
2052 uint8_t smesessionId;
2053 uint16_t smetransactionId;
2054
2055 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002056 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002057 return;
2058 }
2059
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302060 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002061 smesessionId = smeDisassocReq.sessionId;
2062 smetransactionId = smeDisassocReq.transactionId;
2063 if (!lim_is_sme_disassoc_req_valid(pMac,
2064 &smeDisassocReq,
2065 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002066 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002067 if (pMac->lim.gLimRspReqd) {
2068 pMac->lim.gLimRspReqd = false;
2069
2070 retCode = eSIR_SME_INVALID_PARAMETERS;
2071 disassocTrigger = eLIM_HOST_DISASSOC;
2072 goto sendDisassoc;
2073 }
2074
2075 return;
2076 }
2077
2078 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002079 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002080 &sessionId);
2081 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002082 pe_err("session does not exist for given bssId "
2083 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002084 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002085 retCode = eSIR_SME_INVALID_PARAMETERS;
2086 disassocTrigger = eLIM_HOST_DISASSOC;
2087 goto sendDisassoc;
2088 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002089 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2090 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002091 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2092 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002093 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002094
2095#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2096 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2097 0, smeDisassocReq.reasonCode);
2098#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2099
2100 /* Update SME session Id and SME transaction ID */
2101
2102 psessionEntry->smeSessionId = smesessionId;
2103 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002104 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002105 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002106
2107 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2108 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002109 switch (psessionEntry->limSmeState) {
2110 case eLIM_SME_ASSOCIATED_STATE:
2111 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002112 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002113 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002114 psessionEntry->limPrevSmeState =
2115 psessionEntry->limSmeState;
2116 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002117 /* Delete all TDLS peers connected before leaving BSS */
2118 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002119 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2120 psessionEntry->peSessionId,
2121 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002122 break;
2123
2124 case eLIM_SME_WT_DEAUTH_STATE:
2125 /* PE shall still process the DISASSOC_REQ and proceed with
2126 * link tear down even if it had already sent a DEAUTH_IND to
2127 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2128 * its been set when PE entered WT_DEAUTH_STATE.
2129 */
2130 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2131 MTRACE(mac_trace
2132 (pMac, TRACE_CODE_SME_STATE,
2133 psessionEntry->peSessionId,
2134 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002135 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002136 break;
2137
2138 case eLIM_SME_WT_DISASSOC_STATE:
2139 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2140 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2141 * PE can continue processing DISASSOC_REQ and send the response instead
2142 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2143 * for disassoc frame.
2144 *
2145 * It will send a disassoc, which is ok. However, we can use the global flag
2146 * sendDisassoc to not send disassoc frame.
2147 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002148 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149 break;
2150
2151 case eLIM_SME_JOIN_FAILURE_STATE: {
2152 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002153 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002154 if (pMac->lim.gLimRspReqd) {
2155 retCode = eSIR_SME_SUCCESS;
2156 disassocTrigger = eLIM_HOST_DISASSOC;
2157 goto sendDisassoc;
2158 }
2159 }
2160 break;
2161 default:
2162 /**
2163 * STA is not currently associated.
2164 * Log error and send response to host
2165 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002166 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002167 psessionEntry->limSmeState);
2168 lim_print_sme_state(pMac, LOGE,
2169 psessionEntry->limSmeState);
2170
2171 if (pMac->lim.gLimRspReqd) {
2172 if (psessionEntry->limSmeState !=
2173 eLIM_SME_WT_ASSOC_STATE)
2174 pMac->lim.gLimRspReqd = false;
2175
2176 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2177 disassocTrigger = eLIM_HOST_DISASSOC;
2178 goto sendDisassoc;
2179 }
2180
2181 return;
2182 }
2183
2184 break;
2185
2186 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002187 /* Fall through */
2188 break;
2189
2190 case eLIM_STA_IN_IBSS_ROLE:
2191 default:
2192 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002193 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002194 GET_LIM_SYSTEM_ROLE(psessionEntry));
2195
2196 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2197 disassocTrigger = eLIM_HOST_DISASSOC;
2198 goto sendDisassoc;
2199 } /* end switch (pMac->lim.gLimSystemRole) */
2200
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302201 disassocTrigger = eLIM_HOST_DISASSOC;
2202 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002203
2204 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002205 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002206 send_disassoc_frame = 0;
2207 }
2208 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002209 pe_debug("Sending Disasscoc with disassoc Trigger"
2210 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002211 disassocTrigger, reasonCode);
2212
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302213 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002214 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002215 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002216 return;
2217 }
2218
Anurag Chouhanc5548422016-02-24 18:33:27 +05302219 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002220 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002221
2222 pMlmDisassocReq->reasonCode = reasonCode;
2223 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2224
2225 /* Update PE session ID */
2226 pMlmDisassocReq->sessionId = sessionId;
2227
2228 lim_post_mlm_message(pMac,
2229 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2230 return;
2231
2232sendDisassoc:
2233 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002234 lim_send_sme_disassoc_ntf(pMac,
2235 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002236 retCode,
2237 disassocTrigger,
2238 1, smesessionId, smetransactionId,
2239 psessionEntry);
2240 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002241 lim_send_sme_disassoc_ntf(pMac,
2242 smeDisassocReq.peer_macaddr.bytes,
2243 retCode, disassocTrigger, 1,
2244 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002245
2246} /*** end __lim_process_sme_disassoc_req() ***/
2247
2248/** -----------------------------------------------------------------
2249 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2250
2251 This function is called to process SME_DISASSOC_CNF message
2252 from HDD or upper layer application.
2253
2254 \param pMac - global mac structure
2255 \param pStaDs - station dph hash node
2256 \return none
2257 \sa
2258 ----------------------------------------------------------------- */
2259static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2260{
2261 tSirSmeDisassocCnf smeDisassocCnf;
2262 uint16_t aid;
2263 tpDphHashNode pStaDs;
2264 tpPESession psessionEntry;
2265 uint8_t sessionId;
2266
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302267 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002268 sizeof(struct sSirSmeDisassocCnf));
2269
2270 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002271 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002272 &sessionId);
2273 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002274 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002275 return;
2276 }
2277
2278 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002279 pe_err("received invalid SME_DISASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002280 return;
2281 }
2282#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2283 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2284 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2285 psessionEntry,
2286 (uint16_t) smeDisassocCnf.statusCode, 0);
2287 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2288 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2289 psessionEntry,
2290 (uint16_t) smeDisassocCnf.statusCode, 0);
2291#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2292
2293 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2294 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002295 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2296 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2297 && (psessionEntry->limSmeState !=
2298 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002299 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002300 psessionEntry->limSmeState);
2301 lim_print_sme_state(pMac, LOGE,
2302 psessionEntry->limSmeState);
2303 return;
2304 }
2305 break;
2306
2307 case eLIM_AP_ROLE:
2308 /* Fall through */
2309 break;
2310
2311 case eLIM_STA_IN_IBSS_ROLE:
2312 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002313 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002314 GET_LIM_SYSTEM_ROLE(psessionEntry));
2315
2316 return;
2317 }
2318
2319 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2320 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2321 LIM_IS_AP_ROLE(psessionEntry)) {
2322 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002323 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002324 &psessionEntry->dph.dphHashTable);
2325 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002326 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2327 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002328 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002329 return;
2330 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302331
2332 if ((pStaDs->mlmStaContext.mlmState ==
2333 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2334 (pStaDs->mlmStaContext.mlmState ==
2335 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002336 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002337 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302338 pStaDs->mlmStaContext.mlmState);
2339 return;
2340 }
2341
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002342 /* Delete FT session if there exists one */
2343 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002344 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2345
2346 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002347 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002348 }
2349
2350 return;
2351}
2352
2353/**
2354 * __lim_process_sme_deauth_req() - process sme deauth req
2355 * @mac_ctx: Pointer to Global MAC structure
2356 * @msg_buf: pointer to the SME message buffer
2357 *
2358 * This function is called to process SME_DEAUTH_REQ message
2359 * from HDD or upper layer application.
2360 *
2361 * Return: None
2362 */
2363
2364static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2365 uint32_t *msg_buf)
2366{
2367 uint16_t deauth_trigger, reason_code;
2368 tLimMlmDeauthReq *mlm_deauth_req;
2369 tSirSmeDeauthReq sme_deauth_req;
2370 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2371 tpPESession session_entry;
2372 uint8_t session_id; /* PE sessionId */
2373 uint8_t sme_session_id;
2374 uint16_t sme_transaction_id;
2375
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302376 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002377 sme_session_id = sme_deauth_req.sessionId;
2378 sme_transaction_id = sme_deauth_req.transactionId;
2379
2380 /*
2381 * We need to get a session first but we don't even know
2382 * if the message is correct.
2383 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002384 session_entry = pe_find_session_by_bssid(mac_ctx,
2385 sme_deauth_req.bssid.bytes,
2386 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002387 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002388 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002389 ret_code = eSIR_SME_INVALID_PARAMETERS;
2390 deauth_trigger = eLIM_HOST_DEAUTH;
2391 goto send_deauth;
2392 }
2393
2394 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2395 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002396 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002397 mac_ctx->lim.gLimRspReqd = false;
2398
2399 ret_code = eSIR_SME_INVALID_PARAMETERS;
2400 deauth_trigger = eLIM_HOST_DEAUTH;
2401 goto send_deauth;
2402 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002403 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2404 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002405 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2406 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002407 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2409 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2410 session_entry, 0, sme_deauth_req.reasonCode);
2411#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2412
2413 /* Update SME session ID and Transaction ID */
2414 session_entry->smeSessionId = sme_session_id;
2415 session_entry->transactionId = sme_transaction_id;
2416
2417 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2418 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002419 switch (session_entry->limSmeState) {
2420 case eLIM_SME_ASSOCIATED_STATE:
2421 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302422 /* Delete all TDLS peers connected before leaving BSS */
2423 lim_delete_tdls_peers(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002424 case eLIM_SME_WT_ASSOC_STATE:
2425 case eLIM_SME_JOIN_FAILURE_STATE:
2426 case eLIM_SME_IDLE_STATE:
2427 session_entry->limPrevSmeState =
2428 session_entry->limSmeState;
2429 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2430 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2431 session_entry->peSessionId,
2432 session_entry->limSmeState));
2433 /* Send Deauthentication request to MLM below */
2434 break;
2435 case eLIM_SME_WT_DEAUTH_STATE:
2436 case eLIM_SME_WT_DISASSOC_STATE:
2437 /*
2438 * PE Recieved a Deauth/Disassoc frame. Normally it get
2439 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2440 * Which means host is also trying to disconnect.
2441 * PE can continue processing DEAUTH_REQ and send
2442 * the response instead of failing the request.
2443 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2444 * was sent for deauth/disassoc frame.
2445 */
2446 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002447 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002448 break;
2449 default:
2450 /*
2451 * STA is not in a state to deauthenticate with
2452 * peer. Log error and send response to host.
2453 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002454 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002455 session_entry->limSmeState);
2456 lim_print_sme_state(mac_ctx, LOGE,
2457 session_entry->limSmeState);
2458
2459 if (mac_ctx->lim.gLimRspReqd) {
2460 mac_ctx->lim.gLimRspReqd = false;
2461
2462 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2463 deauth_trigger = eLIM_HOST_DEAUTH;
2464
wadesong42968e92017-06-08 14:11:21 +08002465 /*
2466 * here we received deauth request from AP so
2467 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2468 * have ISSUED delSta then mlm state should be
2469 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2470 * delBSS rsp then mlm state should be
2471 * eLIM_MLM_IDLE_STATE so the below condition
2472 * captures the state where delSta not done
2473 * and firmware still in connected state.
2474 */
2475 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002476 eLIM_SME_WT_DEAUTH_STATE &&
2477 session_entry->limMlmState !=
2478 eLIM_MLM_IDLE_STATE &&
2479 session_entry->limMlmState !=
2480 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002481 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002482 goto send_deauth;
2483 }
2484 return;
2485 }
2486 break;
2487
2488 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002489 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002490 if (mac_ctx->lim.gLimRspReqd) {
2491 mac_ctx->lim.gLimRspReqd = false;
2492 ret_code = eSIR_SME_INVALID_PARAMETERS;
2493 deauth_trigger = eLIM_HOST_DEAUTH;
2494 goto send_deauth;
2495 }
2496 return;
2497 case eLIM_AP_ROLE:
2498 break;
2499 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002500 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002501 GET_LIM_SYSTEM_ROLE(session_entry));
2502 if (mac_ctx->lim.gLimRspReqd) {
2503 mac_ctx->lim.gLimRspReqd = false;
2504 ret_code = eSIR_SME_INVALID_PARAMETERS;
2505 deauth_trigger = eLIM_HOST_DEAUTH;
2506 goto send_deauth;
2507 }
2508 return;
2509 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2510
2511 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2512 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002513 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002514 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2515 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2516 } else {
2517 deauth_trigger = eLIM_HOST_DEAUTH;
2518 reason_code = sme_deauth_req.reasonCode;
2519 }
2520
2521 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302522 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002523 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002524 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002525 if (mac_ctx->lim.gLimRspReqd) {
2526 mac_ctx->lim.gLimRspReqd = false;
2527 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2528 deauth_trigger = eLIM_HOST_DEAUTH;
2529 goto send_deauth;
2530 }
2531 return;
2532 }
2533
Anurag Chouhanc5548422016-02-24 18:33:27 +05302534 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002535 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002536
2537 mlm_deauth_req->reasonCode = reason_code;
2538 mlm_deauth_req->deauthTrigger = deauth_trigger;
2539
2540 /* Update PE session Id */
2541 mlm_deauth_req->sessionId = session_id;
2542
2543 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2544 (uint32_t *)mlm_deauth_req);
2545 return;
2546
2547send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002548 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2549 ret_code, deauth_trigger, 1,
2550 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002551}
2552
2553/**
2554 * __lim_process_sme_set_context_req()
2555 *
2556 * @mac_ctx: Pointer to Global MAC structure
2557 * @msg_buf: pointer to the SME message buffer
2558 *
2559 * This function is called to process SME_SETCONTEXT_REQ message
2560 * from HDD or upper layer application.
2561 *
2562 * Return: None
2563 */
2564
2565static void
2566__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2567{
2568 tpSirSmeSetContextReq set_context_req;
2569 tLimMlmSetKeysReq *mlm_set_key_req;
2570 tpPESession session_entry;
2571 uint8_t session_id; /* PE sessionID */
2572 uint8_t sme_session_id;
2573 uint16_t sme_transaction_id;
2574
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002575 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002576 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002577 return;
2578 }
2579
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302580 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002581 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002582 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002583 return;
2584 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302585 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002586 sizeof(struct sSirSmeSetContextReq));
2587 sme_session_id = set_context_req->sessionId;
2588 sme_transaction_id = set_context_req->transactionId;
2589
2590 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002591 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002592 goto end;
2593 }
2594
2595 if (set_context_req->keyMaterial.numKeys >
2596 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002597 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002598 set_context_req->keyMaterial.numKeys);
2599 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002600 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002601 eSIR_SME_INVALID_PARAMETERS, NULL,
2602 sme_session_id, sme_transaction_id);
2603 goto end;
2604 }
2605
2606 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002607 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002608 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002609 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002610 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002611 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002612 eSIR_SME_INVALID_PARAMETERS, NULL,
2613 sme_session_id, sme_transaction_id);
2614 goto end;
2615 }
2616#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2617 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2618 session_entry, 0, 0);
2619#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2620
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002621 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002622 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2623 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002624 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002625 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2626 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302627 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002628 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002629 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002630 goto end;
2631 }
2632 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2633 mlm_set_key_req->numKeys =
2634 set_context_req->keyMaterial.numKeys;
2635 if (mlm_set_key_req->numKeys >
2636 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002637 pe_err("no.of keys exceeded max num of default keys limit");
Jingxiang Ge4168a232018-01-03 18:47:15 +08002638 qdf_mem_free(mlm_set_key_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002639 goto end;
2640 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302641 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002642 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002643
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302644 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002645 (uint8_t *) &set_context_req->keyMaterial.key,
2646 sizeof(tSirKeys) *
2647 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2648 numKeys : 1));
2649
2650 mlm_set_key_req->sessionId = session_id;
2651 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002652 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002653 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002654
2655 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2656 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2657 LIM_IS_AP_ROLE(session_entry)) {
2658 if (set_context_req->keyMaterial.key[0].keyLength) {
2659 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002660
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002661 key_id =
2662 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302663 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002664 &session_entry->WEPKeyMaterial[key_id],
2665 (uint8_t *) &set_context_req->keyMaterial,
2666 sizeof(tSirKeyMaterial));
2667 } else {
2668 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002669
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002670 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2671 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302672 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002673 &mlm_set_key_req->key[i],
2674 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2675 sizeof(tSirKeys));
2676 }
2677 }
2678 }
2679 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2680 (uint32_t *) mlm_set_key_req);
2681 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002682 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002683 GET_LIM_SYSTEM_ROLE(session_entry),
2684 session_entry->limSmeState);
2685 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2686
2687 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002688 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002689 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2690 session_entry, sme_session_id,
2691 sme_transaction_id);
2692 }
2693end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302694 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002695 return;
2696}
2697
2698/**
2699 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2700 *
2701 * @mac_ctx: Pointer to Global MAC structure
2702 * @msg_buf: pointer to the SME message buffer
2703 *
2704 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2705 * from HDD or upper layer application.
2706 *
2707 * Return: None
2708 */
2709
Jeff Johnson801f1532016-10-07 07:54:50 -07002710static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2711 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002712{
2713 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2714 tpDphHashNode sta_ds = NULL;
2715 tpPESession session_entry = NULL;
2716 tSap_Event sap_event;
2717 tpWLAN_SAPEventCB sap_event_cb = NULL;
2718 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2719 uint8_t session_id = CSR_SESSION_ID_INVALID;
2720 uint8_t assoc_id = 0;
2721 uint8_t sta_cnt = 0;
2722
2723 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002724 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002725 return;
2726 }
2727
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302728 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002729 sizeof(struct sSirSmeGetAssocSTAsReq));
2730 /*
2731 * Get Associated stations from PE.
2732 * Find PE session Entry
2733 */
2734 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08002735 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002736 &session_id);
2737 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002738 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002739 goto lim_assoc_sta_end;
2740 }
2741
2742 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002743 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002744 session_entry->limSmeState,
2745 GET_LIM_SYSTEM_ROLE(session_entry));
2746 goto lim_assoc_sta_end;
2747 }
2748 /* Retrieve values obtained in the request message */
2749 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
2750 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2751
2752 if (NULL == assoc_sta_tmp)
2753 goto lim_assoc_sta_end;
2754 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
2755 assoc_id++) {
2756 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
2757 &session_entry->dph.dphHashTable);
2758 if (NULL == sta_ds)
2759 continue;
2760 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302761 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002762 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302763 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002764 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
2765 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
2766
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302767 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002768 (uint8_t *)&sta_ds->supportedRates,
2769 sizeof(tSirSupportedRates));
2770 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
2771 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
2772 assoc_sta_tmp->Support40Mhz =
2773 sta_ds->htDsssCckRate40MHzSupport;
2774
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002775 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002776 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002777 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002778 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002779 pe_debug("Association Id: %d Station Index: %d",
2780 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002781 assoc_sta_tmp++;
2782 sta_cnt++;
2783 }
2784 }
2785lim_assoc_sta_end:
2786 /*
2787 * Call hdd callback with sap event to send the list of
2788 * associated stations from PE
2789 */
2790 if (sap_event_cb != NULL) {
2791 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
2792 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302793 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002794 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
2795 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
2796 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2797 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
2798 }
2799}
2800
2801/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002802 * __lim_counter_measures()
2803 *
2804 * FUNCTION:
2805 * This function is called to "implement" MIC counter measure
2806 * and is *temporary* only
2807 *
2808 * LOGIC: on AP, disassoc all STA associated thru TKIP,
2809 * we don't do the proper STA disassoc sequence since the
2810 * BSS will be stoped anyway
2811 *
2812 ***ASSUMPTIONS:
2813 *
2814 ***NOTE:
2815 *
2816 * @param pMac Pointer to Global MAC structure
2817 * @return None
2818 */
2819
2820static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
2821{
2822 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002823
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002824 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002825 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
2826 mac, psessionEntry, false);
2827};
2828
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002829static void
2830__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2831{
2832 tSirSmeStopBssReq stopBssReq;
2833 tSirRetStatus status;
2834 tLimSmeStates prevState;
2835 tpPESession psessionEntry;
2836 uint8_t smesessionId;
2837 uint8_t sessionId;
2838 uint16_t smetransactionId;
2839 uint8_t i = 0;
2840 tpDphHashNode pStaDs = NULL;
2841
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302842 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002843 smesessionId = stopBssReq.sessionId;
2844 smetransactionId = stopBssReq.transactionId;
2845
2846 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002847 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002848 /* Send Stop BSS response to host */
2849 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2850 eSIR_SME_INVALID_PARAMETERS, smesessionId,
2851 smetransactionId);
2852 return;
2853 }
2854
2855 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08002856 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002857 &sessionId);
2858 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002859 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002860 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2861 eSIR_SME_INVALID_PARAMETERS, smesessionId,
2862 smetransactionId);
2863 return;
2864 }
2865#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2866 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
2867 0, 0);
2868#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2869
2870 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
2871 LIM_IS_STA_ROLE(psessionEntry)) {
2872 /**
2873 * Should not have received STOP_BSS_REQ in states
2874 * other than 'normal' state or on STA in Infrastructure
2875 * mode. Log error and return response to host.
2876 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002877 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002878 psessionEntry->limSmeState,
2879 GET_LIM_SYSTEM_ROLE(psessionEntry));
2880 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
2881 /* / Send Stop BSS response to host */
2882 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2883 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
2884 smetransactionId);
2885 return;
2886 }
2887
2888 if (LIM_IS_AP_ROLE(psessionEntry))
2889 lim_wpspbc_close(pMac, psessionEntry);
2890
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002891 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002892 stopBssReq.reasonCode);
2893
2894 prevState = psessionEntry->limSmeState;
2895
2896 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
2897 MTRACE(mac_trace
2898 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
2899 psessionEntry->limSmeState));
2900
2901 /* Update SME session Id and Transaction Id */
2902 psessionEntry->smeSessionId = smesessionId;
2903 psessionEntry->transactionId = smetransactionId;
2904
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002905 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
2906 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
2907 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002908 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002909
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002910 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
2911 /* Send disassoc all stations associated thru TKIP */
2912 __lim_counter_measures(pMac, psessionEntry);
2913 else
2914 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002915 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
2916 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002917 }
2918
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002919 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
2920 /* Free the buffer allocated in START_BSS_REQ */
2921 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
2922 psessionEntry->addIeParams.probeRespDataLen = 0;
2923 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002924
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002925 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
2926 psessionEntry->addIeParams.assocRespDataLen = 0;
2927 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002928
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002929 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
2930 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
2931 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002932
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002933 /*
2934 * lim_del_bss is also called as part of coalescing,
2935 * when we send DEL BSS followed by Add Bss msg.
2936 */
2937 pMac->lim.gLimIbssCoalescingHappened = false;
2938 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002939 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
2940 pStaDs =
2941 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
2942 if (NULL == pStaDs)
2943 continue;
2944 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
2945 if (eSIR_SUCCESS == status) {
2946 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
2947 pStaDs->assocId, psessionEntry);
2948 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
2949 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002950 pe_err("lim_del_sta failed with Status: %d", status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302951 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002952 }
2953 }
2954 /* send a delBss to HAL and wait for a response */
2955 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
2956
2957 if (status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002958 pe_err("delBss failed for bss %d", psessionEntry->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002959 psessionEntry->limSmeState = prevState;
2960
2961 MTRACE(mac_trace
2962 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
2963 psessionEntry->limSmeState));
2964
2965 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
2966 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
2967 smetransactionId);
2968 }
2969}
2970
2971/**
2972 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
2973 * @pMac: Global MAC context
2974 * @pMsg: Message from SME
2975 *
2976 * Wrapper for the function __lim_handle_sme_stop_bss_request
2977 * This message will be defered until softmac come out of
2978 * scan mode. Message should be handled even if we have
2979 * detected radar in the current operating channel.
2980 *
2981 * Return: true - If we consumed the buffer
2982 * false - If have defered the message.
2983 */
2984
Rajeev Kumarfeb96382017-01-22 19:42:09 -08002985static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
2986 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002987{
2988 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
2989 /**
2990 * If message defered, buffer is not consumed yet.
2991 * So return false
2992 */
2993 return false;
2994 }
2995 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
2996 return true;
2997} /*** end __lim_process_sme_stop_bss_req() ***/
2998
2999void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3000 uint32_t body, tpPESession psessionEntry)
3001{
3002
3003 (void)body;
3004 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3005 lim_ibss_delete(pMac, psessionEntry);
3006 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3007 lim_delete_pre_auth_list(pMac);
3008 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3009 psessionEntry->smeSessionId,
3010 psessionEntry->transactionId);
3011 return;
3012}
3013
3014/**
3015 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3016 *
3017 * @mac_ctx: pointer to mac context
3018 * @msg_type: message type
3019 * @msg_buf: pointer to the SME message buffer
3020 *
3021 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3022 * in BTAMP AP.
3023 *
3024 * Return: None
3025 */
3026
3027void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3028 uint32_t *msg_buf)
3029{
3030 tSirSmeAssocCnf assoc_cnf;
3031 tpDphHashNode sta_ds = NULL;
3032 tpPESession session_entry = NULL;
3033 uint8_t session_id;
3034 tpSirAssocReq assoc_req;
3035
3036 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003037 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003038 goto end;
3039 }
3040
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303041 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003042 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003043 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003044 goto end;
3045 }
3046
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003047 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003048 &session_id);
3049 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003050 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003051 goto end;
3052 }
3053
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003054 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3056 (session_entry->limSmeState !=
3057 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003058 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003059 msg_type, session_entry->limSmeState,
3060 GET_LIM_SYSTEM_ROLE(session_entry));
3061 goto end;
3062 }
3063 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3064 &session_entry->dph.dphHashTable);
3065 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003066 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003067 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303068 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003069
3070 /*
3071 * send a DISASSOC_IND message to WSM to make sure
3072 * the state in WSM and LIM is the same
3073 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003074 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003075 eSIR_SME_STA_NOT_ASSOCIATED,
3076 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3077 session_entry->smeSessionId,
3078 session_entry->transactionId,
3079 session_entry);
3080 goto end;
3081 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303082 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003083 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303084 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003085 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003086 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303087 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003088 goto end;
3089 }
3090
3091 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3092 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3093 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3094 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3095 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003096 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3097 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003098 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303099 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003100 goto end;
3101 }
3102 /*
3103 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3104 * has been received
3105 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003106 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003107 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3108 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3109
3110 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3111 /*
3112 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3113 * when it had received Assoc Request frame. Now, PE just needs
3114 * to send association rsp frame to the requesting BTAMP-STA.
3115 */
3116 sta_ds->mlmStaContext.mlmState =
3117 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003118 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003119 sta_ds->assocId);
3120 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3121 sta_ds->assocId, sta_ds->staAddr,
3122 sta_ds->mlmStaContext.subType, sta_ds,
3123 session_entry);
3124 goto end;
3125 } else {
3126 /*
3127 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3128 * to be associated since the HAL sta entry is created for
3129 * denied STA we need to remove this HAL entry.
3130 * So to do that set updateContext to 1
3131 */
3132 if (!sta_ds->mlmStaContext.updateContext)
3133 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003134 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003135 assoc_cnf.statusCode, sta_ds->assocId);
3136 lim_reject_association(mac_ctx, sta_ds->staAddr,
3137 sta_ds->mlmStaContext.subType,
3138 true, sta_ds->mlmStaContext.authType,
3139 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003140 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003141 session_entry);
3142 }
3143end:
3144 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3145 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3146 assoc_req = (tpSirAssocReq)
3147 session_entry->parsedAssocReq[sta_ds->assocId];
3148 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303149 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003150 assoc_req->assocReqFrame = NULL;
3151 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303152 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003153 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3154 }
3155}
3156
3157static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3158{
3159 tpDphHashNode pStaDs;
3160 tSirMacAddr peerMac;
3161 tpSirAddtsReq pSirAddts;
3162 uint32_t timeout;
3163 tpPESession psessionEntry;
3164 uint8_t sessionId; /* PE sessionId */
3165 uint8_t smesessionId;
3166 uint16_t smetransactionId;
3167
3168 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003169 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003170 return;
3171 }
3172
3173 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3174 &smetransactionId);
3175
3176 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3177
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003178 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3179 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003180 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003181 pe_err("Session Does not exist for given bssId");
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303182 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3183 NULL, pSirAddts->req.tspec,
3184 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003185 return;
3186 }
3187#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3188 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3189 0);
3190#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3191
3192 /* if sta
3193 * - verify assoc state
3194 * - send addts request to ap
3195 * - wait for addts response from ap
3196 * if ap, just ignore with error log
3197 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003198 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3199 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3200 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003201
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003202 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003203 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303204 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003205 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003206
3207 pStaDs =
3208 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3209 &psessionEntry->dph.dphHashTable);
3210
3211 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003212 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303213 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003214 }
3215
3216 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3217 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003218 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303219 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003220 }
3221
3222 pSirAddts->req.wsmTspecPresent = 0;
3223 pSirAddts->req.wmeTspecPresent = 0;
3224 pSirAddts->req.lleTspecPresent = 0;
3225
3226 if ((pStaDs->wsmEnabled) &&
3227 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3228 SIR_MAC_ACCESSPOLICY_EDCA))
3229 pSirAddts->req.wsmTspecPresent = 1;
3230 else if (pStaDs->wmeEnabled)
3231 pSirAddts->req.wmeTspecPresent = 1;
3232 else if (pStaDs->lleEnabled)
3233 pSirAddts->req.lleTspecPresent = 1;
3234 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003235 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303236 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003237 }
3238
3239 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3240 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003241 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003242 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303243 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003244 }
3245
3246 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003247 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003248 pMac->lim.gLimAddtsReq.req.dialogToken,
3249 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3250 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3251 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303252 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253 }
3254
3255 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3256
3257 /* save the addts request */
3258 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303259 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003260 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3261
3262 /* ship out the message now */
3263 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3264 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303265 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003266 /* start a timer to wait for the response */
3267 if (pSirAddts->timeout)
3268 timeout = pSirAddts->timeout;
3269 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3270 eSIR_SUCCESS) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303271 pe_debug("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003272 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303273 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003274 }
3275
3276 timeout = SYS_MS_TO_TICKS(timeout);
3277 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3278 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003279 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303280 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003281 }
3282 pMac->lim.gLimAddtsRspTimerCount++;
3283 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3284 pMac->lim.gLimAddtsRspTimerCount) !=
3285 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003286 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303287 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003288 }
3289 MTRACE(mac_trace
3290 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3291 eLIM_ADDTS_RSP_TIMER));
3292
3293 /* add the sessionId to the timer object */
3294 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3295 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3296 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003297 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303298 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003299 }
3300 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303301
3302send_failure_addts_rsp:
3303 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3304 psessionEntry, pSirAddts->req.tspec,
3305 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003306}
3307
3308static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3309{
3310 tSirMacAddr peerMacAddr;
3311 uint8_t ac;
3312 tSirMacTSInfo *pTsinfo;
3313 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3314 tpDphHashNode pStaDs = NULL;
3315 tpPESession psessionEntry;
3316 uint8_t sessionId;
3317 uint32_t status = eSIR_SUCCESS;
3318 uint8_t smesessionId;
3319 uint16_t smetransactionId;
3320
3321 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3322 &smetransactionId);
3323
3324 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003325 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003326 &sessionId);
3327 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003328 pe_err("Session Does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003329 status = eSIR_FAILURE;
3330 goto end;
3331 }
3332#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3333 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3334 0);
3335#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3336
3337 if (eSIR_SUCCESS !=
3338 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003339 pe_err("lim_validate_delts_req failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003340 status = eSIR_FAILURE;
3341 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3342 smesessionId, smetransactionId);
3343 return;
3344 }
3345
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003346 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3347 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003348 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3349
3350 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3351 pDeltsReq->req.wmeTspecPresent,
3352 &pDeltsReq->req.tsinfo,
3353 &pDeltsReq->req.tspec, psessionEntry);
3354
3355 pTsinfo =
3356 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3357 tsinfo : &pDeltsReq->req.tsinfo;
3358
3359 /* We've successfully send DELTS frame to AP. Update the
3360 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3361 * is no longer trigger enabled or delivery enabled
3362 */
3363 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3364 pTsinfo, CLEAR_UAPSD_MASK);
3365
3366 /* We're deleting the TSPEC, so this particular AC is no longer
3367 * admitted. PE needs to downgrade the EDCA
3368 * parameters(for the AC for which TS is being deleted) to the
3369 * next best AC for which ACM is not enabled, and send the
3370 * updated values to HAL.
3371 */
3372 ac = upToAc(pTsinfo->traffic.userPrio);
3373
3374 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3375 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3376 ~(1 << ac);
3377 } else if (pTsinfo->traffic.direction ==
3378 SIR_MAC_DIRECTION_DNLINK) {
3379 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3380 ~(1 << ac);
3381 } else if (pTsinfo->traffic.direction ==
3382 SIR_MAC_DIRECTION_BIDIR) {
3383 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3384 ~(1 << ac);
3385 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3386 ~(1 << ac);
3387 }
3388
3389 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3390 psessionEntry);
3391
3392 pStaDs =
3393 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3394 &psessionEntry->dph.dphHashTable);
3395 if (pStaDs != NULL) {
3396 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3397 pStaDs->bssId);
3398 status = eSIR_SUCCESS;
3399 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003400 pe_err("Self entry missing in Hash Table");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003401 status = eSIR_FAILURE;
3402 }
3403#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003404 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003405#endif
3406
3407 /* send an sme response back */
3408end:
3409 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3410 smesessionId, smetransactionId);
3411}
3412
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303413void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003414{
3415 /* fetch the sessionEntry based on the sessionId */
3416 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003417
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003418 psessionEntry = pe_find_session_by_session_id(pMac,
3419 pMac->lim.limTimers.gLimAddtsRspTimer.
3420 sessionId);
3421 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003422 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003423 return;
3424 }
3425
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003426 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003427 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003428 GET_LIM_SYSTEM_ROLE(psessionEntry));
3429 pMac->lim.gLimAddtsSent = false;
3430 return;
3431 }
3432
3433 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003434 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003435 return;
3436 }
3437
3438 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003439 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003440 pMac->lim.gLimAddtsRspTimerCount);
3441 return;
3442 }
3443 /* this a real response timeout */
3444 pMac->lim.gLimAddtsSent = false;
3445 pMac->lim.gLimAddtsRspTimerCount++;
3446
3447 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3448 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3449 psessionEntry->smeSessionId,
3450 psessionEntry->transactionId);
3451}
3452
3453/**
3454 * __lim_process_sme_get_statistics_request()
3455 *
3456 ***FUNCTION:
3457 *
3458 *
3459 ***NOTE:
3460 *
3461 * @param pMac Pointer to Global MAC structure
3462 * @param *pMsgBuf A pointer to the SME message buffer
3463 * @return None
3464 */
3465static void
3466__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3467{
3468 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003469 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003470
3471 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3472
3473 msgQ.type = WMA_GET_STATISTICS_REQ;
3474
3475 msgQ.reserved = 0;
3476 msgQ.bodyptr = pMsgBuf;
3477 msgQ.bodyval = 0;
3478 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3479
3480 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303481 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003482 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003483 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003484 return;
3485 }
3486
3487 return;
3488}
3489
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003490#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003491/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003492 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003493 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003494 * @pMac: Pointer to Global MAC structure
3495 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003497 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003498 */
3499static void
3500__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3501{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003502 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003503
3504 msgQ.type = WMA_TSM_STATS_REQ;
3505 msgQ.reserved = 0;
3506 msgQ.bodyptr = pMsgBuf;
3507 msgQ.bodyval = 0;
3508 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3509
3510 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303511 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003512 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003513 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003514 return;
3515 }
3516}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003517#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003518
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08003519static void lim_process_sme_set_addba_accept(tpAniSirGlobal mac_ctx,
3520 struct sme_addba_accept *msg)
3521{
3522 if (!msg) {
3523 pe_err("Msg Buffer is NULL");
3524 return;
3525 }
3526 if (!msg->addba_accept)
3527 mac_ctx->reject_addba_req = 1;
3528 else
3529 mac_ctx->reject_addba_req = 0;
3530}
3531
Arif Hussaineb8ba362018-03-07 19:15:13 -08003532static void lim_process_sme_update_edca_params(tpAniSirGlobal mac_ctx,
3533 uint32_t sme_session_id)
3534{
3535 tpPESession pe_session;
3536 tpDphHashNode sta_ds_ptr;
3537
3538 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3539 if (!pe_session) {
3540 pe_err("Session does not exist: sme_id %d", sme_session_id);
3541 return;
3542 }
3543 pe_session->gLimEdcaParamsActive[EDCA_AC_BE].no_ack =
3544 mac_ctx->no_ack_policy_cfg[EDCA_AC_BE];
3545 pe_session->gLimEdcaParamsActive[EDCA_AC_BK].no_ack =
3546 mac_ctx->no_ack_policy_cfg[EDCA_AC_BK];
3547 pe_session->gLimEdcaParamsActive[EDCA_AC_VI].no_ack =
3548 mac_ctx->no_ack_policy_cfg[EDCA_AC_VI];
3549 pe_session->gLimEdcaParamsActive[EDCA_AC_VO].no_ack =
3550 mac_ctx->no_ack_policy_cfg[EDCA_AC_VO];
3551 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3552 &pe_session->dph.dphHashTable);
3553 if (sta_ds_ptr)
3554 lim_send_edca_params(mac_ctx,
3555 pe_session->gLimEdcaParamsActive,
3556 sta_ds_ptr->bssId);
3557 else
3558 pe_err("Self entry missing in Hash Table");
3559}
3560
Naveen Rawat8029a402017-06-01 10:54:19 -07003561static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3562 struct update_config *msg)
3563{
3564 tpPESession pe_session;
3565
3566 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3567 if (msg == NULL) {
3568 pe_err("Buffer is Pointing to NULL");
3569 return;
3570 }
3571
3572 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3573 msg->sme_session_id);
3574 if (pe_session == NULL) {
3575 pe_warn("Session does not exist for given BSSID");
3576 return;
3577 }
3578
3579 switch (msg->capab) {
3580 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3581 pe_session->htConfig.ht_rx_ldpc = msg->value;
3582 break;
3583 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3584 pe_session->htConfig.ht_tx_stbc = msg->value;
3585 break;
3586 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3587 pe_session->htConfig.ht_rx_stbc = msg->value;
3588 break;
3589 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3590 pe_session->htConfig.ht_sgi20 = msg->value;
3591 break;
3592 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3593 pe_session->htConfig.ht_sgi40 = msg->value;
3594 break;
3595 }
3596
3597 if (LIM_IS_AP_ROLE(pe_session)) {
3598 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3599 lim_send_beacon_ind(mac_ctx, pe_session);
3600 }
3601}
3602
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003603void
3604lim_send_vdev_restart(tpAniSirGlobal pMac,
3605 tpPESession psessionEntry, uint8_t sessionId)
3606{
3607 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003608 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003609 tSirRetStatus retCode = eSIR_SUCCESS;
3610
3611 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003612 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003613 return;
3614 }
3615
3616 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303617 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003619 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003620 return;
3621 }
3622
3623 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3624 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003625 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003626
3627 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3628 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3629 msgQ.bodyval = 0;
3630
3631 retCode = wma_post_ctrl_msg(pMac, &msgQ);
3632 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003633 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303634 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003635 }
3636}
3637
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303638/**
3639 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3640 * @mac_ctx: Pointer to Global MAC structure
3641 * @msg_buf: Pointer to SME message buffer
3642 *
3643 * Return: None
3644 */
3645static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3646 uint32_t *msg_buf)
3647{
3648 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003649 struct scheduler_msg wma_msg = {0};
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303650 tSirRetStatus status;
3651 tSirRoamOffloadScanReq *req_buffer;
3652 uint16_t local_ie_len;
3653 uint8_t *local_ie_buf;
3654
3655 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3656 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3657 req_buffer->sessionId);
3658
3659 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3660 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003661 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303662 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303663 return;
3664 }
3665
3666 local_ie_len = req_buffer->assoc_ie.length;
3667 /* Update ext cap IE if present */
3668 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003669 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3670 local_ie_buf, &local_ie_len)) {
3671 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003672 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3673 req_buffer->assoc_ie.length = local_ie_len;
3674 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3675 local_ie_buf, local_ie_len);
3676 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303677 }
3678 qdf_mem_free(local_ie_buf);
3679
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303680 if (pe_session)
3681 lim_update_fils_rik(pe_session, req_buffer);
3682
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303683 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3684 wma_msg.bodyptr = req_buffer;
3685
3686 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
3687 if (eSIR_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003688 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303689 qdf_mem_free(req_buffer);
3690 }
3691}
3692
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303693/*
3694 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3695 * @mac_ctx: Pointer to global mac context
3696 * @session: Pointer to PE session
3697 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3698 * 1 - Disable broadcast SSID
3699 *
3700 * Return: None
3701 */
3702static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3703 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003704{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003705 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003706 session->ssidHidden, ssid_hidden);
3707
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003708 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303709 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003710 } else {
3711 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05303712 return;
3713 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003714
3715 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303716 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003717
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003718 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303719}
3720
3721/**
3722 * __lim_process_sme_session_update - process SME session update msg
3723 *
3724 * @mac_ctx: Pointer to global mac context
3725 * @msg_buf: Pointer to the received message buffer
3726 *
3727 * Return: None
3728 */
3729static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
3730 uint32_t *msg_buf)
3731{
3732 struct sir_update_session_param *msg;
3733 tpPESession session;
3734
3735 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003736 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303737 return;
3738 }
3739
3740 msg = (struct sir_update_session_param *) msg_buf;
3741
3742 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
3743 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003744 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303745 msg->session_id);
3746 return;
3747 }
3748
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003749 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303750 msg->param_type, msg->param_val);
3751 switch (msg->param_type) {
3752 case SIR_PARAM_SSID_HIDDEN:
3753 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
3754 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303755 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
3756 session->ignore_assoc_disallowed = msg->param_val;
3757 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303758 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003759 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303760 break;
3761 }
3762}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003763
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003764/*
3765 Update the beacon Interval dynamically if beaconInterval is different in MCC
3766 */
3767static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3768{
3769 tpSirChangeBIParams pChangeBIParams;
3770 tpPESession psessionEntry;
3771 uint8_t sessionId = 0;
3772 tUpdateBeaconParams beaconParams;
3773
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003774 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003775
3776 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003777 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003778 return;
3779 }
3780
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303781 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003782 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
3783
3784 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08003785 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003786 &sessionId);
3787 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003788 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003789 return;
3790 }
3791
3792 /*Update sessionEntry Beacon Interval */
3793 if (psessionEntry->beaconParams.beaconInterval !=
3794 pChangeBIParams->beaconInterval) {
3795 psessionEntry->beaconParams.beaconInterval =
3796 pChangeBIParams->beaconInterval;
3797 }
3798
3799 /*Update sch beaconInterval */
3800 if (pMac->sch.schObject.gSchBeaconInterval !=
3801 pChangeBIParams->beaconInterval) {
3802 pMac->sch.schObject.gSchBeaconInterval =
3803 pChangeBIParams->beaconInterval;
3804
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003805 pe_debug("LIM send update BeaconInterval Indication: %d",
3806 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003807
3808 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
3809 /* Update beacon */
3810 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3811
3812 beaconParams.bssIdx = psessionEntry->bssIdx;
3813 /* Set change in beacon Interval */
3814 beaconParams.beaconInterval =
3815 pChangeBIParams->beaconInterval;
3816 beaconParams.paramChangeBitmap =
3817 PARAM_BCN_INTERVAL_CHANGED;
3818 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
3819 }
3820 }
3821
3822 return;
3823} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
3824
3825#ifdef QCA_HT_2040_COEX
3826static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
3827 uint32_t *pMsgBuf)
3828{
3829 tpSirSetHT2040Mode pSetHT2040Mode;
3830 tpPESession psessionEntry;
3831 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003832 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003833 tUpdateVHTOpMode *pHtOpMode = NULL;
3834 uint16_t staId = 0;
3835 tpDphHashNode pStaDs = NULL;
3836
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003837 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003838 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003839 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003840 return;
3841 }
3842
3843 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
3844
3845 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08003846 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003847 &sessionId);
3848 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003849 pe_debug("Session does not exist for given BSSID");
3850 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003851 return;
3852 }
3853
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003854 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003855 pSetHT2040Mode->cbMode);
3856 /*Update sessionEntry HT related fields */
3857 switch (pSetHT2040Mode->cbMode) {
3858 case PHY_SINGLE_CHANNEL_CENTERED:
3859 psessionEntry->htSecondaryChannelOffset =
3860 PHY_SINGLE_CHANNEL_CENTERED;
3861 psessionEntry->htRecommendedTxWidthSet = 0;
3862 if (pSetHT2040Mode->obssEnabled)
3863 psessionEntry->htSupportedChannelWidthSet
3864 = eHT_CHANNEL_WIDTH_40MHZ;
3865 else
3866 psessionEntry->htSupportedChannelWidthSet
3867 = eHT_CHANNEL_WIDTH_20MHZ;
3868 break;
3869 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
3870 psessionEntry->htSecondaryChannelOffset =
3871 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3872 psessionEntry->htRecommendedTxWidthSet = 1;
3873 break;
3874 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
3875 psessionEntry->htSecondaryChannelOffset =
3876 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3877 psessionEntry->htRecommendedTxWidthSet = 1;
3878 break;
3879 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003880 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003881 return;
3882 }
3883
3884 /* Update beacon */
3885 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3886 lim_send_beacon_ind(pMac, psessionEntry);
3887
3888 /* update OP Mode for each associated peer */
3889 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
3890 pStaDs = dph_get_hash_entry(pMac, staId,
3891 &psessionEntry->dph.dphHashTable);
3892 if (NULL == pStaDs)
3893 continue;
3894
3895 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303896 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003897 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003898 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003899 return;
3900 }
3901 pHtOpMode->opMode =
3902 (psessionEntry->htSecondaryChannelOffset ==
3903 PHY_SINGLE_CHANNEL_CENTERED) ?
3904 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
3905 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303906 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003907 sizeof(tSirMacAddr));
3908 pHtOpMode->smesessionId = sessionId;
3909
3910 msg.type = WMA_UPDATE_OP_MODE;
3911 msg.reserved = 0;
3912 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003913 if (!QDF_IS_STATUS_SUCCESS
3914 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
3915 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303916 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003917 return;
3918 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003919 pe_debug("Notifed FW about OP mode: %d for staId=%d",
3920 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003921
3922 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003923 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003924 }
3925
3926 return;
3927}
3928#endif
3929
3930/* -------------------------------------------------------------------- */
3931/**
3932 * __lim_process_report_message
3933 *
3934 * FUNCTION: Processes the next received Radio Resource Management message
3935 *
3936 * LOGIC:
3937 *
3938 * ASSUMPTIONS:
3939 *
3940 * NOTE:
3941 *
3942 * @param None
3943 * @return None
3944 */
3945
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003946static void __lim_process_report_message(tpAniSirGlobal pMac,
3947 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003948{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003949 switch (pMsg->type) {
3950 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
3951 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
3952 break;
3953 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003954 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08003955 break;
3956 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003957 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003958 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003959}
3960
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003961/* -------------------------------------------------------------------- */
3962/**
3963 * lim_send_set_max_tx_power_req
3964 *
3965 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
3966 *
3967 * LOGIC:
3968 *
3969 * ASSUMPTIONS:
3970 *
3971 * NOTE:
3972 *
3973 * @param txPower txPower to be set.
3974 * @param pSessionEntry session entry.
3975 * @return None
3976 */
3977tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07003978lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003979 tpPESession pSessionEntry)
3980{
3981 tpMaxTxPowerParams pMaxTxParams = NULL;
3982 tSirRetStatus retCode = eSIR_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003983 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003984
3985 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003986 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003987 return eSIR_FAILURE;
3988 }
3989
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303990 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003991 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003992 pe_err("Unable to allocate memory for pMaxTxParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003993 return eSIR_MEM_ALLOC_FAILED;
3994
3995 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003996 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303997 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303998 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303999 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004000 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304001 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004002
4003 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4004 msgQ.bodyptr = pMaxTxParams;
4005 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004006 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004007 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4008 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4009 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004010 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304011 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004012 }
4013 return retCode;
4014}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004015
4016/**
4017 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4018 *
4019 * @mac_ctx: Pointer to Global MAC structure
4020 * @msg_buf: pointer to the SME message buffer
4021 *
4022 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4023 * from SME. It Register this information within PE.
4024 *
4025 * Return: None
4026 */
4027static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4028 uint32_t *msg_buf)
4029{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304030 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004031 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4032 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4033 struct mgmt_frm_reg_info *next = NULL;
4034 bool match = false;
4035
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004036 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004037 sme_req->registerFrame, sme_req->frameType,
4038 sme_req->matchLen);
4039 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304040 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304041 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4042 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304043 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004044
4045 while (lim_mgmt_regn != NULL) {
4046 if (lim_mgmt_regn->frameType != sme_req->frameType)
4047 goto skip_match;
4048 if (sme_req->matchLen) {
4049 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304050 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051 sme_req->matchData,
4052 lim_mgmt_regn->matchLen))) {
4053 /* found match! */
4054 match = true;
4055 break;
4056 }
4057 } else {
4058 /* found match! */
4059 match = true;
4060 break;
4061 }
4062skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304063 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304064 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004065 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304066 (qdf_list_node_t *)lim_mgmt_regn,
4067 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304068 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004069 lim_mgmt_regn = next;
4070 next = NULL;
4071 }
4072 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304073 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004074 if (QDF_STATUS_SUCCESS ==
4075 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004076 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004077 (qdf_list_node_t *)lim_mgmt_regn))
4078 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304079 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004080 }
4081
4082 if (sme_req->registerFrame) {
4083 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304084 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004085 sme_req->matchLen);
4086 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004087 lim_mgmt_regn->frameType = sme_req->frameType;
4088 lim_mgmt_regn->matchLen = sme_req->matchLen;
4089 lim_mgmt_regn->sessionId = sme_req->sessionId;
4090 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304091 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004092 sme_req->matchData,
4093 sme_req->matchLen);
4094 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304095 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004096 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304097 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004098 gLimMgmtFrameRegistratinQueue,
4099 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304100 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004101 &mac_ctx->lim.lim_frame_register_lock);
4102 }
4103 }
4104 return;
4105}
4106
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004107static void
4108__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4109{
4110 tpSirResetAPCapsChange pResetCapsChange;
4111 tpPESession psessionEntry;
4112 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004113
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004114 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004115 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004116 return;
4117 }
4118
4119 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4120 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004121 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4122 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004123 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004124 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004125 return;
4126 }
4127
4128 psessionEntry->limSentCapsChangeNtf = false;
4129 return;
4130}
4131
4132/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304133 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4134 * indication callback in PE.
4135 * @mac_ptr: Mac pointer
4136 * @msg_buf: Msg pointer containing the callback
4137 *
4138 * This function is used save the Management frame
4139 * indication callback in PE.
4140 *
4141 * Return: None
4142 */
4143static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4144 uint32_t *msg_buf)
4145{
4146 struct sir_sme_mgmt_frame_cb_req *sme_req =
4147 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4148
4149 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004150 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304151 return;
4152 }
4153 if (sme_req->callback)
4154 mac_ctx->mgmt_frame_ind_cb =
4155 (sir_mgmt_frame_ind_callback)sme_req->callback;
4156 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004157 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304158}
4159
4160/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304161 *__lim_process_send_disassoc_frame: function processes disassoc frame
4162 * @mac_ctx: pointer to mac context
4163 * @msg_buf: message buffer
4164 *
4165 * function processes disassoc request received from SME
4166 *
4167 * return: none
4168 */
4169static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4170 uint32_t *msg_buf)
4171{
4172 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4173 tSirRetStatus status;
4174 tpPESession session_entry = NULL;
4175 uint8_t sme_session_id;
4176 uint16_t sme_trans_id;
4177
4178 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004179 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304180 return;
4181 }
4182
4183 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4184 &sme_trans_id);
4185
4186 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4187 &sme_send_disassoc_frame_req,
4188 (uint8_t *)msg_buf);
4189
4190 if ((eSIR_FAILURE == status) ||
4191 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4192 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004193 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304194 return;
4195 }
4196
4197 session_entry = pe_find_session_by_sme_session_id(
4198 mac_ctx, sme_session_id);
4199 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004200 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304201 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4202 return;
4203 }
4204
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004205 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 +05304206 sme_send_disassoc_frame_req.msg_type,
4207 sme_send_disassoc_frame_req.length,
4208 sme_send_disassoc_frame_req.session_id,
4209 sme_send_disassoc_frame_req.trans_id,
4210 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4211 sme_send_disassoc_frame_req.reason,
4212 sme_send_disassoc_frame_req.wait_for_ack);
4213
4214 lim_send_disassoc_mgmt_frame(mac_ctx,
4215 sme_send_disassoc_frame_req.reason,
4216 sme_send_disassoc_frame_req.peer_mac,
4217 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4218}
4219
4220/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004221 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4222 * @mac_ctx: Pointer to Global MAC structure
4223 * @pdev_id: pdev id to set the IE.
4224 * @nss: Nss values to prepare the HT IE.
4225 *
4226 * Prepares the HT IE with self capabilities for different
4227 * Nss values and sends the set HT IE req to FW.
4228 *
4229 * Return: None
4230 */
4231static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4232 uint8_t nss)
4233{
4234 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004235 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004236 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004237 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004238 tHtCaps *p_ht_cap;
4239 int i;
4240
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004241 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004242 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4243 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004244 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004245 return;
4246 }
4247 ie_params->nss = i;
4248 ie_params->pdev_id = pdev_id;
4249 ie_params->ie_type = DOT11_HT_IE;
4250 /* 2 for IE len and EID */
4251 ie_params->ie_len = 2 + sizeof(tHtCaps);
4252 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4253 if (NULL == ie_params->ie_ptr) {
4254 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004255 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004256 return;
4257 }
4258 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4259 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4260 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4261 ie_params->ie_len);
4262
4263 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004264 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4265 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004266 if (NULL == p_ie) {
4267 qdf_mem_free(ie_params->ie_ptr);
4268 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004269 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004270 return;
4271 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004272 p_ht_cap = (tHtCaps *)&p_ie[2];
4273 p_ht_cap->supportedMCSSet[1] = 0;
4274 p_ht_cap->txSTBC = 0;
4275 }
4276
4277 msg.type = WMA_SET_PDEV_IE_REQ;
4278 msg.bodyptr = ie_params;
4279 msg.bodyval = 0;
4280
4281 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4282 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004283 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004284 qdf_mem_free(ie_params->ie_ptr);
4285 qdf_mem_free(ie_params);
4286 return;
4287 }
4288 }
4289}
4290
4291/**
4292 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4293 * @mac_ctx: Pointer to Global MAC structure
4294 * @pdev_id: pdev id to set the IE.
4295 * @nss: Nss values to prepare the VHT IE.
4296 *
4297 * Prepares the VHT IE with self capabilities for different
4298 * Nss values and sends the set VHT IE req to FW.
4299 *
4300 * Return: None
4301 */
4302static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4303 uint8_t nss)
4304{
4305 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004306 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004307 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004308 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004309 tSirMacVHTCapabilityInfo *vht_cap;
4310 int i;
4311 tSirVhtMcsInfo *vht_mcs;
4312
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004313 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004314 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4315 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004316 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004317 return;
4318 }
4319 ie_params->nss = i;
4320 ie_params->pdev_id = pdev_id;
4321 ie_params->ie_type = DOT11_VHT_IE;
4322 /* 2 for IE len and EID */
4323 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4324 sizeof(tSirVhtMcsInfo);
4325 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4326 if (NULL == ie_params->ie_ptr) {
4327 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004328 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004329 return;
4330 }
4331 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4332 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4333 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4334 ie_params->ie_len);
4335
4336 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004337 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4338 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004339 if (NULL == p_ie) {
4340 qdf_mem_free(ie_params->ie_ptr);
4341 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004342 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004343 return;
4344 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004345 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4346 vht_cap->txSTBC = 0;
4347 vht_mcs =
4348 (tSirVhtMcsInfo *)&p_ie[2 +
4349 sizeof(tSirMacVHTCapabilityInfo)];
4350 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4351 vht_mcs->rxHighest =
4352 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4353 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4354 vht_mcs->txHighest =
4355 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4356 }
4357 msg.type = WMA_SET_PDEV_IE_REQ;
4358 msg.bodyptr = ie_params;
4359 msg.bodyval = 0;
4360
4361 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4362 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004363 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004364 qdf_mem_free(ie_params->ie_ptr);
4365 qdf_mem_free(ie_params);
4366 return;
4367 }
4368 }
4369}
4370
4371/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004372 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4373 * @mac_ctx: Pointer to Global MAC structure
4374 * @msg_buf: Pointer to the SME message buffer
4375 *
4376 * This function is called by limProcessMessageQueue(). This function sets the
4377 * VDEV IEs to the FW.
4378 *
4379 * Return: None
4380 */
4381static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4382 uint32_t *msg_buf)
4383{
4384 struct sir_set_vdev_ies_per_band *p_msg =
4385 (struct sir_set_vdev_ies_per_band *)msg_buf;
4386
4387 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004388 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004389 return;
4390 }
4391
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004392 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004393 p_msg->vdev_id);
4394 /* intentionally using NULL here so that self capabilty are sent */
4395 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4396 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004397 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004398}
4399
4400/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004401 * lim_process_set_pdev_IEs() - process the set pdev IE req
4402 * @mac_ctx: Pointer to Global MAC structure
4403 * @msg_buf: Pointer to the SME message buffer
4404 *
4405 * This function is called by limProcessMessageQueue(). This
4406 * function sets the PDEV IEs to the FW.
4407 *
4408 * Return: None
4409 */
4410static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4411{
4412 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4413
4414 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4415
4416 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004417 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004418 return;
4419 }
4420
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004421 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004422 ht_vht_cfg->nss);
4423 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4424
4425 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4426 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4427 ht_vht_cfg->nss);
4428}
4429
4430/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304431 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4432 *
4433 * access policy
4434 * @mac_ctx: pointer to mac context
4435 * @msg: message buffer
4436 *
4437 * function processes vendor IE and access policy from SME and updates PE
4438 *
4439 * session entry
4440 *
4441 * return: none
4442*/
4443static void lim_process_sme_update_access_policy_vendor_ie(
4444 tpAniSirGlobal mac_ctx,
4445 uint32_t *msg)
4446{
4447 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4448 struct sPESession *pe_session_entry;
4449 uint8_t num_bytes;
4450
4451 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004452 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304453 return;
4454 }
4455 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4456 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4457 update_vendor_ie->sme_session_id);
4458
4459 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004460 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304461 update_vendor_ie->sme_session_id);
4462 return;
4463 }
4464 if (pe_session_entry->access_policy_vendor_ie)
4465 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4466
4467 num_bytes = update_vendor_ie->ie[1] + 2;
4468 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4469
4470 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004471 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304472 return;
4473 }
4474 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4475 &update_vendor_ie->ie[0], num_bytes);
4476
4477 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4478}
4479
4480/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004481 * lim_process_sme_req_messages()
4482 *
4483 ***FUNCTION:
4484 * This function is called by limProcessMessageQueue(). This
4485 * function processes SME request messages from HDD or upper layer
4486 * application.
4487 *
4488 ***LOGIC:
4489 *
4490 ***ASSUMPTIONS:
4491 *
4492 ***NOTE:
4493 *
4494 * @param pMac Pointer to Global MAC structure
4495 * @param msgType Indicates the SME message type
4496 * @param *pMsgBuf A pointer to the SME message buffer
4497 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4498 * false - if pMsgBuf is not to be freed.
4499 */
4500
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004501bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4502 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004503{
4504 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
4505 uint32_t *pMsgBuf = pMsg->bodyptr;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004506
4507 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004508 lim_msg_str(pMsg->type), pMsg->type,
4509 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4510 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004511
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004512 /* If no insert NOA required then execute the code below */
4513
4514 switch (pMsg->type) {
4515 case eWNI_SME_SYS_READY_IND:
4516 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4517 break;
4518
4519 case eWNI_SME_START_BSS_REQ:
4520 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4521 break;
4522
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004523 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4524 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4525 break;
4526 case eWNI_SME_JOIN_REQ:
4527 __lim_process_sme_join_req(pMac, pMsgBuf);
4528 break;
4529
4530 case eWNI_SME_REASSOC_REQ:
4531 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4532 break;
4533
4534 case eWNI_SME_DISASSOC_REQ:
4535 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4536 break;
4537
4538 case eWNI_SME_DISASSOC_CNF:
4539 case eWNI_SME_DEAUTH_CNF:
4540 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4541 break;
4542
4543 case eWNI_SME_DEAUTH_REQ:
4544 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4545 break;
4546
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304547 case eWNI_SME_SEND_DISASSOC_FRAME:
4548 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4549 break;
4550
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004551 case eWNI_SME_SETCONTEXT_REQ:
4552 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4553 break;
4554
4555 case eWNI_SME_STOP_BSS_REQ:
4556 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4557 break;
4558
4559 case eWNI_SME_ASSOC_CNF:
4560 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004561 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004562 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4563 pMsgBuf);
4564 break;
4565
4566 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004567 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004568 __lim_process_sme_addts_req(pMac, pMsgBuf);
4569 break;
4570
4571 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004572 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004573 __lim_process_sme_delts_req(pMac, pMsgBuf);
4574 break;
4575
4576 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004577 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004578 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4579 break;
4580
4581 case eWNI_SME_GET_STATISTICS_REQ:
4582 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4583 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4584 bufConsumed = false;
4585 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004586#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004587 case eWNI_SME_GET_TSM_STATS_REQ:
4588 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4589 bufConsumed = false;
4590 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004591#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004592 case eWNI_SME_GET_ASSOC_STAS_REQ:
4593 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4594 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304595 case eWNI_SME_SESSION_UPDATE_PARAM:
4596 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004597 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304598 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4599 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4600 bufConsumed = false;
4601 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004602 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4603 /* Update the beaconInterval */
4604 __lim_process_sme_change_bi(pMac, pMsgBuf);
4605 break;
4606
4607#ifdef QCA_HT_2040_COEX
4608 case eWNI_SME_SET_HT_2040_MODE:
4609 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4610 break;
4611#endif
4612
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004613 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4614 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4615 __lim_process_report_message(pMac, pMsg);
4616 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004617
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004618 case eWNI_SME_FT_PRE_AUTH_REQ:
4619 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4620 break;
4621 case eWNI_SME_FT_UPDATE_KEY:
4622 lim_process_ft_update_key(pMac, pMsgBuf);
4623 break;
4624
4625 case eWNI_SME_FT_AGGR_QOS_REQ:
4626 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4627 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004628
4629 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4630 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4631 break;
4632#ifdef FEATURE_WLAN_TDLS
4633 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4634 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4635 break;
4636 case eWNI_SME_TDLS_ADD_STA_REQ:
4637 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4638 break;
4639 case eWNI_SME_TDLS_DEL_STA_REQ:
4640 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4641 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004642#endif
4643 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4644 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4645 break;
4646
4647 case eWNI_SME_CHANNEL_CHANGE_REQ:
4648 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4649 break;
4650
4651 case eWNI_SME_START_BEACON_REQ:
4652 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4653 break;
4654
4655 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4656 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4657 break;
4658
4659 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4660 lim_process_update_add_ies(pMac, pMsgBuf);
4661 break;
4662
4663 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4664 lim_process_modify_add_ies(pMac, pMsgBuf);
4665 break;
4666 case eWNI_SME_SET_HW_MODE_REQ:
4667 lim_process_set_hw_mode(pMac, pMsgBuf);
4668 break;
4669 case eWNI_SME_NSS_UPDATE_REQ:
4670 lim_process_nss_update_request(pMac, pMsgBuf);
4671 break;
4672 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4673 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4674 break;
4675 case eWNI_SME_SET_IE_REQ:
4676 lim_process_set_ie_req(pMac, pMsgBuf);
4677 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304678 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4679 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
4680 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304681 case eWNI_SME_EXT_CHANGE_CHANNEL:
4682 lim_process_ext_change_channel(pMac, pMsgBuf);
4683 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08004684 case eWNI_SME_SET_ANTENNA_MODE_REQ:
4685 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
4686 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004687 case eWNI_SME_PDEV_SET_HT_VHT_IE:
4688 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07004689 break;
4690 case eWNI_SME_SET_VDEV_IES_PER_BAND:
4691 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
4692 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304693 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
4694 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
4695 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07004696 case eWNI_SME_UPDATE_CONFIG:
4697 lim_process_sme_update_config(pMac,
4698 (struct update_config *)pMsgBuf);
4699 break;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004700 case eWNI_SME_SET_ADDBA_ACCEPT:
4701 lim_process_sme_set_addba_accept(pMac,
4702 (struct sme_addba_accept *)pMsgBuf);
4703 break;
Arif Hussaineb8ba362018-03-07 19:15:13 -08004704 case eWNI_SME_UPDATE_EDCA_PROFILE:
4705 lim_process_sme_update_edca_params(pMac, pMsg->bodyval);
4706 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004707 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304708 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004709 pMsg->bodyptr = NULL;
4710 break;
4711 } /* switch (msgType) */
4712
4713 return bufConsumed;
4714} /*** end lim_process_sme_req_messages() ***/
4715
4716/**
4717 * lim_process_sme_start_beacon_req()
4718 *
4719 ***FUNCTION:
4720 * This function is called by limProcessMessageQueue(). This
4721 * function processes SME request messages from HDD or upper layer
4722 * application.
4723 *
4724 ***LOGIC:
4725 *
4726 ***ASSUMPTIONS:
4727 *
4728 ***NOTE:
4729 *
4730 * @param pMac Pointer to Global MAC structure
4731 * @param msgType Indicates the SME message type
4732 * @param *pMsgBuf A pointer to the SME message buffer
4733 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4734 * false - if pMsgBuf is not to be freed.
4735 */
4736static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
4737{
4738 tpSirStartBeaconIndication pBeaconStartInd;
4739 tpPESession psessionEntry;
4740 uint8_t sessionId; /* PE sessionID */
4741
4742 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004743 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004744 return;
4745 }
4746
4747 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
4748 psessionEntry = pe_find_session_by_bssid(pMac,
4749 pBeaconStartInd->bssid,
4750 &sessionId);
4751 if (psessionEntry == NULL) {
4752 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004753 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004754 return;
4755 }
4756
4757 if (pBeaconStartInd->beaconStartStatus == true) {
4758 /*
4759 * Currently this Indication comes from SAP
4760 * to start Beacon Tx on a DFS channel
4761 * since beaconing has to be done on DFS
4762 * channel only after CAC WAIT is completed.
4763 * On a DFS Channel LIM does not start beacon
4764 * Tx right after the WMA_ADD_BSS_RSP.
4765 */
4766 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05304767 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004768 FL("Start Beacon with ssid %s Ch %d"),
4769 psessionEntry->ssId.ssId,
4770 psessionEntry->currentOperChannel);
4771 lim_send_beacon_ind(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08004772 lim_enable_obss_detection_config(pMac, psessionEntry);
Arif Hussain05fb4872018-01-03 16:02:55 -08004773 lim_send_obss_color_collision_cfg(pMac, psessionEntry,
4774 OBSS_COLOR_COLLISION_DETECTION);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004775 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004776 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004777 return;
4778 }
4779}
4780
4781/**
4782 * lim_process_sme_channel_change_request() - process sme ch change req
4783 *
4784 * @mac_ctx: Pointer to Global MAC structure
4785 * @msg_buf: pointer to the SME message buffer
4786 *
4787 * This function is called to process SME_CHANNEL_CHANGE_REQ message
4788 *
4789 * Return: None
4790 */
4791static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
4792 uint32_t *msg_buf)
4793{
4794 tpSirChanChangeRequest ch_change_req;
4795 tpPESession session_entry;
4796 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07004797 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004798 uint32_t val = 0;
4799
4800 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004801 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004802 return;
4803 }
4804 ch_change_req = (tpSirChanChangeRequest)msg_buf;
4805
4806 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
4807 ch_change_req->targetChannel);
4808
4809 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
4810 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004811 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004812 return;
4813 }
4814
4815 session_entry = pe_find_session_by_bssid(mac_ctx,
4816 ch_change_req->bssid, &session_id);
4817 if (session_entry == NULL) {
4818 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004819 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004820 return;
4821 }
4822
Manjunathappa Prakash34fda792018-02-07 18:23:42 -08004823 if ((session_entry->currentOperChannel ==
4824 ch_change_req->targetChannel) &&
4825 (session_entry->ch_width == ch_change_req->ch_width)) {
4826 pe_err("Target channel and mode is same as current channel and mode channel %d and mode %d",
4827 session_entry->currentOperChannel, session_entry->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004828 return;
4829 }
4830
4831 if (LIM_IS_AP_ROLE(session_entry))
4832 session_entry->channelChangeReasonCode =
4833 LIM_SWITCH_CHANNEL_SAP_DFS;
4834 else
4835 session_entry->channelChangeReasonCode =
4836 LIM_SWITCH_CHANNEL_OPERATION;
4837
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004838 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004839 session_entry->currentOperChannel,
4840 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004841 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004842
4843 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004844 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004845 session_entry->ch_center_freq_seg0 =
4846 ch_change_req->center_freq_seg_0;
4847 session_entry->ch_center_freq_seg1 =
4848 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004849 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004850 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08004851 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004852 session_entry->htRecommendedTxWidthSet =
4853 session_entry->htSupportedChannelWidthSet;
4854 session_entry->currentOperChannel =
4855 ch_change_req->targetChannel;
4856 session_entry->limRFBand =
4857 lim_get_rf_band(session_entry->currentOperChannel);
4858 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08004859 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004860 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004861 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
4862 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004863 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004864 }
4865
4866 session_entry->lim11hEnable = val;
4867 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304868 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004869 &ch_change_req->operational_rateset,
4870 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304871 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004872 &ch_change_req->extended_rateset,
4873 sizeof(session_entry->extRateSet));
4874 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
4875 session_entry->ch_center_freq_seg0,
4876 session_entry->ch_center_freq_seg1,
4877 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07004878 max_tx_pwr, session_entry->peSessionId,
4879 ch_change_req->cac_duration_ms,
4880 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004881}
4882
4883/******************************************************************************
4884* lim_start_bss_update_add_ie_buffer()
4885*
4886***FUNCTION:
4887* This function checks the src buffer and its length and then malloc for
4888* dst buffer update the same
4889*
4890***LOGIC:
4891*
4892***ASSUMPTIONS:
4893*
4894***NOTE:
4895*
4896* @param pMac Pointer to Global MAC structure
4897* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
4898* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
4899* @param *pSrcData_buff A pointer of uint8_t src buffer
4900* @param srcDataLen src buffer length
4901******************************************************************************/
4902
4903static void
4904lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
4905 uint8_t **pDstData_buff,
4906 uint16_t *pDstDataLen,
4907 uint8_t *pSrcData_buff, uint16_t srcDataLen)
4908{
4909
4910 if (srcDataLen > 0 && pSrcData_buff != NULL) {
4911 *pDstDataLen = srcDataLen;
4912
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304913 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004914
4915 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004916 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004917 return;
4918 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304919 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004920 } else {
4921 *pDstData_buff = NULL;
4922 *pDstDataLen = 0;
4923 }
4924}
4925
4926/******************************************************************************
4927* lim_update_add_ie_buffer()
4928*
4929***FUNCTION:
4930* This function checks the src buffer and length if src buffer length more
4931* than dst buffer length then free the dst buffer and malloc for the new src
4932* length, and update the dst buffer and length. But if dst buffer is bigger
4933* than src buffer length then it just update the dst buffer and length
4934*
4935***LOGIC:
4936*
4937***ASSUMPTIONS:
4938*
4939***NOTE:
4940*
4941* @param pMac Pointer to Global MAC structure
4942* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
4943* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
4944* @param *pSrcData_buff A pointer of uint8_t src buffer
4945* @param srcDataLen src buffer length
4946******************************************************************************/
4947
4948static void
4949lim_update_add_ie_buffer(tpAniSirGlobal pMac,
4950 uint8_t **pDstData_buff,
4951 uint16_t *pDstDataLen,
4952 uint8_t *pSrcData_buff, uint16_t srcDataLen)
4953{
4954
4955 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004956 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004957 return;
4958 }
4959
4960 if (srcDataLen > *pDstDataLen) {
4961 *pDstDataLen = srcDataLen;
4962 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304963 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004964 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304965 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004966
4967 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004968 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004969 *pDstDataLen = 0;
4970 return;
4971 }
4972 }
4973
4974 /* copy the content of buffer into dst buffer
4975 */
4976 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304977 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004978
4979}
4980
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004981/**
4982 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
4983 * @pMac : Pointer to Global MAC structure
4984 * @pDstData_buff : A pointer to pointer of dst buffer
4985 * @pDstDataLen : A pointer to pointer of dst buffer length
4986 * @pModifyIE : A pointer to tSirModifyIE
4987 *
4988 * This function replaces previous ibss prop_ie with new ibss prop_ie.
4989 *
4990 * Return:
4991 * True or false depending upon whether IE is updated or not
4992 */
4993static bool
4994lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
4995 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
4996{
Hong Shi1553d692016-09-28 12:16:19 +08004997 int32_t oui_length;
4998 uint8_t *ibss_ie = NULL;
4999 uint8_t *vendor_ie;
5000#define MAC_VENDOR_OUI "\x00\x16\x32"
5001#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005002
5003 ibss_ie = pModifyIE->pIEBuffer;
5004 oui_length = pModifyIE->oui_length;
5005
5006 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005007 pe_err("Invalid set IBSS vendor IE command length %d",
5008 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005009 return false;
5010 }
5011
Hong Shi1553d692016-09-28 12:16:19 +08005012 /*
5013 * Why replace only beacon OUI data here:
5014 * 1. other ie (such as wpa) shall not be overwritten here.
5015 * 2. per spec, beacon oui ie might be set twice and original one
5016 * shall be updated.
5017 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005018 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005019 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5020 if (vendor_ie) {
5021 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5022 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5023 pModifyIE->ieBufferlength);
5024 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005025 uint16_t new_length;
5026 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005027
Naveen Rawat668dee32017-09-29 14:39:40 -07005028 /*
5029 * check for uint16 overflow before using sum of two numbers as
5030 * length of size to malloc
5031 */
5032 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5033 pe_err("U16 overflow due to %d + %d",
5034 pModifyIE->ieBufferlength, *pDstDataLen);
5035 return false;
5036 }
5037
5038 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5039 new_ptr = qdf_mem_malloc(new_length);
Hong Shi1553d692016-09-28 12:16:19 +08005040 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005041 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005042 return false;
5043 }
5044 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5045 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5046 pModifyIE->ieBufferlength);
5047 qdf_mem_free(*pDstData_buff);
5048 *pDstDataLen = new_length;
5049 *pDstData_buff = new_ptr;
5050 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005051 return true;
5052}
5053
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005054/*
5055* lim_process_modify_add_ies() - process modify additional IE req.
5056*
5057* @mac_ctx: Pointer to Global MAC structure
5058* @msg_buf: pointer to the SME message buffer
5059*
5060* This function update the PE buffers for additional IEs.
5061*
5062* Return: None
5063*/
5064static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5065 uint32_t *msg_buf)
5066{
5067 tpSirModifyIEsInd modify_add_ies;
5068 tpPESession session_entry;
5069 uint8_t session_id;
5070 bool ret = false;
5071 tSirAddIeParams *add_ie_params;
5072
5073 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005074 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005075 return;
5076 }
5077
5078 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5079 /* Incoming message has smeSession, use BSSID to find PE session */
5080 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005081 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005082
5083 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005084 pe_err("Session not found for given bssid"
5085 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005086 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005087 goto end;
5088 }
5089 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5090 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5091 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005092 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005093 modify_add_ies->modifyIE.pIEBuffer,
5094 modify_add_ies->modifyIE.ieBufferlength,
5095 modify_add_ies->modifyIE.ieID,
5096 modify_add_ies->modifyIE.ieIDLen,
5097 modify_add_ies->updateType);
5098 goto end;
5099 }
5100 add_ie_params = &session_entry->addIeParams;
5101 switch (modify_add_ies->updateType) {
5102 case eUPDATE_IE_PROBE_RESP:
5103 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005104 if (LIM_IS_IBSS_ROLE(session_entry)) {
5105 lim_update_ibss_prop_add_ies(mac_ctx,
5106 &add_ie_params->probeRespData_buff,
5107 &add_ie_params->probeRespDataLen,
5108 &modify_add_ies->modifyIE);
5109 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005110 break;
5111 case eUPDATE_IE_ASSOC_RESP:
5112 /* assoc resp IE */
5113 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305114 QDF_TRACE(QDF_MODULE_ID_PE,
5115 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005116 "assoc resp add ie not present %d"),
5117 add_ie_params->assocRespDataLen);
5118 }
5119 /* search through the buffer and modify the IE */
5120 break;
5121 case eUPDATE_IE_PROBE_BCN:
5122 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005123 if (LIM_IS_IBSS_ROLE(session_entry)) {
5124 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5125 &add_ie_params->probeRespBCNData_buff,
5126 &add_ie_params->probeRespBCNDataLen,
5127 &modify_add_ies->modifyIE);
5128 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005129 if (ret == true && modify_add_ies->modifyIE.notify) {
5130 lim_handle_param_update(mac_ctx,
5131 modify_add_ies->updateType);
5132 }
5133 break;
5134 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005135 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005136 modify_add_ies->updateType);
5137 break;
5138 }
5139end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305140 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005141 modify_add_ies->modifyIE.pIEBuffer = NULL;
5142}
5143
5144/*
5145* lim_process_update_add_ies() - process additional IE update req
5146*
5147* @mac_ctx: Pointer to Global MAC structure
5148* @msg_buf: pointer to the SME message buffer
5149*
5150* This function update the PE buffers for additional IEs.
5151*
5152* Return: None
5153*/
5154static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5155 uint32_t *msg_buf)
5156{
5157 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5158 uint8_t session_id;
5159 tpPESession session_entry;
5160 tSirAddIeParams *addn_ie;
5161 uint16_t new_length = 0;
5162 uint8_t *new_ptr = NULL;
5163 tSirUpdateIE *update_ie;
5164
5165 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005166 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005167 return;
5168 }
5169 update_ie = &update_add_ies->updateIE;
5170 /* incoming message has smeSession, use BSSID to find PE session */
5171 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005172 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005173
5174 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005175 pe_err("Session not found for given bssid"
5176 MAC_ADDRESS_STR,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005177 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005178 goto end;
5179 }
5180 addn_ie = &session_entry->addIeParams;
5181 /* if len is 0, upper layer requested freeing of buffer */
5182 if (0 == update_ie->ieBufferlength) {
5183 switch (update_add_ies->updateType) {
5184 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305185 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005186 addn_ie->probeRespData_buff = NULL;
5187 addn_ie->probeRespDataLen = 0;
5188 break;
5189 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305190 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005191 addn_ie->assocRespData_buff = NULL;
5192 addn_ie->assocRespDataLen = 0;
5193 break;
5194 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305195 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005196 addn_ie->probeRespBCNData_buff = NULL;
5197 addn_ie->probeRespBCNDataLen = 0;
5198
5199 if (update_ie->notify)
5200 lim_handle_param_update(mac_ctx,
5201 update_add_ies->updateType);
5202 break;
5203 default:
5204 break;
5205 }
5206 return;
5207 }
5208 switch (update_add_ies->updateType) {
5209 case eUPDATE_IE_PROBE_RESP:
5210 if (update_ie->append) {
5211 /*
5212 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005213 * with combined length.
5214 * Multiple back to back append commands
5215 * can lead to a huge length.So, check
5216 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005217 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005218 if (addn_ie->probeRespDataLen >
5219 (USHRT_MAX - update_ie->ieBufferlength)) {
5220 pe_err("IE Length overflow, curr:%d, new:%d",
5221 addn_ie->probeRespDataLen,
5222 update_ie->ieBufferlength);
5223 goto end;
5224 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005225 new_length = update_ie->ieBufferlength +
5226 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305227 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005228 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005229 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005230 goto end;
5231 }
5232 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305233 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005234 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305235 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005236 update_ie->pAdditionIEBuffer,
5237 update_ie->ieBufferlength);
5238 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305239 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005240 /* adjust length accordingly */
5241 addn_ie->probeRespDataLen = new_length;
5242 /* save refernece of local buffer in PE session */
5243 addn_ie->probeRespData_buff = new_ptr;
5244 goto end;
5245 }
5246 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5247 &addn_ie->probeRespDataLen,
5248 update_ie->pAdditionIEBuffer,
5249 update_ie->ieBufferlength);
5250 break;
5251 case eUPDATE_IE_ASSOC_RESP:
5252 /* assoc resp IE */
5253 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5254 &addn_ie->assocRespDataLen,
5255 update_ie->pAdditionIEBuffer,
5256 update_ie->ieBufferlength);
5257 break;
5258 case eUPDATE_IE_PROBE_BCN:
5259 /* probe resp Bcn IE */
5260 lim_update_add_ie_buffer(mac_ctx,
5261 &addn_ie->probeRespBCNData_buff,
5262 &addn_ie->probeRespBCNDataLen,
5263 update_ie->pAdditionIEBuffer,
5264 update_ie->ieBufferlength);
5265 if (update_ie->notify)
5266 lim_handle_param_update(mac_ctx,
5267 update_add_ies->updateType);
5268 break;
5269 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005270 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005271 break;
5272 }
5273end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305274 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005275 update_ie->pAdditionIEBuffer = NULL;
5276}
5277
5278/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305279 * send_extended_chan_switch_action_frame()- function to send ECSA
5280 * action frame for each sta connected to SAP/GO and AP in case of
5281 * STA .
5282 * @mac_ctx: pointer to global mac structure
5283 * @new_channel: new channel to switch to.
5284 * @ch_bandwidth: BW of channel to calculate op_class
5285 * @session_entry: pe session
5286 *
5287 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5288 *
5289 * Return: void
5290 */
5291
5292static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5293 uint16_t new_channel, uint8_t ch_bandwidth,
5294 tpPESession session_entry)
5295{
5296 uint16_t op_class;
5297 uint8_t switch_mode = 0, i;
5298 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005299 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305300
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005301 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305302 mac_ctx->scan.countryCodeCurrent,
5303 new_channel,
5304 ch_bandwidth);
5305
5306 if (LIM_IS_AP_ROLE(session_entry) &&
5307 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005308 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305309
gaoleze2920bd2017-03-21 17:38:42 +08005310 switch_count = session_entry->gLimChannelSwitch.switchCount;
5311
Abhishek Singh518323d2015-10-19 17:42:01 +05305312 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005313 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305314 psta =
5315 session_entry->dph.dphHashTable.pDphNodeArray + i;
5316 if (psta && psta->added)
5317 lim_send_extended_chan_switch_action_frame(
5318 mac_ctx,
5319 psta->staAddr,
5320 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005321 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305322 }
5323 } else if (LIM_IS_STA_ROLE(session_entry)) {
5324 lim_send_extended_chan_switch_action_frame(mac_ctx,
5325 session_entry->bssId,
5326 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005327 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305328 }
5329
5330}
5331
gaolez76d2a162017-03-21 19:23:58 +08005332void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5333 uint16_t new_channel,
5334 uint8_t ch_bandwidth,
5335 tpPESession session_entry)
5336{
5337 uint16_t op_class;
5338 uint8_t switch_mode = 0, i;
5339 uint8_t switch_count;
5340 tpDphHashNode psta;
5341 tpDphHashNode dph_node_array_ptr;
5342
5343 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5344
5345 op_class = wlan_reg_dmn_get_opclass_from_channel(
5346 mac_ctx->scan.countryCodeCurrent,
5347 new_channel, ch_bandwidth);
5348
5349 if (LIM_IS_AP_ROLE(session_entry) &&
5350 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5351 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5352
5353 switch_count = session_entry->gLimChannelSwitch.switchCount;
5354
5355 if (LIM_IS_AP_ROLE(session_entry)) {
5356 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5357 psta = dph_node_array_ptr + i;
5358 if (!(psta && psta->added))
5359 continue;
5360 if (session_entry->lim_non_ecsa_cap_num == 0)
5361 lim_send_extended_chan_switch_action_frame
5362 (mac_ctx, psta->staAddr, switch_mode,
5363 op_class, new_channel, switch_count,
5364 session_entry);
5365 else
5366 lim_send_channel_switch_mgmt_frame
5367 (mac_ctx, psta->staAddr, switch_mode,
5368 new_channel, switch_count,
5369 session_entry);
5370 }
5371 } else if (LIM_IS_STA_ROLE(session_entry)) {
5372 lim_send_extended_chan_switch_action_frame
5373 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5374 new_channel, switch_count, session_entry);
5375 }
5376}
5377
5378/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005379 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5380 *
5381 * @mac_ctx: Pointer to Global MAC structure
5382 * @msg_buf: pointer to the SME message buffer
5383 *
5384 * This function processes SME request messages from HDD or upper layer
5385 * application.
5386 *
5387 * Return: None
5388 */
5389static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5390 uint32_t *msg_buf)
5391{
5392 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5393 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005394 uint8_t session_id;
5395 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005396 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005397
5398 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005399 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005400 return;
5401 }
5402
5403 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5404 session_entry = pe_find_session_by_bssid(mac_ctx,
5405 dfs_csa_ie_req->bssid, &session_id);
5406 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005407 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005408 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5409 return;
5410 }
5411
5412 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005413 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005414 GET_LIM_SYSTEM_ROLE(session_entry));
5415 return;
5416 }
5417
5418 /* target channel */
5419 session_entry->gLimChannelSwitch.primaryChannel =
5420 dfs_csa_ie_req->targetChannel;
5421
5422 /* Channel switch announcement needs to be included in beacon */
5423 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005424 session_entry->gLimChannelSwitch.switchCount =
5425 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005426 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005427 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305428 session_entry->gLimChannelSwitch.sec_ch_offset =
5429 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005430 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005431 session_entry->gLimChannelSwitch.switchMode =
5432 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005433
5434 /*
5435 * Validate if SAP is operating HT or VHT mode and set the Channel
5436 * Switch Wrapper element with the Wide Band Switch subelement.
5437 */
5438 if (true != session_entry->vhtCapability)
5439 goto skip_vht;
5440
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005441 /* Now encode the Wider Ch BW element depending on the ch width */
5442 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005443 switch (dfs_csa_ie_req->ch_params.ch_width) {
5444 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005445 /*
5446 * Wide channel BW sublement in channel wrapper element is not
5447 * required in case of 20 Mhz operation. Currently It is set
5448 * only set in case of 40/80 Mhz Operation.
5449 */
5450 session_entry->dfsIncludeChanWrapperIe = false;
5451 wider_bw_ch_switch->newChanWidth =
5452 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5453 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005454 case CH_WIDTH_40MHZ:
5455 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005456 wider_bw_ch_switch->newChanWidth =
5457 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5458 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005459 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005460 session_entry->dfsIncludeChanWrapperIe = true;
5461 wider_bw_ch_switch->newChanWidth =
5462 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5463 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005464 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005465 session_entry->dfsIncludeChanWrapperIe = true;
5466 wider_bw_ch_switch->newChanWidth =
5467 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5468 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005469 case CH_WIDTH_80P80MHZ:
5470 session_entry->dfsIncludeChanWrapperIe = true;
5471 wider_bw_ch_switch->newChanWidth =
5472 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005473 /*
5474 * This is not applicable for 20/40/80 Mhz.
5475 * Only used when we support 80+80 Mhz operation.
5476 * In case of 80+80 Mhz, this parameter indicates
5477 * center channel frequency index of 80 Mhz channel of
5478 * frequency segment 1.
5479 */
5480 wider_bw_ch_switch->newCenterChanFreq1 =
5481 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005482 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005483 default:
5484 session_entry->dfsIncludeChanWrapperIe = false;
5485 /*
5486 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5487 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5488 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005489 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005490 break;
5491 }
5492 /* Fetch the center channel based on the channel width */
5493 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005494 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005495skip_vht:
5496 /* Send CSA IE request from here */
5497 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5498 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005499 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005500 return;
5501 }
5502
5503 /*
5504 * First beacon update request is sent here, the remaining updates are
5505 * done when the FW responds back after sending the first beacon after
5506 * the template update
5507 */
5508 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305509
5510 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5511 ch_offset = BW80;
5512 else
5513 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5514
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005515 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305516 session_entry->gLimChannelSwitch.switchCount,
5517 session_entry->gLimChannelSwitch.primaryChannel,
5518 session_entry->gLimChannelSwitch.ch_width,
5519 session_entry->dfsIncludeChanWrapperIe,
5520 ch_offset);
5521
gaolez76d2a162017-03-21 19:23:58 +08005522 /* Send ECSA/CSA Action frame after updating the beacon */
5523 if (CHAN_HOP_ALL_BANDS_ENABLE)
5524 lim_send_chan_switch_action_frame(mac_ctx,
5525 session_entry->gLimChannelSwitch.primaryChannel,
5526 ch_offset, session_entry);
5527 else
5528 send_extended_chan_switch_action_frame(mac_ctx,
5529 session_entry->gLimChannelSwitch.primaryChannel,
5530 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005531}
5532
5533/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305534 * lim_process_ext_change_channel()- function to send ECSA
5535 * action frame for STA/CLI .
5536 * @mac_ctx: pointer to global mac structure
5537 * @msg: params from sme for new channel.
5538 *
5539 * This function is called to send ECSA frame for STA/CLI.
5540 *
5541 * Return: void
5542 */
5543
5544static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5545 uint32_t *msg)
5546{
5547 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5548 (struct sir_sme_ext_cng_chan_req *) msg;
5549 tpPESession session_entry = NULL;
5550
5551 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005552 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305553 return;
5554 }
5555 session_entry =
5556 pe_find_session_by_sme_session_id(mac_ctx,
5557 ext_chng_channel->session_id);
5558 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005559 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305560 ext_chng_channel->session_id);
5561 return;
5562 }
5563 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005564 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305565 return;
5566 }
5567 send_extended_chan_switch_action_frame(mac_ctx,
5568 ext_chng_channel->new_channel,
5569 0, session_entry);
5570}
5571
5572/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005573 * lim_process_nss_update_request() - process sme nss update req
5574 *
5575 * @mac_ctx: Pointer to Global MAC structure
5576 * @msg_buf: pointer to the SME message buffer
5577 *
5578 * This function processes SME request messages from HDD or upper layer
5579 * application.
5580 *
5581 * Return: None
5582 */
5583static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5584 uint32_t *msg_buf)
5585{
5586 struct sir_nss_update_request *nss_update_req_ptr;
5587 tpPESession session_entry = NULL;
5588
5589 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005590 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005591 return;
5592 }
5593
5594 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305595 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005596 nss_update_req_ptr->vdev_id);
5597 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005598 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005599 nss_update_req_ptr->vdev_id);
5600 return;
5601 }
5602
5603 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005604 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005605 GET_LIM_SYSTEM_ROLE(session_entry));
5606 return;
5607 }
5608
5609 /* populate nss field in the beacon */
5610 session_entry->gLimOperatingMode.present = 1;
5611 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05305612 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
5613
5614 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
5615 (session_entry->ch_width > CH_WIDTH_80MHZ))
5616 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
5617
5618 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
5619
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005620 /* Send nss update request from here */
5621 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5622 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005623 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005624 return;
5625 }
5626
5627 lim_send_beacon_ind(mac_ctx, session_entry);
5628}
5629
5630/**
5631 * lim_process_set_ie_req() - process sme set IE request
5632 *
5633 * @mac_ctx: Pointer to Global MAC structure
5634 * @msg_buf: pointer to the SME message buffer
5635 *
5636 * This function processes SME request messages from HDD or upper layer
5637 * application.
5638 *
5639 * Return: None
5640 */
5641static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5642{
5643 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305644 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005645
5646 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005647 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005648 return;
5649 }
5650
5651 msg = (struct send_extcap_ie *)msg_buf;
5652 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305653 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005654 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005655
5656}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005657
5658#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Arif Hussain05fb4872018-01-03 16:02:55 -08005659
5660/**
5661 * obss_color_collision_process_color_disable() - Disable bss color
5662 * @mac_ctx: Pointer to Global MAC structure
5663 * @session: pointer to session
5664 *
5665 * This function will disbale bss color.
5666 *
5667 * Return: None
5668 */
5669static void obss_color_collision_process_color_disable(tpAniSirGlobal mac_ctx,
5670 tpPESession session)
5671{
5672 tUpdateBeaconParams beacon_params;
5673
5674 if (!session) {
5675 pe_err("Invalid session");
5676 return;
5677 }
5678
5679 if (session->valid && !LIM_IS_AP_ROLE(session)) {
5680 pe_err("Invalid SystemRole %d",
5681 GET_LIM_SYSTEM_ROLE(session));
5682 return;
5683 }
5684
5685 if (session->bss_color_changing == 1) {
5686 pe_warn("%d: color change in progress", session->smeSessionId);
5687 /* Continue color collision detection */
5688 lim_send_obss_color_collision_cfg(mac_ctx, session,
5689 OBSS_COLOR_COLLISION_DETECTION);
5690 return;
5691 }
5692
5693 if (session->he_op.bss_col_disabled == 1) {
5694 pe_warn("%d: bss color already disabled",
5695 session->smeSessionId);
5696 /* Continue free color detection */
5697 lim_send_obss_color_collision_cfg(mac_ctx, session,
5698 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5699 return;
5700 }
5701
5702 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5703 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5704 session->he_op.bss_col_disabled = 1;
Arif Hussain05fb4872018-01-03 16:02:55 -08005705 beacon_params.bss_color_disabled = 1;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005706 beacon_params.bss_color = session->he_op.bss_color;
Arif Hussain05fb4872018-01-03 16:02:55 -08005707
5708 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
5709 eSIR_SUCCESS) {
5710 pe_err("Unable to set op mode IE in beacon");
5711 return;
5712 }
5713
5714 lim_send_beacon_params(mac_ctx, &beacon_params, session);
5715 lim_send_obss_color_collision_cfg(mac_ctx, session,
5716 OBSS_COLOR_FREE_SLOT_AVAILABLE);
5717}
5718
5719/**
5720 * obss_color_collision_process_color_change() - Process bss color change
5721 * @mac_ctx: Pointer to Global MAC structure
5722 * @session: pointer to session
5723 * @obss_color_info: obss color collision/free slot indication info
5724 *
5725 * This function selects new color ib case of bss color collision.
5726 *
5727 * Return: None
5728 */
5729static void obss_color_collision_process_color_change(tpAniSirGlobal mac_ctx,
5730 tpPESession session,
5731 struct wmi_obss_color_collision_info *obss_color_info)
5732{
5733 int i, num_bss_color = 0;
5734 uint32_t bss_color_bitmap;
5735 uint8_t bss_color_index_array[MAX_BSS_COLOR_VALUE];
5736 uint32_t rand_byte = 0;
5737 struct sir_set_he_bss_color he_bss_color;
5738 bool is_color_collision = false;
5739
5740
5741 if (session->bss_color_changing == 1) {
5742 pe_err("%d: color change in progress", session->smeSessionId);
5743 return;
5744 }
5745
5746 if (!session->he_op.bss_col_disabled) {
5747 if (session->he_op.bss_color < 32)
5748 is_color_collision = (obss_color_info->
5749 obss_color_bitmap_bit0to31 >>
5750 session->he_op.bss_color) & 0x01;
5751 else
5752 is_color_collision = (obss_color_info->
5753 obss_color_bitmap_bit32to63 >>
5754 (session->he_op.bss_color -
5755 31)) & 0x01;
5756 if (!is_color_collision) {
5757 pe_err("%d: color collision not found, curr_color: %d",
5758 session->smeSessionId,
5759 session->he_op.bss_color);
5760 return;
5761 }
5762 }
5763
5764 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit0to31;
5765
5766 /* Skip color zero */
5767 bss_color_bitmap = bss_color_bitmap >> 1;
5768 for (i = 0; (i < 31) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5769 if (!(bss_color_bitmap & 0x01)) {
5770 bss_color_index_array[num_bss_color] = i + 1;
5771 num_bss_color++;
5772 }
5773 bss_color_bitmap = bss_color_bitmap >> 1;
5774 }
5775
5776 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit32to63;
5777 for (i = 0; (i < 32) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
5778 if (!(bss_color_bitmap & 0x01)) {
5779 bss_color_index_array[num_bss_color] = i + 32;
5780 num_bss_color++;
5781 }
5782 bss_color_bitmap = bss_color_bitmap >> 1;
5783 }
5784
5785 if (num_bss_color) {
5786 qdf_get_random_bytes((void *) &rand_byte, 1);
5787 i = (rand_byte + qdf_mc_timer_get_system_ticks()) %
5788 num_bss_color;
5789 pe_debug("New bss color = %d", bss_color_index_array[i]);
5790 he_bss_color.session_id = obss_color_info->vdev_id;
5791 he_bss_color.bss_color = bss_color_index_array[i];
5792 lim_process_set_he_bss_color(mac_ctx,
5793 (uint32_t *)&he_bss_color);
5794 } else {
5795 pe_err("Unable to find bss color from bitmasp");
5796 if (obss_color_info->evt_type ==
5797 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY &&
5798 session->obss_color_collision_dec_evt ==
5799 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
5800 /* In dot11BSSColorCollisionAPPeriod and
5801 * timer expired, time to disable bss color.
5802 */
5803 obss_color_collision_process_color_disable(mac_ctx,
5804 session);
5805 else
5806 /*
5807 * Enter dot11BSSColorCollisionAPPeriod period.
5808 */
5809 lim_send_obss_color_collision_cfg(mac_ctx, session,
5810 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY);
5811 }
5812}
5813
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005814void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5815{
5816 struct sir_set_he_bss_color *bss_color;
5817 tpPESession session_entry = NULL;
5818 tUpdateBeaconParams beacon_params;
5819
5820 if (!msg_buf) {
5821 pe_err("Buffer is Pointing to NULL");
5822 return;
5823 }
5824
5825 bss_color = (struct sir_set_he_bss_color *)msg_buf;
5826 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5827 bss_color->session_id);
5828 if (!session_entry) {
5829 pe_err("Session not found for given session_id %d",
5830 bss_color->session_id);
5831 return;
5832 }
5833
5834 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5835 pe_err("Invalid SystemRole %d",
5836 GET_LIM_SYSTEM_ROLE(session_entry));
5837 return;
5838 }
5839
5840 if (bss_color->bss_color == session_entry->he_op.bss_color) {
5841 pe_err("No change in BSS color, current BSS color %d",
5842 bss_color->bss_color);
5843 return;
5844 }
5845 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5846 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5847 session_entry->he_op.bss_col_disabled = 1;
5848 session_entry->he_bss_color_change.countdown =
5849 BSS_COLOR_SWITCH_COUNTDOWN;
5850 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08005851 beacon_params.bss_color_disabled = 1;
5852 beacon_params.bss_color = session_entry->he_op.bss_color;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005853 session_entry->bss_color_changing = 1;
5854
5855 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5856 eSIR_SUCCESS) {
5857 pe_err("Unable to set op mode IE in beacon");
5858 return;
5859 }
5860
5861 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
Arif Hussain05fb4872018-01-03 16:02:55 -08005862 lim_send_obss_color_collision_cfg(mac_ctx, session_entry,
5863 OBSS_COLOR_COLLISION_DETECTION_DISABLE);
5864}
5865
5866void lim_send_obss_color_collision_cfg(tpAniSirGlobal mac_ctx,
5867 tpPESession session,
5868 enum wmi_obss_color_collision_evt_type
5869 event_type)
5870{
5871 struct wmi_obss_color_collision_cfg_param *cfg_param;
5872 struct scheduler_msg msg = {0};
5873
5874 if (!session) {
5875 pe_err("Invalid session");
5876 return;
5877 }
5878
5879 if (!session->he_capable ||
5880 !session->is_session_obss_color_collision_det_enabled) {
5881 pe_debug("%d: obss color det not enabled, he_cap:%d, sup:%d:%d",
5882 session->smeSessionId, session->he_capable,
5883 session->is_session_obss_color_collision_det_enabled,
5884 mac_ctx->lim.global_obss_color_collision_det_offload);
5885 return;
5886 }
5887
5888 cfg_param = qdf_mem_malloc(sizeof(*cfg_param));
5889 if (!cfg_param) {
5890 pe_err("Failed to allocate memory");
5891 return;
5892 }
5893
5894 pe_debug("%d: sending event:%d", session->smeSessionId, event_type);
5895 qdf_mem_zero(cfg_param, sizeof(*cfg_param));
5896 cfg_param->vdev_id = session->smeSessionId;
5897 cfg_param->evt_type = event_type;
5898 if (LIM_IS_AP_ROLE(session))
5899 cfg_param->detection_period_ms =
5900 OBSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS;
5901 else
5902 cfg_param->detection_period_ms =
5903 OBSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS;
5904
5905 cfg_param->scan_period_ms = OBSS_COLOR_COLLISION_SCAN_PERIOD_MS;
5906 if (event_type == OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
5907 cfg_param->free_slot_expiry_time_ms =
5908 OBSS_COLOR_COLLISION_FREE_SLOT_EXPIRY_MS;
5909
5910 msg.type = WMA_OBSS_COLOR_COLLISION_REQ;
5911 msg.bodyptr = cfg_param;
5912 msg.reserved = 0;
5913
5914 if (QDF_IS_STATUS_ERROR(scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
5915 pe_err("Failed to post WMA_OBSS_COLOR_COLLISION_REQ to WMA");
5916 qdf_mem_free(cfg_param);
5917 } else {
5918 session->obss_color_collision_dec_evt = event_type;
5919 }
5920}
5921
5922void lim_process_obss_color_collision_info(tpAniSirGlobal mac_ctx,
5923 uint32_t *msg_buf)
5924{
5925 struct wmi_obss_color_collision_info *obss_color_info;
5926 tpPESession session;
5927
5928 if (!msg_buf) {
5929 pe_err("Buffer is Pointing to NULL");
5930 return;
5931 }
5932
5933 obss_color_info = (struct wmi_obss_color_collision_info *)msg_buf;
5934 session = pe_find_session_by_sme_session_id(mac_ctx,
5935 obss_color_info->vdev_id);
5936 if (!session) {
5937 pe_err("Session not found for given session_id %d",
5938 obss_color_info->vdev_id);
5939 return;
5940 }
5941
5942 pe_debug("vdev_id:%d, evt:%d:%d, 0to31:0x%x, 32to63:0x%x, cap:%d:%d:%d",
5943 obss_color_info->vdev_id,
5944 obss_color_info->evt_type,
5945 session->obss_color_collision_dec_evt,
5946 obss_color_info->obss_color_bitmap_bit0to31,
5947 obss_color_info->obss_color_bitmap_bit32to63,
5948 session->he_capable,
5949 session->is_session_obss_color_collision_det_enabled,
5950 mac_ctx->lim.global_obss_color_collision_det_offload);
5951
5952 if (!session->he_capable ||
5953 !session->is_session_obss_color_collision_det_enabled) {
5954 return;
5955 }
5956
5957 switch (obss_color_info->evt_type) {
5958 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
5959 pe_err("%d: FW disabled obss color det. he_cap:%d, sup:%d:%d",
5960 session->smeSessionId, session->he_capable,
5961 session->is_session_obss_color_collision_det_enabled,
5962 mac_ctx->lim.global_obss_color_collision_det_offload);
5963 session->is_session_obss_color_collision_det_enabled = false;
5964 return;
5965 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
5966 case OBSS_COLOR_COLLISION_DETECTION:
5967 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
5968 if (session->valid && !LIM_IS_AP_ROLE(session)) {
5969 pe_debug("Invalid System Role %d",
5970 GET_LIM_SYSTEM_ROLE(session));
5971 return;
5972 }
5973
5974 if (session->obss_color_collision_dec_evt !=
5975 obss_color_info->evt_type) {
5976 pe_debug("%d: Wrong event: %d, skiping",
5977 obss_color_info->vdev_id,
5978 obss_color_info->evt_type);
5979 return;
5980 }
5981 obss_color_collision_process_color_change(mac_ctx, session,
5982 obss_color_info);
5983 break;
5984 default:
5985 pe_err("%d: Invalid event type %d",
5986 obss_color_info->vdev_id, obss_color_info->evt_type);
5987 return;
5988 }
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005989}
5990#endif