blob: 9c3b75dceccf00630b88ff875d2f7eba3a86b2f7 [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_scan_req(tpAniSirGlobal, uint32_t *);
92static void __lim_process_sme_join_req(tpAniSirGlobal, uint32_t *);
93static void __lim_process_sme_reassoc_req(tpAniSirGlobal, uint32_t *);
94static void __lim_process_sme_disassoc_req(tpAniSirGlobal, uint32_t *);
95static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal, uint32_t *);
96static void __lim_process_sme_deauth_req(tpAniSirGlobal, uint32_t *);
97static void __lim_process_sme_set_context_req(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080098static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal,
99 struct scheduler_msg *pMsg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +0530100static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
101 uint32_t *msg_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800102static void lim_process_sme_channel_change_request(tpAniSirGlobal pMac,
103 uint32_t *pMsg);
104static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg);
105static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal pMac, uint32_t *pMsg);
106static void lim_process_nss_update_request(tpAniSirGlobal pMac, uint32_t *pMsg);
107static void lim_process_set_ie_req(tpAniSirGlobal pMac, uint32_t *pMsg);
108
109static void lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
110 uint8_t **pDstData_buff,
111 uint16_t *pDstDataLen,
112 uint8_t *pSrcData_buff,
113 uint16_t srcDataLen);
114
115static void lim_update_add_ie_buffer(tpAniSirGlobal pMac,
116 uint8_t **pDstData_buff,
117 uint16_t *pDstDataLen,
118 uint8_t *pSrcData_buff, uint16_t srcDataLen);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800119static bool lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac,
120 uint8_t **pDstData_buff,
121 uint16_t *pDstDataLen,
122 tSirModifyIE *pModifyIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800123static void lim_process_modify_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
124
125static void lim_process_update_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
126
Abhishek Singh518323d2015-10-19 17:42:01 +0530127static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
128 uint32_t *msg);
129
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800130/**
131 * lim_process_set_hw_mode() - Send set HW mode command to WMA
132 * @mac: Globacl MAC pointer
133 * @msg: Message containing the hw mode index
134 *
135 * Send the set HW mode command to WMA
136 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530137 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800138 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530139static QDF_STATUS lim_process_set_hw_mode(tpAniSirGlobal mac, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800140{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530141 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700142 struct scheduler_msg message = {0};
Tushnim Bhattacharyya66348bd2017-03-09 15:02:10 -0800143 struct policy_mgr_hw_mode *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800144 uint32_t len;
145 struct s_sir_set_hw_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700146 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800147 struct sir_set_hw_mode_resp *param;
148
149 buf = (struct s_sir_set_hw_mode *) msg;
150 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700151 pe_err("Set HW mode param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152 /* To free the active command list */
153 goto fail;
154 }
155
156 len = sizeof(*req_msg);
157
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530158 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700160 pe_err("qdf_mem_malloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800161 /* Free the active command list
162 * Probably the malloc is going to fail there as well?!
163 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530164 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800165 }
166
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800167 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530168 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800169 /* Other parameters are not needed for WMA */
170
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800171 message.bodyptr = req_msg;
172 message.type = SIR_HAL_PDEV_SET_HW_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800173
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700174 pe_debug("Posting SIR_HAL_SOC_SET_HW_MOD to WMA");
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800175 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530176 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700177 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800178 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530179 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800180 goto fail;
181 }
182 return status;
183fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530184 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800185 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700186 pe_err("HW mode resp failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530187 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800188 }
189 param->status = SET_HW_MODE_STATUS_ECANCELED;
190 param->cfgd_hw_mode_index = 0;
191 param->num_vdev_mac_entries = 0;
192 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
193 resp_msg.bodyptr = param;
194 resp_msg.bodyval = 0;
195 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530196 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800197}
198
199/**
200 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
201 * @mac: Global MAC pointer
202 * @msg: Message containing the dual mac config parameter
203 *
204 * Send the set dual mac config command to WMA
205 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530206 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800207 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530208static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800209 uint32_t *msg)
210{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530211 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700212 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800213 struct sir_dual_mac_config *req_msg;
214 uint32_t len;
215 struct sir_set_dual_mac_cfg *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700216 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800217 struct sir_dual_mac_config_resp *param;
218
219 buf = (struct sir_set_dual_mac_cfg *) msg;
220 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700221 pe_err("Set Dual mac config is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800222 /* To free the active command list */
223 goto fail;
224 }
225
226 len = sizeof(*req_msg);
227
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530228 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700230 pe_err("qdf_mem_malloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800231 /* Free the active command list
232 * Probably the malloc is going to fail there as well?!
233 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530234 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235 }
236
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800237 req_msg->scan_config = buf->set_dual_mac.scan_config;
238 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
239 /* Other parameters are not needed for WMA */
240
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800241 message.bodyptr = req_msg;
242 message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800243
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700244 pe_debug("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800245 req_msg->scan_config, req_msg->fw_mode_config);
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800246 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530247 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700248 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530250 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800251 goto fail;
252 }
253 return status;
254fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530255 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800256 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700257 pe_err("Dual mac config resp failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530258 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800259 }
260 param->status = SET_HW_MODE_STATUS_ECANCELED;
261 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
262 resp_msg.bodyptr = param;
263 resp_msg.bodyval = 0;
264 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530265 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800266}
267
268/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800269 * lim_process_set_antenna_mode_req() - Set antenna mode command
270 * to WMA
271 * @mac: Global MAC pointer
272 * @msg: Message containing the antenna mode parameter
273 *
274 * Send the set antenna mode command to WMA
275 *
276 * Return: QDF_STATUS_SUCCESS if message posting is successful
277 */
278static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
279 uint32_t *msg)
280{
281 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700282 struct scheduler_msg message = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800283 struct sir_antenna_mode_param *req_msg;
284 struct sir_set_antenna_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700285 struct scheduler_msg resp_msg = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800286 struct sir_antenna_mode_resp *param;
287
288 buf = (struct sir_set_antenna_mode *) msg;
289 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700290 pe_err("Set antenna mode is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800291 /* To free the active command list */
292 goto fail;
293 }
294
295 req_msg = qdf_mem_malloc(sizeof(*req_msg));
296 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700297 pe_err("qdf_mem_malloc failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800298 return QDF_STATUS_E_NOMEM;
299 }
300
301 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
302 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
303
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800304 message.bodyptr = req_msg;
305 message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800306
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700307 pe_debug("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800308 req_msg->num_rx_chains,
309 req_msg->num_tx_chains);
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800310 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800311 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700312 pe_err("scheduler_post_msg failed!(err=%d)",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800313 status);
314 qdf_mem_free(req_msg);
315 goto fail;
316 }
317 return status;
318fail:
319 param = qdf_mem_malloc(sizeof(*param));
320 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700321 pe_err("antenna mode resp failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800322 return QDF_STATUS_E_NOMEM;
323 }
324 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
325 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
326 resp_msg.bodyptr = param;
327 resp_msg.bodyval = 0;
328 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
329 return QDF_STATUS_SUCCESS;
330}
331
332/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800333 * __lim_fresh_scan_reqd() - determine if a fresh scan request must be issued.
334 * @mac_ctx: Pointer to Global MAC structure
335 * @return_fresh_results: Trigger fresh scan.
336 *
337 * PE will do fresh scan, if all of the active sessions are in
338 * good state (Link Est or BSS Started). If one of the sessions
339 * is not in one of the above states, then PE does not do fresh
340 * scan. If no session exists (scanning very first time),
341 * then PE will always do fresh scan if SME asks it to do that.
342 *
343 * Return: true for fresh scan results, false if in invalid state.
344 */
345static uint8_t
346__lim_fresh_scan_reqd(tpAniSirGlobal mac_ctx, uint8_t return_fresh_results)
347{
348 uint8_t valid_state = true;
349 int i;
350
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700351
352 pe_debug("gLimSmeState: %d, returnFreshResults 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800353 mac_ctx->lim.gLimSmeState, return_fresh_results);
354
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700355 if (mac_ctx->lim.gLimSmeState != eLIM_SME_IDLE_STATE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800356 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800357
358 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
Naveen Rawatb6a951a2016-06-21 15:02:37 -0700359
360 if (mac_ctx->lim.gpSession[i].valid == false)
361 continue;
362
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700363 pe_debug("session %d, bsstype %d, limSystemRole %d, limSmeState %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800364 i, mac_ctx->lim.gpSession[i].bssType,
365 mac_ctx->lim.gpSession[i].limSystemRole,
366 mac_ctx->lim.gpSession[i].limSmeState);
Naveen Rawatb6a951a2016-06-21 15:02:37 -0700367
368 if (mac_ctx->lim.gpSession[i].bssType == eSIR_NDI_MODE)
369 continue;
370
371 if (mac_ctx->lim.gpSession[i].bssType ==
372 eSIR_INFRASTRUCTURE_MODE &&
373 mac_ctx->lim.gpSession[i].limSmeState ==
374 eLIM_SME_LINK_EST_STATE)
375 continue;
376
377 if (mac_ctx->lim.gpSession[i].bssType == eSIR_IBSS_MODE &&
378 mac_ctx->lim.gpSession[i].limSmeState ==
379 eLIM_SME_NORMAL_STATE)
380 continue;
381
382 if (mac_ctx->lim.gpSession[i].bssType == eSIR_INFRA_AP_MODE &&
383 mac_ctx->lim.gpSession[i].pePersona ==
384 QDF_P2P_GO_MODE &&
385 mac_ctx->lim.gpSession[i].limSmeState ==
386 eLIM_SME_NORMAL_STATE)
387 continue;
388
389 if (mac_ctx->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE &&
390 mac_ctx->lim.gpSession[i].limSmeState ==
391 eLIM_SME_NORMAL_STATE)
392 continue;
393
394 valid_state = false;
395 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800396 }
397
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700398 pe_debug("valid_state: %d", valid_state);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800399
400 if ((valid_state) &&
401 (return_fresh_results & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
402 return true;
403 else
404 return false;
405}
406
407/**
408 * __lim_is_sme_assoc_cnf_valid()
409 *
410 ***FUNCTION:
411 * This function is called by __lim_process_sme_assoc_cnf_new() upon
412 * receiving SME_ASSOC_CNF.
413 *
414 ***LOGIC:
415 * Message validity checks are performed in this function
416 *
417 ***ASSUMPTIONS:
418 *
419 ***NOTE:
420 *
421 * @param pMeasReq Pointer to Received ASSOC_CNF message
422 * @return true When received SME_ASSOC_CNF is formatted
423 * correctly
424 * false otherwise
425 */
426
427static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
428{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530429 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800430 return false;
431 else
432 return true;
433} /*** end __lim_is_sme_assoc_cnf_valid() ***/
434
435/**
436 * __lim_get_sme_join_req_size_for_alloc()
437 *
438 ***FUNCTION:
439 * This function is called in various places to get IE length
440 * from tSirBssDescription structure
441 * number being scanned.
442 *
443 ***PARAMS:
444 *
445 ***LOGIC:
446 *
447 ***ASSUMPTIONS:
448 * NA
449 *
450 ***NOTE:
451 * NA
452 *
453 * @param pBssDescr
454 * @return Total IE length
455 */
456
457static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
458{
459 uint16_t len = 0;
460
461 if (!pBuf)
462 return len;
463
464 pBuf += sizeof(uint16_t);
465 len = lim_get_u16(pBuf);
Arif Hussainc9651922017-04-16 14:08:23 -0700466 return len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800467}
468
469/**
470 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
471 * @pMac: Global MAC context
472 * @pMsg: Pointer to message posted from SME to LIM.
473 *
474 * Has role only if 11h is enabled. Not used on STA side.
475 * Defers the message if SME is in learn state and brings
476 * the LIM back to normal mode.
477 *
478 * Return: true - If defered false - Otherwise
479 */
480
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800481static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac,
482 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800483{
484 if (lim_is_system_in_scan_state(pMac)) {
485 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700486 pe_err("Could not defer Msg: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800487 return false;
488 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700489 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800490 pMsg->type);
491 return true;
492 }
493 return false;
494}
495
496/**
497 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
498 * @mac_ctx: Pointer to Global MAC structure
499 * @message: Pointer to message posted from SME to LIM.
500 *
501 * Has role only if 11h is enabled. Not used on STA side.
502 * Defers the message if radar is detected.
503 *
504 * Return: true, if defered otherwise return false.
505 */
506static bool
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800507__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx,
508 struct scheduler_msg *message)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800509{
510 /*
511 * fRadarDetCurOperChan will be set only if we
512 * detect radar in current operating channel and
513 * System Role == AP ROLE
514 *
515 * TODO: Need to take care radar detection.
516 *
517 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
518 */
519 if (0) {
520 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700521 pe_err("Could not defer Msg: %d", message->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800522 return false;
523 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700524 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800525 message->type);
526 return true;
527 }
528 return false;
529}
530
531/**
532 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
533 * @pMac: Global MAC context
534 * @pMsgBuf: Message from WMA
535 *
536 * handles the notification from HDD. PE just forwards this message to HAL.
537 *
538 * Return: true-Posting to HAL failed, so PE will consume the buffer.
539 * false-Posting to HAL successful, so HAL will consume the buffer.
540 */
541
542static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
543{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700544 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800545 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
546
547 msg.type = WMA_SYS_READY_IND;
548 msg.reserved = 0;
549 msg.bodyptr = pMsgBuf;
550 msg.bodyval = 0;
551
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700552 if (ANI_DRIVER_TYPE(pMac) != QDF_DRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800553 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +0530554 pe_register_mgmt_rx_frm_callback(pMac);
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700555 pe_register_callbacks_with_wma(pMac, ready_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800556 pMac->lim.add_bssdescr_callback = ready_req->add_bssdescr_cb;
Sandeep Puligilla1426d612017-04-12 18:22:06 -0700557 pMac->lim.sme_msg_callback = ready_req->sme_msg_cb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800558 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700559
560 pe_debug("sending WMA_SYS_READY_IND msg to HAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800561 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
562
563 if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700564 pe_err("wma_post_ctrl_msg failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800565 return true;
566 }
567 return false;
568}
569
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800570/**
571 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
572 *@mac_ctx: Pointer to Global MAC structure
573 *@session: A pointer to session entry
574 *@sme_start_bss_req: Start BSS Request from upper layers.
575 *
576 * This function is used to configure the start bss parameters
577 * in to the session.
578 *
579 * Return: None.
580 */
581static void
582lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
583 tpSirSmeStartBssReq sme_start_bss_req)
584{
585 session->limSystemRole = eLIM_AP_ROLE;
586 session->privacy = sme_start_bss_req->privacy;
587 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
588 session->authType = sme_start_bss_req->authType;
589 /* Store the DTIM period */
590 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
591 /* Enable/disable UAPSD */
592 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530593 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800594 session->proxyProbeRspEn = 0;
595 } else {
596 /*
597 * To detect PBC overlap in SAP WPS mode,
598 * Host handles Probe Requests.
599 */
600 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
601 session->proxyProbeRspEn = 1;
602 else
603 session->proxyProbeRspEn = 0;
604 }
605 session->ssidHidden = sme_start_bss_req->ssidHidden;
606 session->wps_state = sme_start_bss_req->wps_state;
607 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530608 session->vendor_vht_sap =
609 sme_start_bss_req->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800610 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
611 &session->shortSlotTimeSupported);
612 session->isCoalesingInIBSSAllowed =
613 sme_start_bss_req->isCoalesingInIBSSAllowed;
614
Jiachao Wu712d4fd2017-08-23 16:52:34 +0800615 session->beacon_tx_rate = sme_start_bss_req->beacon_tx_rate;
616
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800617}
618
619/**
620 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
621 *@mac_ctx: Pointer to Global MAC structure
622 *@msg_buf: A pointer to the SME message buffer
623 *
624 * This function is called to process SME_START_BSS_REQ message
625 * from HDD or upper layer application.
626 *
627 * Return: None
628 */
629static void
630__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
631{
632 uint16_t size;
633 uint32_t val = 0;
634 tSirRetStatus ret_status;
635 tSirMacChanNum channel_number;
636 tLimMlmStartReq *mlm_start_req = NULL;
637 tpSirSmeStartBssReq sme_start_bss_req = NULL;
638 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
639 /* Flag Used in case of IBSS to Auto generate BSSID. */
640 uint32_t auto_gen_bssid = false;
641 uint8_t session_id;
642 tpPESession session = NULL;
Krunal Sonib37bb352016-12-20 14:12:21 -0800643 uint8_t sme_session_id = 0xFF;
644 uint16_t sme_transaction_id = 0xFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800645 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700646 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800647 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
648
649/* FEATURE_WLAN_DIAG_SUPPORT */
650#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
651 /*
652 * Since the session is not created yet, sending NULL.
653 * The response should have the correct state.
654 */
655 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
656 NULL, 0, 0);
657#endif /* FEATURE_WLAN_DIAG_SUPPORT */
658
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700659 pe_debug("Received START_BSS_REQ");
Krunal Sonib37bb352016-12-20 14:12:21 -0800660 size = sizeof(tSirSmeStartBssReq);
661 sme_start_bss_req = qdf_mem_malloc(size);
662 if (NULL == sme_start_bss_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700663 pe_err("Allocate Memory fail for LimStartBssReq");
Krunal Sonib37bb352016-12-20 14:12:21 -0800664 /* Send failure response to host */
665 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
666 goto free;
667 }
668 qdf_mem_copy(sme_start_bss_req, msg_buf, sizeof(tSirSmeStartBssReq));
669 sme_session_id = sme_start_bss_req->sessionId;
670 sme_transaction_id = sme_start_bss_req->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800671
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800672 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
673 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800674 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
675 sme_start_bss_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700676 pe_warn("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800677 ret_code = eSIR_SME_INVALID_PARAMETERS;
678 goto free;
679 }
680
681 /*
682 * This is the place where PE is going to create a session.
683 * If session is not existed, then create a new session
684 */
685 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800686 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800687 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700688 pe_warn("Session Already exists for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800689 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
690 session = NULL;
691 goto free;
692 } else {
693 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800694 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800695 &session_id, mac_ctx->lim.maxStation,
696 sme_start_bss_req->bssType);
697 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700698 pe_warn("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800699 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
700 goto free;
701 }
702 }
703
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700704 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
705 /* Probe resp add ie */
706 lim_start_bss_update_add_ie_buffer(mac_ctx,
707 &session->addIeParams.probeRespData_buff,
708 &session->addIeParams.probeRespDataLen,
709 sme_start_bss_req->addIeParams.
710 probeRespData_buff,
711 sme_start_bss_req->addIeParams.
712 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800713
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700714 /* Probe Beacon add ie */
715 lim_start_bss_update_add_ie_buffer(mac_ctx,
716 &session->addIeParams.probeRespBCNData_buff,
717 &session->addIeParams.probeRespBCNDataLen,
718 sme_start_bss_req->addIeParams.
719 probeRespBCNData_buff,
720 sme_start_bss_req->addIeParams.
721 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800722
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700723 /* Assoc resp IE */
724 lim_start_bss_update_add_ie_buffer(mac_ctx,
725 &session->addIeParams.assocRespData_buff,
726 &session->addIeParams.assocRespDataLen,
727 sme_start_bss_req->addIeParams.
728 assocRespData_buff,
729 sme_start_bss_req->addIeParams.
730 assocRespDataLen);
731 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800732 /* Store the session related params in newly created session */
733 session->pLimStartBssReq = sme_start_bss_req;
734
735 /* Store PE session_id in session Table */
736 session->peSessionId = session_id;
737
738 /* Store SME session Id in sessionTable */
739 session->smeSessionId = sme_start_bss_req->sessionId;
740
741 session->transactionId = sme_start_bss_req->transactionId;
742
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530743 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800744 &(sme_start_bss_req->htConfig),
745 sizeof(session->htConfig));
746
Sandeep Puligilla98917432016-06-10 13:50:28 -0700747 qdf_mem_copy(&(session->vht_config),
748 &(sme_start_bss_req->vht_config),
749 sizeof(session->vht_config));
750
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800751 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800752 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800753
754 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530755 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800756 (uint8_t *) &sme_start_bss_req->ssId,
757 (sme_start_bss_req->ssId.length + 1));
758
759 session->bssType = sme_start_bss_req->bssType;
760
761 session->nwType = sme_start_bss_req->nwType;
762
763 session->beaconParams.beaconInterval =
764 sme_start_bss_req->beaconInterval;
765
766 /* Store the channel number in session Table */
767 session->currentOperChannel =
768 sme_start_bss_req->channelId;
769
770 /* Store Persona */
771 session->pePersona = sme_start_bss_req->bssPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +0530772 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800773 FL("PE PERSONA=%d"), session->pePersona);
774
775 /* Update the phymode */
776 session->gLimPhyMode = sme_start_bss_req->nwType;
777
778 session->maxTxPower =
779 cfg_get_regulatory_max_transmit_power(mac_ctx,
780 session->currentOperChannel);
781 /* Store the dot 11 mode in to the session Table */
782 session->dot11mode = sme_start_bss_req->dot11mode;
783#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
784 session->cc_switch_mode =
785 sme_start_bss_req->cc_switch_mode;
786#endif
787 session->htCapability =
788 IS_DOT11_MODE_HT(session->dot11mode);
789 session->vhtCapability =
790 IS_DOT11_MODE_VHT(session->dot11mode);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800791
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700792 pe_debug("HT[%d], VHT[%d]",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800793 session->htCapability, session->vhtCapability);
794
795 if (IS_DOT11_MODE_HE(session->dot11mode)) {
796 lim_update_session_he_capable(mac_ctx, session);
797 lim_copy_bss_he_cap(session, sme_start_bss_req);
798 }
799
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800800 session->txLdpcIniFeatureEnabled =
801 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800802#ifdef WLAN_FEATURE_11W
803 session->limRmfEnabled =
804 sme_start_bss_req->pmfCapable ? 1 : 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700805 pe_debug("Session RMF enabled: %d", session->limRmfEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800806#endif
807
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530808 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800809 (void *)&sme_start_bss_req->operationalRateSet,
810 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530811 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800812 (void *)&sme_start_bss_req->extendedRateSet,
813 sizeof(tSirMacRateSet));
814
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700815 if (IS_5G_CH(session->currentOperChannel))
816 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
817 else
818 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
819
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800820 switch (sme_start_bss_req->bssType) {
821 case eSIR_INFRA_AP_MODE:
822 lim_configure_ap_start_bss_session(mac_ctx, session,
823 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700824 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700825 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700826 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700827 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800828 break;
829 case eSIR_IBSS_MODE:
830 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
831 lim_get_short_slot_from_phy_mode(mac_ctx, session,
832 session->gLimPhyMode,
833 &session->shortSlotTimeSupported);
834
835 /*
836 * initialize to "OPEN".
837 * will be updated upon key installation
838 */
839 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700840 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841
842 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700843 case eSIR_NDI_MODE:
844 session->limSystemRole = eLIM_NDI_ROLE;
845 break;
846
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848 /*
849 * There is one more mode called auto mode.
850 * which is used no where
851 */
852
853 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
854
855 default:
856 /* not used anywhere...used in scan function */
857 break;
858 }
859
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700860 pe_debug("persona - %d, nss - %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700861 session->pePersona, session->vdev_nss);
862 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800863 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700864 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800865 * parsed (Re)Assoc request structure
866 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700867 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530869 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700870 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800871 if (NULL == session->parsedAssocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700872 pe_warn("AllocateMemory() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
874 goto free;
875 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800876 }
877
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700878 if (!sme_start_bss_req->channelId &&
879 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700880 pe_err("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800881 ret_code = eSIR_SME_INVALID_PARAMETERS;
882 goto free;
883 }
884 channel_number = sme_start_bss_req->channelId;
885#ifdef QCA_HT_2040_COEX
886 if (sme_start_bss_req->obssEnabled)
887 session->htSupportedChannelWidthSet =
888 session->htCapability;
889 else
890#endif
891 session->htSupportedChannelWidthSet =
892 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
893 session->htSecondaryChannelOffset =
894 sme_start_bss_req->sec_ch_offset;
895 session->htRecommendedTxWidthSet =
896 (session->htSecondaryChannelOffset) ? 1 : 0;
Abhishek Singh4294f802017-08-10 16:37:07 +0530897 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800898 FL("cbMode %u"), sme_start_bss_req->cbMode);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800899 if (lim_is_session_he_capable(session) ||
900 session->vhtCapability || session->htCapability) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800901 chanwidth = sme_start_bss_req->vht_channel_width;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700902 pe_debug("vht_channel_width %u htSupportedChannelWidthSet %d",
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800903 sme_start_bss_req->vht_channel_width,
904 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800905 session->ch_width = chanwidth;
906 if (session->htSupportedChannelWidthSet) {
907 session->ch_center_freq_seg0 =
908 sme_start_bss_req->center_freq_seg0;
909 session->ch_center_freq_seg1 =
910 sme_start_bss_req->center_freq_seg1;
911 } else {
912 session->ch_center_freq_seg0 = 0;
913 session->ch_center_freq_seg1 = 0;
914 }
915 }
916
917 if (session->vhtCapability &&
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800918 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800919 session->nss = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700920 pe_debug("nss set to [%d]", session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800921 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700922 pe_debug("vht su tx bformer %d",
Krunal Soni53993f72016-07-08 18:20:03 -0700923 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800924
925 /* Delete pre-auth list if any */
926 lim_delete_pre_auth_list(mac_ctx);
927
Krunal Soni53993f72016-07-08 18:20:03 -0700928 if (session->nss == 1) {
929 session->vht_config.su_beam_former = 0;
930 session->vht_config.tx_stbc = 0;
931 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530932 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -0700933 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800934 /*
935 * keep the RSN/WPA IE information in PE Session Entry
936 * later will be using this to check when received (Re)Assoc req
937 */
938 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
939 &sme_start_bss_req->rsnIE, session);
940
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700941 if (LIM_IS_AP_ROLE(session) ||
942 LIM_IS_IBSS_ROLE(session) ||
943 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800944 session->gLimProtectionControl =
945 sme_start_bss_req->protEnabled;
946 /*
947 * each byte will have the following info
948 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
949 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
950 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530951 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800952 (void *)&sme_start_bss_req->ht_capab,
953 sizeof(uint16_t));
954 /* Initialize WPS PBC session link list */
955 session->pAPWPSPBCSession = NULL;
956 }
957 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530958 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800959 if (NULL == mlm_start_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700960 pe_err("Allocate Memory failed for mlmStartReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800961 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
962 goto free;
963 }
964
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530966 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967 (uint8_t *) &sme_start_bss_req->ssId,
968 sme_start_bss_req->ssId.length + 1);
969 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
970 mlm_start_req->obssProtEnabled =
971 sme_start_bss_req->obssProtEnabled;
972
973 mlm_start_req->bssType = session->bssType;
974
975 /* Fill PE session Id from the session Table */
976 mlm_start_req->sessionId = session->peSessionId;
977
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700978 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
979 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800980 /*
981 * Copy the BSSId from sessionTable to
982 * mlmStartReq struct
983 */
984 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
985 } else {
986 /* ibss mode */
987 mac_ctx->lim.gLimIbssCoalescingHappened = false;
988
989 ret_status = wlan_cfg_get_int(mac_ctx,
990 WNI_CFG_IBSS_AUTO_BSSID,
991 &auto_gen_bssid);
992 if (ret_status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700993 pe_err("Get Auto Gen BSSID fail,Status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800994 ret_status);
Abhishek Singh4294f802017-08-10 16:37:07 +0530995 ret_code = eSIR_LOGE_EXCEPTION;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800996 goto free;
997 }
998
999 if (!auto_gen_bssid) {
1000 /*
1001 * We're not auto generating BSSID.
1002 * Instead, get it from session entry
1003 */
1004 sir_copy_mac_addr(mlm_start_req->bssId,
1005 session->bssId);
1006 /*
1007 * Start IBSS group BSSID
1008 * Auto Generating BSSID.
1009 */
1010 auto_gen_bssid = ((mlm_start_req->bssId[0] &
1011 0x01) ? true : false);
1012 }
1013
1014 if (auto_gen_bssid) {
1015 /*
1016 * if BSSID is not any uc id.
1017 * then use locally generated BSSID.
1018 * Autogenerate the BSSID
1019 */
1020 lim_get_random_bssid(mac_ctx,
1021 mlm_start_req->bssId);
1022 mlm_start_req->bssId[0] = 0x02;
1023
1024 /*
1025 * Copy randomly generated BSSID
1026 * to the session Table
1027 */
1028 sir_copy_mac_addr(session->bssId,
1029 mlm_start_req->bssId);
1030 }
1031 }
1032 /* store the channel num in mlmstart req structure */
1033 mlm_start_req->channelNumber = session->currentOperChannel;
1034 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
1035 mlm_start_req->beaconPeriod =
1036 session->beaconParams.beaconInterval;
Arif Hussain671a1902017-03-17 09:08:32 -07001037 mlm_start_req->cac_duration_ms =
1038 sme_start_bss_req->cac_duration_ms;
1039 mlm_start_req->dfs_regdomain =
1040 sme_start_bss_req->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001041 if (LIM_IS_AP_ROLE(session)) {
1042 mlm_start_req->dtimPeriod = session->dtimPeriod;
1043 mlm_start_req->wps_state = session->wps_state;
1044
1045 } else {
1046 if (wlan_cfg_get_int(mac_ctx,
1047 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001048 pe_err("could not retrieve DTIM Period");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049 mlm_start_req->dtimPeriod = (uint8_t) val;
1050 }
1051
1052 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
1053 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001054 pe_err("could not retrieve Beacon interval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
1056
1057 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
1058 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001059 pe_err("could not retrieve CFPMaxDuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001060 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1061
1062 /*
1063 * this may not be needed anymore now,
1064 * as rateSet is now included in the
1065 * session entry and MLM has session context.
1066 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301067 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001068 (void *)&session->rateSet,
1069 sizeof(tSirMacRateSet));
1070
1071 /* Now populate the 11n related parameters */
1072 mlm_start_req->nwType = session->nwType;
1073 mlm_start_req->htCapable = session->htCapability;
1074
1075 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1076 /* Unused */
1077 mlm_start_req->dualCTSProtection =
1078 mac_ctx->lim.gHTDualCTSProtection;
1079 mlm_start_req->txChannelWidthSet =
1080 session->htRecommendedTxWidthSet;
1081
1082 session->limRFBand = lim_get_rf_band(channel_number);
1083
1084 /* Initialize 11h Enable Flag */
1085 session->lim11hEnable = 0;
gaolez76d2a162017-03-21 19:23:58 +08001086 if (mlm_start_req->bssType != eSIR_IBSS_MODE &&
1087 (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001088 BAND_5G == session->limRFBand)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001089 if (wlan_cfg_get_int(mac_ctx,
1090 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001091 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001092 else
1093 session->lim11hEnable = val;
1094
1095 if (session->lim11hEnable &&
1096 (eSIR_INFRA_AP_MODE ==
1097 mlm_start_req->bssType)) {
1098 cfg_get_wmi_dfs_master_param =
1099 wlan_cfg_get_int(mac_ctx,
1100 WNI_CFG_DFS_MASTER_ENABLED,
1101 &val);
1102 session->lim11hEnable = val;
1103 }
1104 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1105 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001106 pe_err("Get Fail, CFG DFS ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001107 }
1108
1109 if (!session->lim11hEnable) {
1110 if (cfg_set_int(mac_ctx,
1111 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1112 eSIR_SUCCESS)
1113 /*
1114 * Failed to set the CFG param
1115 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1116 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001117 pe_err("Set LOCAL_POWER_CONSTRAINT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001118 }
1119
Jiachao Wu712d4fd2017-08-23 16:52:34 +08001120 mlm_start_req->beacon_tx_rate = session->beacon_tx_rate;
1121
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001122 session->limPrevSmeState = session->limSmeState;
1123 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1124 MTRACE(mac_trace
1125 (mac_ctx, TRACE_CODE_SME_STATE,
1126 session->peSessionId,
1127 session->limSmeState));
1128
1129 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1130 (uint32_t *) mlm_start_req);
1131 return;
1132 } else {
1133
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001134 pe_err("Received unexpected START_BSS_REQ, in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001135 mac_ctx->lim.gLimSmeState);
1136 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001137 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001138 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1139
1140free:
1141 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001142 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001143 session->pLimStartBssReq = NULL;
1144 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001145 if (NULL != sme_start_bss_req)
1146 qdf_mem_free(sme_start_bss_req);
1147 if (NULL != mlm_start_req)
1148 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001149 if (NULL != session) {
1150 pe_delete_session(mac_ctx, session);
1151 session = NULL;
1152 }
1153 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1154 session, sme_session_id, sme_transaction_id);
1155}
1156
1157/**
1158 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1159 *
1160 * @pMac: Global MAC context
1161 * @pMsg: Message pointer
1162 *
1163 * Wrapper for the function __lim_handle_sme_start_bss_request
1164 * This message will be defered until softmac come out of
1165 * scan mode or if we have detected radar on the current
1166 * operating channel.
1167 *
1168 * return true - If we consumed the buffer
1169 * false - If have defered the message.
1170 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001171static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1172 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001173{
1174 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1175 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1176 /**
1177 * If message defered, buffer is not consumed yet.
1178 * So return false
1179 */
1180 return false;
1181 }
1182
1183 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1184 return true;
1185}
1186
1187/**
1188 * lim_get_random_bssid()
1189 *
1190 * FUNCTION:This function is called to process generate the random number for bssid
1191 * This function is called to process SME_SCAN_REQ message
1192 * from HDD or upper layer application.
1193 *
1194 * LOGIC:
1195 *
1196 * ASSUMPTIONS:
1197 *
1198 * NOTE:
1199 * 1. geneartes the unique random number for bssid in ibss
1200 *
1201 * @param pMac Pointer to Global MAC structure
1202 * @param *data Pointer to bssid buffer
1203 * @return None
1204 */
1205void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1206{
1207 uint32_t random[2];
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001208
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001209 random[0] = tx_time_get();
1210 random[0] |= (random[0] << 15);
1211 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301212 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001213}
1214
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301215static QDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001216 tpSirSmeScanReq pScanReq)
1217{
1218 tSirScanOffloadReq *pScanOffloadReq;
1219 uint8_t *p;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001220 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001221 uint16_t i, len;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001222 uint16_t addn_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001223 tSirRetStatus status, rc = eSIR_SUCCESS;
1224 tDot11fIEExtCap extracted_extcap = {0};
1225 bool extcap_present = true;
1226
1227 if (pScanReq->uIEFieldLen) {
1228 status = lim_strip_extcap_update_struct(pMac,
1229 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1230 &pScanReq->uIEFieldLen, &extracted_extcap);
1231
1232 if (eSIR_SUCCESS != status) {
1233 extcap_present = false;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001234 pe_debug("Unable to Strip ExtCap IE from Scan Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001235 }
1236
1237 if (extcap_present) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001238 pe_debug("Extcap was part of SCAN IE - Updating FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001239 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1240 &extracted_extcap, true);
1241 }
1242 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001243 pe_debug("No IEs in the scan request from supplicant");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001244 }
1245
1246 /**
1247 * The tSirScanOffloadReq will reserve the space for first channel,
1248 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1249 */
1250 len = sizeof(tSirScanOffloadReq) +
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001251 (pScanReq->channelList.numChannels - 1) +
1252 pScanReq->uIEFieldLen;
Naveen Rawat02e12662016-08-31 16:49:27 -07001253
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301254 pScanOffloadReq = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001255 if (NULL == pScanOffloadReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001256 pe_err("AllocateMemory failed for pScanOffloadReq");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301257 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001258 }
1259
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001260 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1261 msg.bodyptr = pScanOffloadReq;
1262 msg.bodyval = 0;
1263
Anurag Chouhanc5548422016-02-24 18:33:27 +05301264 qdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001265
1266 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001267 pe_err("Invalid value (%d) for numSsid",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001268 SIR_SCAN_MAX_NUM_SSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301269 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301270 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001271 }
1272
1273 pScanOffloadReq->numSsid = pScanReq->numSsid;
1274 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1275 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301276 qdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001277 (uint8_t *) pScanReq->ssId[i].ssId,
1278 pScanOffloadReq->ssId[i].length);
1279 }
1280
1281 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301282 qdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001283 pScanOffloadReq->bssType = pScanReq->bssType;
1284 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1285 pScanOffloadReq->scanType = pScanReq->scanType;
1286 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1287 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1288 pScanOffloadReq->restTime = pScanReq->restTime;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05301289 pScanOffloadReq->min_rest_time = pScanReq->min_rest_time;
1290 pScanOffloadReq->idle_time = pScanReq->idle_time;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301291 pScanOffloadReq->scan_adaptive_dwell_mode =
1292 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293
Paul Zhangd2315472017-02-22 10:02:50 +08001294 for (i = 0; i < pMac->lim.maxBssId; i++) {
1295 tpPESession session_entry =
1296 pe_find_session_by_sme_session_id(pMac, i);
1297 if (session_entry &&
1298 (eLIM_MLM_LINK_ESTABLISHED_STATE ==
1299 session_entry->limMlmState) &&
1300 (session_entry->beaconParams.beaconInterval
1301 < BEACON_INTERVAL_THRESHOLD)) {
1302 pScanOffloadReq->burst_scan_duration =
1303 STA_BURST_SCAN_DURATION;
1304 break;
1305 }
1306 }
1307
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 /* for normal scan, the value for p2pScanType should be 0
1309 always */
1310 if (pScanReq->p2pSearch)
1311 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1312
1313 pScanOffloadReq->sessionId = pScanReq->sessionId;
1314 pScanOffloadReq->scan_id = pScanReq->scan_id;
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07001315 pScanOffloadReq->scan_requestor_id = USER_SCAN_REQUESTOR_ID;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301316 pScanOffloadReq->scan_adaptive_dwell_mode =
1317 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001318
1319 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001320 pe_err("Invalid pe sessionID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001321 pScanOffloadReq->sessionId);
1322
1323 pScanOffloadReq->channelList.numChannels =
1324 pScanReq->channelList.numChannels;
1325 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1326 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1327 p[i] = pScanReq->channelList.channelNumber[i];
1328
1329 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1330 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1331 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301332 qdf_mem_copy((uint8_t *) pScanOffloadReq +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001333 pScanOffloadReq->uIEFieldOffset,
1334 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1335 pScanReq->uIEFieldLen);
Naveen Rawat02e12662016-08-31 16:49:27 -07001336
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001337 rc = wma_post_ctrl_msg(pMac, &msg);
1338 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001339 pe_err("wma_post_ctrl_msg() return failure");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301340 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301341 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001342 }
1343
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001344 pe_debug("Processed Offload Scan Request Successfully");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001345
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301346 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001347}
1348
1349/**
1350 * __lim_process_sme_scan_req() - Process the SME Scan Request
1351 * @mac_ctx: Global MAC Context
1352 * @msg_buf: Buffer which contains the request and pertinent parameters
1353 *
1354 * This function is called to process SME_SCAN_REQ message
1355 * from HDD or upper layer application.
1356 *
1357 * Return: None
1358 */
1359
1360static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1361 uint32_t *msg_buf)
1362{
1363 tpSirSmeScanReq scan_req;
1364 uint8_t valid_req = 0;
1365
1366#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1367 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1368 eSIR_SUCCESS, eSIR_SUCCESS);
1369#endif
Sreelakshmi Konamki1bb6f312016-12-08 12:32:01 +05301370 mac_ctx->lim.beacon_probe_rsp_cnt_per_scan = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001371
1372 scan_req = (tpSirSmeScanReq) msg_buf;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001373 pe_debug("SME SCAN REQ id %d numChan %d min %d max %d IELen %d first %d fresh %d unique %d type %s (%d) rsp %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001374 scan_req->scan_id, scan_req->channelList.numChannels,
1375 scan_req->minChannelTime, scan_req->maxChannelTime,
1376 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1377 scan_req->returnFreshResults, scan_req->returnUniqueResults,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301378 lim_scan_type_to_string(scan_req->scanType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001379 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1380 /*
1381 * Since scan req always requires a response, we will overwrite response
1382 * required here. This is added esp to take care of the condition where
1383 * in p2p go case, we hold the scan req and insert single NOA. We send
1384 * the held scan request to FW later on getting start NOA ind from FW so
1385 * we lose state of the gLimRspReqd flag for the scan req if any other
1386 * request comes by then. e.g. While unit testing, we found when insert
1387 * single NOA is done, we see a get stats request which turns the flag
1388 * gLimRspReqd to false; now when we actually start the saved scan req
1389 * for init scan after getting NOA started, the gLimRspReqd being a
1390 * global flag is showing false instead of true value for this saved
1391 * scan req. Since all scan reqs coming to lim require a response,
1392 * there is no harm in setting the global flag gLimRspReqd to true here.
1393 */
1394 mac_ctx->lim.gLimRspReqd = true;
1395
1396 /*
1397 * copy the Self MAC address from SmeReq to the globalplace,
1398 * used for sending probe req
1399 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001400 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1401 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001402 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1403
1404 if (!valid_req || mac_ctx->lim.scan_disabled) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001405 pe_err("Scan disabled %d, Valid Scan Req %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001406 mac_ctx->lim.scan_disabled, valid_req);
1407
1408 if (mac_ctx->lim.gLimRspReqd) {
1409 mac_ctx->lim.gLimRspReqd = false;
1410
1411 lim_send_sme_scan_rsp(mac_ctx,
1412 eSIR_SME_INVALID_PARAMETERS,
1413 scan_req->sessionId,
1414 scan_req->transactionId,
1415 scan_req->scan_id);
1416 }
1417 return;
1418 }
1419
1420 /*
1421 * If scan request is received in idle, joinFailed
1422 * states or in link established state (in STA role)
1423 * or in normal state (in STA-in-IBSS/AP role) with
1424 * 'return fresh scan results' request from HDD or
1425 * it is periodic background scanning request,
1426 * trigger fresh scan request to MLM
1427 */
1428 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1429
1430 mac_ctx->lim.gLim24Band11dScanDone = 0;
1431 mac_ctx->lim.gLim50Band11dScanDone = 0;
1432 mac_ctx->lim.gLimReturnAfterFirstMatch =
1433 scan_req->returnAfterFirstMatch;
1434 mac_ctx->lim.gLimReturnUniqueResults =
1435 ((scan_req->returnUniqueResults) > 0 ? true : false);
1436
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301437 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001438 lim_send_hal_start_scan_offload_req(mac_ctx,
1439 scan_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001440 pe_err("Couldn't send Offload scan request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441 lim_send_sme_scan_rsp(mac_ctx,
1442 eSIR_SME_INVALID_PARAMETERS,
1443 scan_req->sessionId,
1444 scan_req->transactionId,
1445 scan_req->scan_id);
1446 return;
1447 }
Anurag Chouhanffb21542016-02-17 14:33:03 +05301448 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001449 /* In all other cases return 'cached' scan results */
1450 if (mac_ctx->lim.gLimRspReqd) {
1451 mac_ctx->lim.gLimRspReqd = false;
1452 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1453 scan_req->sessionId,
1454 scan_req->transactionId, scan_req->scan_id);
1455 }
1456 }
1457}
1458
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001459/**
1460 * __lim_process_clear_dfs_channel_list()
1461 *
1462 ***FUNCTION:
1463 ***Clear DFS channel list when country is changed/aquired.
1464 .*This message is sent from SME.
1465 *
1466 ***LOGIC:
1467 *
1468 ***ASSUMPTIONS:
1469 *
1470 ***NOTE:
1471 *
1472 * @param pMac Pointer to Global MAC structure
1473 * @param *pMsgBuf A pointer to the SME message buffer
1474 * @return None
1475 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001476static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1477 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001478{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301479 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001480}
1481
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301482#ifdef WLAN_FEATURE_SAE
1483
1484/**
1485 * lim_update_sae_config()- This API update SAE session info to csr config
1486 * from join request.
1487 * @session: PE session
1488 * @sme_join_req: pointer to join request
1489 *
1490 * Return: None
1491 */
1492static void lim_update_sae_config(tpPESession session,
1493 tpSirSmeJoinReq sme_join_req)
1494{
1495 session->sae_pmk_cached = sme_join_req->sae_pmk_cached;
1496
1497 pe_debug("pmk_cached %d for BSSID=" MAC_ADDRESS_STR,
1498 session->sae_pmk_cached,
1499 MAC_ADDR_ARRAY(sme_join_req->bssDescription.bssId));
1500}
1501#else
1502static inline void lim_update_sae_config(tpPESession session,
1503 tpSirSmeJoinReq sme_join_req)
1504{}
1505#endif
1506
1507
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001508/**
1509 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1510 * @mac_ctx: Pointer to Global MAC structure
1511 * @msg_buf: A pointer to the SME message buffer
1512 *
1513 * This function is called to process SME_JOIN_REQ message
1514 * from HDD or upper layer application.
1515 *
1516 * Return: None
1517 */
1518static void
1519__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1520{
1521 tpSirSmeJoinReq sme_join_req = NULL;
1522 tLimMlmJoinReq *mlm_join_req;
1523 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1524 uint32_t val = 0;
1525 uint16_t n_size;
1526 uint8_t session_id;
1527 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301528 uint8_t sme_session_id = 0;
1529 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001530 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531 uint16_t ie_len;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001532 const uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001533 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001534 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001535
Arif Hussain995fcaf2016-07-18 11:28:22 -07001536 if (!mac_ctx || !msg_buf) {
1537 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1538 FL("JOIN REQ with invalid data"));
1539 return;
1540 }
1541
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001542/* FEATURE_WLAN_DIAG_SUPPORT */
1543#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1544 /*
1545 * Not sending any session, since it is not created yet.
1546 * The response whould have correct state.
1547 */
1548 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1549#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1550
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001551 /*
1552 * Expect Join request in idle state.
1553 * Reassociate request is expected in link established state.
1554 */
1555
1556 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1557 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1558 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1559 msg_buf);
1560
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301561 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001562 if (NULL == sme_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001563 pe_err("AllocateMemory failed for sme_join_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001564 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301565 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001566 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301567 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001568 n_size);
1569
1570 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1571 /* Received invalid eWNI_SME_JOIN_REQ */
1572 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001573 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574 sme_join_req->sessionId);
1575 ret_code = eSIR_SME_INVALID_PARAMETERS;
1576 goto end;
1577 }
1578
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001579 /*
1580 * Update the capability here itself as this is used in
1581 * lim_extract_ap_capability() below. If not updated issues
1582 * like not honoring power constraint on 1st association after
1583 * driver loading might occur.
1584 */
1585 lim_update_rrm_capability(mac_ctx, sme_join_req);
1586
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001587 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001588 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001589 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590 &session_id);
1591
1592 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001593 pe_err("Session(%d) Already exists for BSSID: "
1594 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001595 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001596 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001597 session->limSmeState);
1598
1599 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1600 session->smeSessionId == sme_join_req->sessionId) {
1601 /*
1602 * Received eWNI_SME_JOIN_REQ for same
1603 * BSS as currently associated.
1604 * Log the event and send success
1605 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001606 pe_warn("SessionId: %d", session_id);
1607 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001608 /* Send Join success response to host */
1609 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1610 session = NULL;
1611 goto end;
1612 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001613 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001614 ret_code = eSIR_SME_REFUSED;
1615 session = NULL;
1616 goto end;
1617 }
1618 } else {
1619 /*
1620 * Session Entry does not exist for given BSSId
1621 * Try to Create a new session
1622 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001623 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001624 &session_id, mac_ctx->lim.maxStation,
1625 eSIR_INFRASTRUCTURE_MODE);
1626 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001627 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001628 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1629 goto end;
1630 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001631 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001632 session_id);
1633 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001634 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001635
1636 /*
1637 * Store Session related parameters
1638 * Store PE session Id in session Table
1639 */
1640 session->peSessionId = session_id;
1641
1642 /* store the smejoin req handle in session table */
1643 session->pLimJoinReq = sme_join_req;
1644
1645 /* Store SME session Id in sessionTable */
1646 session->smeSessionId = sme_join_req->sessionId;
1647
1648 /* Store SME transaction Id in session Table */
1649 session->transactionId = sme_join_req->transactionId;
1650
1651 /* Store beaconInterval */
1652 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001653 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001654
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301655 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001656 sizeof(session->htConfig));
1657
Sandeep Puligilla98917432016-06-10 13:50:28 -07001658 qdf_mem_copy(&(session->vht_config),
1659 &(sme_join_req->vht_config),
1660 sizeof(session->vht_config));
1661
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001662 /* Copying of bssId is already done, while creating session */
1663 sir_copy_mac_addr(session->selfMacAddr,
1664 sme_join_req->selfMacAddr);
1665 session->bssType = sme_join_req->bsstype;
1666
1667 session->statypeForBss = STA_ENTRY_PEER;
1668 session->limWmeEnabled = sme_join_req->isWMEenabled;
1669 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301670 session->wps_registration = sme_join_req->wps_registration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001671
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301672 session->enable_bcast_probe_rsp =
1673 sme_join_req->enable_bcast_probe_rsp;
1674
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001675 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001676 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001677 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1678
Naveen Rawat08db88f2017-09-08 15:07:48 -07001679 vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001680 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001681 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001682
1683 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001684 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001685 session->isCiscoVendorAP = true;
1686 } else {
1687 session->isCiscoVendorAP = false;
1688 }
1689
1690 /* Copy the dot 11 mode in to the session table */
1691
1692 session->dot11mode = sme_join_req->dot11mode;
1693#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1694 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1695#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001696 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001697 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1698 session->enableHtSmps = sme_join_req->enableHtSmps;
1699 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001700 session->send_smps_action =
1701 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001702 /*
1703 * By default supported NSS 1x1 is set to true
1704 * and later on updated while determining session
1705 * supported rates which is the intersection of
1706 * self and peer rates
1707 */
1708 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301709 /*Store Persona */
1710 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001711 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 -08001712 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001713 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001714 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301715 session->supported_nss_1x1,
1716 session->pePersona,
1717 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001718
1719 /*Store Persona */
1720 session->pePersona = sme_join_req->staPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +05301721 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301722 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d force_24ghz_in_ht20 %d"),
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001723 session->pePersona, sme_join_req->cbMode,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301724 session->nwType, session->dot11mode,
1725 sme_join_req->force_24ghz_in_ht20);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001726
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001727 /* Copy The channel Id to the session Table */
1728 session->currentOperChannel = bss_desc->channelId;
1729 if (IS_5G_CH(session->currentOperChannel))
1730 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001731 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001732 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1733 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1734 session->vdev_nss = vdev_type_nss->p2p_cli;
1735 else
1736 session->vdev_nss = vdev_type_nss->sta;
1737 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001738 session->vhtCapability =
1739 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001740 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301741 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001742 session->vht_config.su_beam_formee =
1743 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001744 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001745 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001746 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001747 session->enableVhtpAid =
1748 sme_join_req->enableVhtpAid;
1749 session->enableVhtGid =
1750 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001751 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001752 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001753 }
Krunal Soni53993f72016-07-08 18:20:03 -07001754
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001755 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301756 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001757 session->vht_config.su_beam_formee,
1758 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001759 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001760 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001761 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001762 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301763 session->force_24ghz_in_ht20 =
1764 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001765 /* cbMode is already merged value of peer and self -
1766 * done by csr in csr_get_cb_mode_from_ies */
1767 session->htSupportedChannelWidthSet =
1768 (sme_join_req->cbMode) ? 1 : 0;
1769 session->htRecommendedTxWidthSet =
1770 session->htSupportedChannelWidthSet;
1771 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1772
1773 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1774 session->ch_center_freq_seg0 =
1775 session->currentOperChannel - 2;
1776 session->ch_width = CH_WIDTH_40MHZ;
1777 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1778 sme_join_req->cbMode) {
1779 session->ch_center_freq_seg0 =
1780 session->currentOperChannel + 2;
1781 session->ch_width = CH_WIDTH_40MHZ;
1782 } else {
1783 session->ch_center_freq_seg0 = 0;
1784 session->ch_width = CH_WIDTH_20MHZ;
1785 }
1786
Naveen Rawataeca1b92017-10-16 16:55:31 -07001787 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1788 lim_update_session_he_capable(mac_ctx, session);
1789 lim_copy_join_req_he_cap(session, sme_join_req);
1790 }
1791
1792
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001793 /* Record if management frames need to be protected */
1794#ifdef WLAN_FEATURE_11W
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +05301795 if ((eSIR_ED_AES_128_CMAC ==
1796 sme_join_req->MgmtEncryptionType) ||
1797 (eSIR_ED_AES_GMAC_128 == sme_join_req->MgmtEncryptionType) ||
1798 (eSIR_ED_AES_GMAC_256 == sme_join_req->MgmtEncryptionType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001799 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001800 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001801 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001802#endif
1803
1804#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001805 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001806#endif
1807
1808 /* Copy the SSID from smejoinreq to session entry */
1809 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301810 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001811 session->ssId.length);
1812
1813 /*
1814 * Determin 11r or ESE connection based on input from SME
1815 * which inturn is dependent on the profile the user wants
1816 * to connect to, So input is coming from supplicant
1817 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001818 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001819#ifdef FEATURE_WLAN_ESE
1820 session->isESEconnection = sme_join_req->isESEconnection;
1821#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001822 session->isFastTransitionEnabled =
1823 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001824
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001825 session->isFastRoamIniFeatureEnabled =
1826 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001827 session->txLdpcIniFeatureEnabled =
1828 sme_join_req->txLdpcIniFeatureEnabled;
1829
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301830 lim_update_fils_config(session, sme_join_req);
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301831 lim_update_sae_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001832 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1833 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001834 } else {
1835 /*
1836 * Throw an error and return and make
1837 * sure to delete the session.
1838 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001839 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001840 session->bssType);
1841 ret_code = eSIR_SME_INVALID_PARAMETERS;
1842 goto end;
1843 }
1844
1845 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301846 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001847 &sme_join_req->addIEScan, sizeof(tSirAddie));
1848
1849 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301850 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001851 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1852
1853 val = sizeof(tLimMlmJoinReq) +
1854 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301855 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001856 if (NULL == mlm_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001857 pe_err("AllocateMemory failed for mlmJoinReq");
Nitesh Shah0102cac2016-07-13 14:38:30 +05301858 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1859 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001860 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001861
1862 /* PE SessionId is stored as a part of JoinReq */
1863 mlm_join_req->sessionId = session->peSessionId;
1864
1865 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1866 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1867 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001868 pe_err("couldn't retrieve JoinFailureTimer value"
1869 " setting to default value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870 mlm_join_req->joinFailureTimeout =
1871 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1872 }
1873
1874 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301875 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001876 (void *)&sme_join_req->operationalRateSet,
1877 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301878 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001879 (void *)&sme_join_req->extendedRateSet,
1880 sizeof(tSirMacRateSet));
1881 /*
1882 * this may not be needed anymore now, as rateSet is now
1883 * included in the session entry and MLM has session context.
1884 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301885 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001886 (void *)&session->rateSet,
1887 sizeof(tSirMacRateSet));
1888
1889 session->encryptType = sme_join_req->UCEncryptionType;
1890
1891 mlm_join_req->bssDescription.length =
1892 session->pLimJoinReq->bssDescription.length;
1893
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301894 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001895 (uint8_t *)
1896 &session->pLimJoinReq->bssDescription.bssId,
1897 session->pLimJoinReq->bssDescription.length + 2);
1898
1899 session->limCurrentBssCaps =
1900 session->pLimJoinReq->bssDescription.capabilityInfo;
1901
1902 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1903 session->currentOperChannel);
1904 local_power_constraint = reg_max;
1905
1906 lim_extract_ap_capability(mac_ctx,
1907 (uint8_t *)
1908 session->pLimJoinReq->bssDescription.ieFields,
1909 lim_get_ielen_from_bss_description(
1910 &session->pLimJoinReq->bssDescription),
1911 &session->limCurrentBssQosCaps,
1912 &session->limCurrentBssPropCap,
1913 &session->gLimCurrentBssUapsd,
1914 &local_power_constraint, session);
1915
Krunal Soni53993f72016-07-08 18:20:03 -07001916 /*
1917 * Once the AP capabilities are available then set the
1918 * beam forming capabilities accordingly.
1919 */
1920 if (session->nss == 1) {
1921 session->vht_config.su_beam_former = 0;
1922 session->vht_config.tx_stbc = 0;
1923 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301924 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001925 }
1926
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001927 session->maxTxPower = lim_get_max_tx_power(reg_max,
1928 local_power_constraint,
1929 mac_ctx->roam.configParam.nTxPowerCap);
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301930
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001931 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301932 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001933
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301934 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1935 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1936 pe_debug("Update MaxTxPower in join Req to %d",
1937 sme_join_req->powerCap.maxTxPower);
1938 }
1939
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001940 if (session->gLimCurrentBssUapsd) {
1941 session->gUapsdPerAcBitmask =
1942 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001943 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944 session->gUapsdPerAcBitmask);
1945
1946 /* resetting the dynamic uapsd mask */
1947 session->gUapsdPerAcDeliveryEnableMask = 0;
1948 session->gUapsdPerAcTriggerEnableMask = 0;
1949 }
1950
1951 session->limRFBand =
1952 lim_get_rf_band(session->currentOperChannel);
1953
1954 /* Initialize 11h Enable Flag */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001955 if (BAND_5G == session->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001956 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1957 &val) != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001958 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001959 session->lim11hEnable =
1960 WNI_CFG_11H_ENABLED_STADEF;
1961 } else {
1962 session->lim11hEnable = val;
1963 }
1964 } else {
1965 session->lim11hEnable = 0;
1966 }
1967
1968 /*
1969 * To care of the scenario when STA transitions from
1970 * IBSS to Infrastructure mode.
1971 */
1972 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1973
1974 session->limPrevSmeState = session->limSmeState;
1975 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1976 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1977 session->peSessionId,
1978 session->limSmeState));
1979
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001980 /* Indicate whether spectrum management is enabled */
1981 session->spectrumMgtEnabled =
1982 sme_join_req->spectrumMgtIndicator;
1983
1984 /* Enable the spectrum management if this is a DFS channel */
1985 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001986 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987 session->currentOperChannel))
1988 session->spectrumMgtEnabled = true;
1989
1990 session->isOSENConnection = sme_join_req->isOSENConnection;
1991
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001992 /* Issue LIM_MLM_JOIN_REQ to MLM */
1993 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1994 (uint32_t *) mlm_join_req);
1995 return;
1996
1997 } else {
1998 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001999 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000 mac_ctx->lim.gLimSmeState);
2001 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
2002 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2003 session = NULL;
2004 goto end;
2005 }
2006
2007end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05302008 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2009 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002010
2011 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302012 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002013 sme_join_req = NULL;
2014 if (NULL != session)
2015 session->pLimJoinReq = NULL;
2016 }
2017 if (ret_code != eSIR_SME_SUCCESS) {
2018 if (NULL != session) {
2019 pe_delete_session(mac_ctx, session);
2020 session = NULL;
2021 }
2022 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002023 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002024 sme_session_id, ret_code);
2025 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
2026 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
2027 sme_transaction_id);
2028}
2029
Amar Singhala297bfa2015-10-15 15:07:29 -07002030uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031 uint8_t iniTxPower)
2032{
2033 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302034 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002035
Anurag Chouhan6d760662016-02-20 16:05:43 +05302036 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002037 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2038 maxTxPower = txPower;
2039 else if (txPower < MIN_TX_PWR_CAP)
2040 maxTxPower = MIN_TX_PWR_CAP;
2041 else
2042 maxTxPower = MAX_TX_PWR_CAP;
2043
2044 return maxTxPower;
2045}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002046
2047/**
2048 * __lim_process_sme_reassoc_req() - process reassoc req
2049 *
2050 * @mac_ctx: Pointer to Global MAC structure
2051 * @msg_buf: pointer to the SME message buffer
2052 *
2053 * This function is called to process SME_REASSOC_REQ message
2054 * from HDD or upper layer application.
2055 *
2056 * Return: None
2057 */
2058
2059static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2060 uint32_t *msg_buf)
2061{
2062 uint16_t caps;
2063 uint32_t val;
2064 tpSirSmeJoinReq reassoc_req = NULL;
2065 tLimMlmReassocReq *mlm_reassoc_req;
2066 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2067 tpPESession session_entry = NULL;
2068 uint8_t session_id;
2069 uint8_t sme_session_id;
2070 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002071 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002072 uint32_t tele_bcn_en = 0;
2073 uint16_t size;
2074
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002075 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302076 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002077 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002078 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002079
2080 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2081 goto end;
2082 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302083 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002084
2085 if (!lim_is_sme_join_req_valid(mac_ctx,
2086 (tpSirSmeJoinReq)reassoc_req)) {
2087 /*
2088 * Received invalid eWNI_SME_REASSOC_REQ
2089 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002090 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002091
2092 ret_code = eSIR_SME_INVALID_PARAMETERS;
2093 goto end;
2094 }
2095
2096 session_entry = pe_find_session_by_bssid(mac_ctx,
2097 reassoc_req->bssDescription.bssId,
2098 &session_id);
2099 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002100 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002101 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2102 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002104 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
2105 &sme_session_id, &transaction_id);
2106 session_entry =
2107 pe_find_session_by_sme_session_id(mac_ctx,
2108 sme_session_id);
2109 if (session_entry != NULL)
2110 lim_handle_sme_join_result(mac_ctx,
2111 eSIR_SME_INVALID_PARAMETERS,
2112 eSIR_MAC_UNSPEC_FAILURE_STATUS,
2113 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002114 goto end;
2115 }
2116#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2117 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2118 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2119#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2120 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2121
2122 /* Store the reassoc handle in the session Table */
2123 session_entry->pLimReAssocReq = reassoc_req;
2124
2125 session_entry->dot11mode = reassoc_req->dot11mode;
2126 session_entry->vhtCapability =
2127 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002128
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302129 if (session_entry->vhtCapability) {
2130 if (session_entry->pePersona == QDF_STA_MODE) {
2131 session_entry->vht_config.su_beam_formee =
2132 reassoc_req->vht_config.su_beam_formee;
2133 } else {
2134 reassoc_req->vht_config.su_beam_formee = 0;
2135 }
2136 session_entry->enableVhtpAid =
2137 reassoc_req->enableVhtpAid;
2138 session_entry->enableVhtGid =
2139 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002140 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302141 }
2142
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002143 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302144 session_entry->vhtCapability,
2145 session_entry->vht_config.su_beam_formee,
2146 session_entry->vht_config.su_beam_former);
2147
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002148 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2149 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002150 session_entry->send_smps_action =
2151 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002152 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002153 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002154 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002155 session_entry->send_smps_action,
2156 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002157 /*
2158 * Reassociate request is expected
2159 * in link established state only.
2160 */
2161
2162 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002163 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2164 /*
2165 * May be from 11r FT pre-auth. So lets check it
2166 * before we bail out
2167 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002168 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002169 session_entry->peSessionId);
2170
2171 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302172 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002173 session_entry->limReAssocbssId,
2174 6)) {
2175 lim_print_mac_addr(mac_ctx,
2176 reassoc_req->bssDescription.
2177 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002178 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002179 ret_code = eSIR_SME_INVALID_PARAMETERS;
2180 goto end;
2181 }
2182
2183 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2184 session_entry);
2185 return;
2186 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002187 /*
2188 * Should not have received eWNI_SME_REASSOC_REQ
2189 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002190 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002191 session_entry->limSmeState);
2192 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2193
2194 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2195 goto end;
2196 }
2197
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302198 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002199 session_entry->pLimReAssocReq->bssDescription.bssId,
2200 sizeof(tSirMacAddr));
2201
2202 session_entry->limReassocChannelId =
2203 session_entry->pLimReAssocReq->bssDescription.channelId;
2204
2205 session_entry->reAssocHtSupportedChannelWidthSet =
2206 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2207 session_entry->reAssocHtRecommendedTxWidthSet =
2208 session_entry->reAssocHtSupportedChannelWidthSet;
2209 session_entry->reAssocHtSecondaryChannelOffset =
2210 session_entry->pLimReAssocReq->cbMode;
2211
2212 session_entry->limReassocBssCaps =
2213 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2214 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2215 session_entry->currentOperChannel);
2216 local_pwr_constraint = reg_max;
2217
2218 lim_extract_ap_capability(mac_ctx,
2219 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2220 lim_get_ielen_from_bss_description(
2221 &session_entry->pLimReAssocReq->bssDescription),
2222 &session_entry->limReassocBssQosCaps,
2223 &session_entry->limReassocBssPropCap,
2224 &session_entry->gLimCurrentBssUapsd,
2225 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302226 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002227 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302228 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002229 /* Copy the SSID from session entry to local variable */
2230 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302231 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002232 reassoc_req->ssId.ssId,
2233 session_entry->limReassocSSID.length);
2234 if (session_entry->gLimCurrentBssUapsd) {
2235 session_entry->gUapsdPerAcBitmask =
2236 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002237 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002238 session_entry->gUapsdPerAcBitmask);
2239 }
2240
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302241 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002242 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002243 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002244
2245 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2246 goto end;
2247 }
2248
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302249 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002250 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2251
2252 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2253 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002254 eSIR_SUCCESS)
2255 pe_err("could not retrieve ReassocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002256
2257 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002258 eSIR_SUCCESS)
2259 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302260
2261 lim_update_caps_info_for_bss(mac_ctx, &caps,
2262 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002263 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302264
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002265 mlm_reassoc_req->capabilityInfo = caps;
2266
2267 /* Update PE session_id */
2268 mlm_reassoc_req->sessionId = session_id;
2269
2270 /*
2271 * If telescopic beaconing is enabled, set listen interval to
2272 * WNI_CFG_TELE_BCN_MAX_LI
2273 */
2274 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2275 &tele_bcn_en) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002276 pe_err("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002277
2278 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2279
2280 if (tele_bcn_en) {
2281 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2282 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002283 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002284 } else {
2285 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2286 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002287 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002288 }
2289
2290 mlm_reassoc_req->listenInterval = (uint16_t) val;
2291
2292 /* Indicate whether spectrum management is enabled */
2293 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2294
2295 /* Enable the spectrum management if this is a DFS channel */
2296 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002297 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002298 session_entry->currentOperChannel))
2299 session_entry->spectrumMgtEnabled = true;
2300
2301 session_entry->limPrevSmeState = session_entry->limSmeState;
2302 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2303
2304 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2305 session_entry->peSessionId,
2306 session_entry->limSmeState));
2307
2308 lim_post_mlm_message(mac_ctx,
2309 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2310 return;
2311end:
2312 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302313 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002314 if (session_entry)
2315 session_entry->pLimReAssocReq = NULL;
2316 }
2317
2318 if (session_entry) {
2319 /*
2320 * error occurred after we determined the session so extract
2321 * session and transaction info from there
2322 */
2323 sme_session_id = session_entry->smeSessionId;
2324 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002325 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002326 /*
2327 * error occurred before or during the time we determined
2328 * the session so extract the session and transaction info
2329 * from the message
2330 */
2331 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2332 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002333 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002334 /*
2335 * Send Reassoc failure response to host
2336 * (note session_entry may be NULL, but that's OK)
2337 */
2338 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2339 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2340 session_entry, sme_session_id,
2341 transaction_id);
2342}
2343
2344bool send_disassoc_frame = 1;
2345/**
2346 * __lim_process_sme_disassoc_req()
2347 *
2348 ***FUNCTION:
2349 * This function is called to process SME_DISASSOC_REQ message
2350 * from HDD or upper layer application.
2351 *
2352 ***LOGIC:
2353 *
2354 ***ASSUMPTIONS:
2355 *
2356 ***NOTE:
2357 *
2358 * @param pMac Pointer to Global MAC structure
2359 * @param *pMsgBuf A pointer to the SME message buffer
2360 * @return None
2361 */
2362
2363static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2364{
2365 uint16_t disassocTrigger, reasonCode;
2366 tLimMlmDisassocReq *pMlmDisassocReq;
2367 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2368 tSirSmeDisassocReq smeDisassocReq;
2369 tpPESession psessionEntry = NULL;
2370 uint8_t sessionId;
2371 uint8_t smesessionId;
2372 uint16_t smetransactionId;
2373
2374 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002375 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002376 return;
2377 }
2378
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302379 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002380 smesessionId = smeDisassocReq.sessionId;
2381 smetransactionId = smeDisassocReq.transactionId;
2382 if (!lim_is_sme_disassoc_req_valid(pMac,
2383 &smeDisassocReq,
2384 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002385 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002386 if (pMac->lim.gLimRspReqd) {
2387 pMac->lim.gLimRspReqd = false;
2388
2389 retCode = eSIR_SME_INVALID_PARAMETERS;
2390 disassocTrigger = eLIM_HOST_DISASSOC;
2391 goto sendDisassoc;
2392 }
2393
2394 return;
2395 }
2396
2397 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002398 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002399 &sessionId);
2400 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002401 pe_err("session does not exist for given bssId "
2402 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002403 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002404 retCode = eSIR_SME_INVALID_PARAMETERS;
2405 disassocTrigger = eLIM_HOST_DISASSOC;
2406 goto sendDisassoc;
2407 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002408 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2409 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002410 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2411 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002412 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002413
2414#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2415 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2416 0, smeDisassocReq.reasonCode);
2417#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2418
2419 /* Update SME session Id and SME transaction ID */
2420
2421 psessionEntry->smeSessionId = smesessionId;
2422 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002423 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002424 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002425
2426 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2427 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002428 switch (psessionEntry->limSmeState) {
2429 case eLIM_SME_ASSOCIATED_STATE:
2430 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002431 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002432 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002433 psessionEntry->limPrevSmeState =
2434 psessionEntry->limSmeState;
2435 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002436 /* Delete all TDLS peers connected before leaving BSS */
2437 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002438 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2439 psessionEntry->peSessionId,
2440 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002441 break;
2442
2443 case eLIM_SME_WT_DEAUTH_STATE:
2444 /* PE shall still process the DISASSOC_REQ and proceed with
2445 * link tear down even if it had already sent a DEAUTH_IND to
2446 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2447 * its been set when PE entered WT_DEAUTH_STATE.
2448 */
2449 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2450 MTRACE(mac_trace
2451 (pMac, TRACE_CODE_SME_STATE,
2452 psessionEntry->peSessionId,
2453 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002454 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002455 break;
2456
2457 case eLIM_SME_WT_DISASSOC_STATE:
2458 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2459 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2460 * PE can continue processing DISASSOC_REQ and send the response instead
2461 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2462 * for disassoc frame.
2463 *
2464 * It will send a disassoc, which is ok. However, we can use the global flag
2465 * sendDisassoc to not send disassoc frame.
2466 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002467 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002468 break;
2469
2470 case eLIM_SME_JOIN_FAILURE_STATE: {
2471 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002472 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002473 if (pMac->lim.gLimRspReqd) {
2474 retCode = eSIR_SME_SUCCESS;
2475 disassocTrigger = eLIM_HOST_DISASSOC;
2476 goto sendDisassoc;
2477 }
2478 }
2479 break;
2480 default:
2481 /**
2482 * STA is not currently associated.
2483 * Log error and send response to host
2484 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002485 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002486 psessionEntry->limSmeState);
2487 lim_print_sme_state(pMac, LOGE,
2488 psessionEntry->limSmeState);
2489
2490 if (pMac->lim.gLimRspReqd) {
2491 if (psessionEntry->limSmeState !=
2492 eLIM_SME_WT_ASSOC_STATE)
2493 pMac->lim.gLimRspReqd = false;
2494
2495 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2496 disassocTrigger = eLIM_HOST_DISASSOC;
2497 goto sendDisassoc;
2498 }
2499
2500 return;
2501 }
2502
2503 break;
2504
2505 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002506 /* Fall through */
2507 break;
2508
2509 case eLIM_STA_IN_IBSS_ROLE:
2510 default:
2511 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002512 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002513 GET_LIM_SYSTEM_ROLE(psessionEntry));
2514
2515 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2516 disassocTrigger = eLIM_HOST_DISASSOC;
2517 goto sendDisassoc;
2518 } /* end switch (pMac->lim.gLimSystemRole) */
2519
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302520 disassocTrigger = eLIM_HOST_DISASSOC;
2521 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002522
2523 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002524 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002525 send_disassoc_frame = 0;
2526 }
2527 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002528 pe_debug("Sending Disasscoc with disassoc Trigger"
2529 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002530 disassocTrigger, reasonCode);
2531
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302532 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002533 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002534 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002535 return;
2536 }
2537
Anurag Chouhanc5548422016-02-24 18:33:27 +05302538 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002539 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002540
2541 pMlmDisassocReq->reasonCode = reasonCode;
2542 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2543
2544 /* Update PE session ID */
2545 pMlmDisassocReq->sessionId = sessionId;
2546
2547 lim_post_mlm_message(pMac,
2548 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2549 return;
2550
2551sendDisassoc:
2552 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002553 lim_send_sme_disassoc_ntf(pMac,
2554 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002555 retCode,
2556 disassocTrigger,
2557 1, smesessionId, smetransactionId,
2558 psessionEntry);
2559 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002560 lim_send_sme_disassoc_ntf(pMac,
2561 smeDisassocReq.peer_macaddr.bytes,
2562 retCode, disassocTrigger, 1,
2563 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002564
2565} /*** end __lim_process_sme_disassoc_req() ***/
2566
2567/** -----------------------------------------------------------------
2568 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2569
2570 This function is called to process SME_DISASSOC_CNF message
2571 from HDD or upper layer application.
2572
2573 \param pMac - global mac structure
2574 \param pStaDs - station dph hash node
2575 \return none
2576 \sa
2577 ----------------------------------------------------------------- */
2578static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2579{
2580 tSirSmeDisassocCnf smeDisassocCnf;
2581 uint16_t aid;
2582 tpDphHashNode pStaDs;
2583 tpPESession psessionEntry;
2584 uint8_t sessionId;
2585
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302586 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002587 sizeof(struct sSirSmeDisassocCnf));
2588
2589 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002590 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002591 &sessionId);
2592 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002593 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002594 return;
2595 }
2596
2597 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002598 pe_err("received invalid SME_DISASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002599 return;
2600 }
2601#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2602 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2603 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2604 psessionEntry,
2605 (uint16_t) smeDisassocCnf.statusCode, 0);
2606 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2607 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2608 psessionEntry,
2609 (uint16_t) smeDisassocCnf.statusCode, 0);
2610#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2611
2612 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2613 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002614 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2615 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2616 && (psessionEntry->limSmeState !=
2617 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002618 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002619 psessionEntry->limSmeState);
2620 lim_print_sme_state(pMac, LOGE,
2621 psessionEntry->limSmeState);
2622 return;
2623 }
2624 break;
2625
2626 case eLIM_AP_ROLE:
2627 /* Fall through */
2628 break;
2629
2630 case eLIM_STA_IN_IBSS_ROLE:
2631 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002632 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002633 GET_LIM_SYSTEM_ROLE(psessionEntry));
2634
2635 return;
2636 }
2637
2638 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2639 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2640 LIM_IS_AP_ROLE(psessionEntry)) {
2641 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002642 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002643 &psessionEntry->dph.dphHashTable);
2644 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002645 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2646 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002647 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002648 return;
2649 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302650
2651 if ((pStaDs->mlmStaContext.mlmState ==
2652 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2653 (pStaDs->mlmStaContext.mlmState ==
2654 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002655 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002656 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302657 pStaDs->mlmStaContext.mlmState);
2658 return;
2659 }
2660
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002661 /* Delete FT session if there exists one */
2662 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002663 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2664
2665 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002666 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002667 }
2668
2669 return;
2670}
2671
2672/**
2673 * __lim_process_sme_deauth_req() - process sme deauth req
2674 * @mac_ctx: Pointer to Global MAC structure
2675 * @msg_buf: pointer to the SME message buffer
2676 *
2677 * This function is called to process SME_DEAUTH_REQ message
2678 * from HDD or upper layer application.
2679 *
2680 * Return: None
2681 */
2682
2683static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2684 uint32_t *msg_buf)
2685{
2686 uint16_t deauth_trigger, reason_code;
2687 tLimMlmDeauthReq *mlm_deauth_req;
2688 tSirSmeDeauthReq sme_deauth_req;
2689 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2690 tpPESession session_entry;
2691 uint8_t session_id; /* PE sessionId */
2692 uint8_t sme_session_id;
2693 uint16_t sme_transaction_id;
2694
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302695 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002696 sme_session_id = sme_deauth_req.sessionId;
2697 sme_transaction_id = sme_deauth_req.transactionId;
2698
2699 /*
2700 * We need to get a session first but we don't even know
2701 * if the message is correct.
2702 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002703 session_entry = pe_find_session_by_bssid(mac_ctx,
2704 sme_deauth_req.bssid.bytes,
2705 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002706 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002707 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002708 ret_code = eSIR_SME_INVALID_PARAMETERS;
2709 deauth_trigger = eLIM_HOST_DEAUTH;
2710 goto send_deauth;
2711 }
2712
2713 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2714 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002715 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002716 mac_ctx->lim.gLimRspReqd = false;
2717
2718 ret_code = eSIR_SME_INVALID_PARAMETERS;
2719 deauth_trigger = eLIM_HOST_DEAUTH;
2720 goto send_deauth;
2721 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002722 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2723 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002724 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2725 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002726 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002727#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2728 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2729 session_entry, 0, sme_deauth_req.reasonCode);
2730#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2731
2732 /* Update SME session ID and Transaction ID */
2733 session_entry->smeSessionId = sme_session_id;
2734 session_entry->transactionId = sme_transaction_id;
2735
2736 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2737 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002738 switch (session_entry->limSmeState) {
2739 case eLIM_SME_ASSOCIATED_STATE:
2740 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302741 /* Delete all TDLS peers connected before leaving BSS */
2742 lim_delete_tdls_peers(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002743 case eLIM_SME_WT_ASSOC_STATE:
2744 case eLIM_SME_JOIN_FAILURE_STATE:
2745 case eLIM_SME_IDLE_STATE:
2746 session_entry->limPrevSmeState =
2747 session_entry->limSmeState;
2748 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2749 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2750 session_entry->peSessionId,
2751 session_entry->limSmeState));
2752 /* Send Deauthentication request to MLM below */
2753 break;
2754 case eLIM_SME_WT_DEAUTH_STATE:
2755 case eLIM_SME_WT_DISASSOC_STATE:
2756 /*
2757 * PE Recieved a Deauth/Disassoc frame. Normally it get
2758 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2759 * Which means host is also trying to disconnect.
2760 * PE can continue processing DEAUTH_REQ and send
2761 * the response instead of failing the request.
2762 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2763 * was sent for deauth/disassoc frame.
2764 */
2765 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002766 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002767 break;
2768 default:
2769 /*
2770 * STA is not in a state to deauthenticate with
2771 * peer. Log error and send response to host.
2772 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002773 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002774 session_entry->limSmeState);
2775 lim_print_sme_state(mac_ctx, LOGE,
2776 session_entry->limSmeState);
2777
2778 if (mac_ctx->lim.gLimRspReqd) {
2779 mac_ctx->lim.gLimRspReqd = false;
2780
2781 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2782 deauth_trigger = eLIM_HOST_DEAUTH;
2783
wadesong42968e92017-06-08 14:11:21 +08002784 /*
2785 * here we received deauth request from AP so
2786 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2787 * have ISSUED delSta then mlm state should be
2788 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2789 * delBSS rsp then mlm state should be
2790 * eLIM_MLM_IDLE_STATE so the below condition
2791 * captures the state where delSta not done
2792 * and firmware still in connected state.
2793 */
2794 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002795 eLIM_SME_WT_DEAUTH_STATE &&
2796 session_entry->limMlmState !=
2797 eLIM_MLM_IDLE_STATE &&
2798 session_entry->limMlmState !=
2799 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002800 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002801 goto send_deauth;
2802 }
2803 return;
2804 }
2805 break;
2806
2807 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002808 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002809 if (mac_ctx->lim.gLimRspReqd) {
2810 mac_ctx->lim.gLimRspReqd = false;
2811 ret_code = eSIR_SME_INVALID_PARAMETERS;
2812 deauth_trigger = eLIM_HOST_DEAUTH;
2813 goto send_deauth;
2814 }
2815 return;
2816 case eLIM_AP_ROLE:
2817 break;
2818 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002819 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002820 GET_LIM_SYSTEM_ROLE(session_entry));
2821 if (mac_ctx->lim.gLimRspReqd) {
2822 mac_ctx->lim.gLimRspReqd = false;
2823 ret_code = eSIR_SME_INVALID_PARAMETERS;
2824 deauth_trigger = eLIM_HOST_DEAUTH;
2825 goto send_deauth;
2826 }
2827 return;
2828 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2829
2830 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2831 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002832 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002833 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2834 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2835 } else {
2836 deauth_trigger = eLIM_HOST_DEAUTH;
2837 reason_code = sme_deauth_req.reasonCode;
2838 }
2839
2840 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302841 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002842 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002843 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002844 if (mac_ctx->lim.gLimRspReqd) {
2845 mac_ctx->lim.gLimRspReqd = false;
2846 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2847 deauth_trigger = eLIM_HOST_DEAUTH;
2848 goto send_deauth;
2849 }
2850 return;
2851 }
2852
Anurag Chouhanc5548422016-02-24 18:33:27 +05302853 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002854 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002855
2856 mlm_deauth_req->reasonCode = reason_code;
2857 mlm_deauth_req->deauthTrigger = deauth_trigger;
2858
2859 /* Update PE session Id */
2860 mlm_deauth_req->sessionId = session_id;
2861
2862 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2863 (uint32_t *)mlm_deauth_req);
2864 return;
2865
2866send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002867 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2868 ret_code, deauth_trigger, 1,
2869 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002870}
2871
2872/**
2873 * __lim_process_sme_set_context_req()
2874 *
2875 * @mac_ctx: Pointer to Global MAC structure
2876 * @msg_buf: pointer to the SME message buffer
2877 *
2878 * This function is called to process SME_SETCONTEXT_REQ message
2879 * from HDD or upper layer application.
2880 *
2881 * Return: None
2882 */
2883
2884static void
2885__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2886{
2887 tpSirSmeSetContextReq set_context_req;
2888 tLimMlmSetKeysReq *mlm_set_key_req;
2889 tpPESession session_entry;
2890 uint8_t session_id; /* PE sessionID */
2891 uint8_t sme_session_id;
2892 uint16_t sme_transaction_id;
2893
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002894 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002895 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002896 return;
2897 }
2898
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302899 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002900 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002901 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002902 return;
2903 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302904 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002905 sizeof(struct sSirSmeSetContextReq));
2906 sme_session_id = set_context_req->sessionId;
2907 sme_transaction_id = set_context_req->transactionId;
2908
2909 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002910 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002911 goto end;
2912 }
2913
2914 if (set_context_req->keyMaterial.numKeys >
2915 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002916 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002917 set_context_req->keyMaterial.numKeys);
2918 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002919 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002920 eSIR_SME_INVALID_PARAMETERS, NULL,
2921 sme_session_id, sme_transaction_id);
2922 goto end;
2923 }
2924
2925 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002926 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002927 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002928 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002930 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002931 eSIR_SME_INVALID_PARAMETERS, NULL,
2932 sme_session_id, sme_transaction_id);
2933 goto end;
2934 }
2935#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2936 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2937 session_entry, 0, 0);
2938#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2939
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002940 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002941 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2942 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002943 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002944 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2945 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302946 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002947 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002948 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002949 goto end;
2950 }
2951 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2952 mlm_set_key_req->numKeys =
2953 set_context_req->keyMaterial.numKeys;
2954 if (mlm_set_key_req->numKeys >
2955 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002956 pe_err("no.of keys exceeded max num of default keys limit");
Jingxiang Ge4168a232018-01-03 18:47:15 +08002957 qdf_mem_free(mlm_set_key_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002958 goto end;
2959 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302960 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002961 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302963 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002964 (uint8_t *) &set_context_req->keyMaterial.key,
2965 sizeof(tSirKeys) *
2966 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2967 numKeys : 1));
2968
2969 mlm_set_key_req->sessionId = session_id;
2970 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002971 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002972 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002973
2974 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2975 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2976 LIM_IS_AP_ROLE(session_entry)) {
2977 if (set_context_req->keyMaterial.key[0].keyLength) {
2978 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002979
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002980 key_id =
2981 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302982 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002983 &session_entry->WEPKeyMaterial[key_id],
2984 (uint8_t *) &set_context_req->keyMaterial,
2985 sizeof(tSirKeyMaterial));
2986 } else {
2987 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002988
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002989 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2990 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302991 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002992 &mlm_set_key_req->key[i],
2993 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2994 sizeof(tSirKeys));
2995 }
2996 }
2997 }
2998 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2999 (uint32_t *) mlm_set_key_req);
3000 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003001 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003002 GET_LIM_SYSTEM_ROLE(session_entry),
3003 session_entry->limSmeState);
3004 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3005
3006 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003007 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003008 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3009 session_entry, sme_session_id,
3010 sme_transaction_id);
3011 }
3012end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303013 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003014 return;
3015}
3016
3017/**
3018 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3019 *
3020 * @mac_ctx: Pointer to Global MAC structure
3021 * @msg_buf: pointer to the SME message buffer
3022 *
3023 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3024 * from HDD or upper layer application.
3025 *
3026 * Return: None
3027 */
3028
Jeff Johnson801f1532016-10-07 07:54:50 -07003029static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3030 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003031{
3032 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3033 tpDphHashNode sta_ds = NULL;
3034 tpPESession session_entry = NULL;
3035 tSap_Event sap_event;
3036 tpWLAN_SAPEventCB sap_event_cb = NULL;
3037 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3038 uint8_t session_id = CSR_SESSION_ID_INVALID;
3039 uint8_t assoc_id = 0;
3040 uint8_t sta_cnt = 0;
3041
3042 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003043 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003044 return;
3045 }
3046
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303047 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003048 sizeof(struct sSirSmeGetAssocSTAsReq));
3049 /*
3050 * Get Associated stations from PE.
3051 * Find PE session Entry
3052 */
3053 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003054 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055 &session_id);
3056 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003057 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058 goto lim_assoc_sta_end;
3059 }
3060
3061 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003062 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003063 session_entry->limSmeState,
3064 GET_LIM_SYSTEM_ROLE(session_entry));
3065 goto lim_assoc_sta_end;
3066 }
3067 /* Retrieve values obtained in the request message */
3068 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3069 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3070
3071 if (NULL == assoc_sta_tmp)
3072 goto lim_assoc_sta_end;
3073 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3074 assoc_id++) {
3075 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3076 &session_entry->dph.dphHashTable);
3077 if (NULL == sta_ds)
3078 continue;
3079 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303080 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003081 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303082 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003083 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3084 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3085
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303086 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003087 (uint8_t *)&sta_ds->supportedRates,
3088 sizeof(tSirSupportedRates));
3089 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3090 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3091 assoc_sta_tmp->Support40Mhz =
3092 sta_ds->htDsssCckRate40MHzSupport;
3093
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003094 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003095 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003096 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003097 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003098 pe_debug("Association Id: %d Station Index: %d",
3099 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003100 assoc_sta_tmp++;
3101 sta_cnt++;
3102 }
3103 }
3104lim_assoc_sta_end:
3105 /*
3106 * Call hdd callback with sap event to send the list of
3107 * associated stations from PE
3108 */
3109 if (sap_event_cb != NULL) {
3110 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3111 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303112 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003113 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3114 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3115 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3116 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3117 }
3118}
3119
3120/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003121 * __lim_counter_measures()
3122 *
3123 * FUNCTION:
3124 * This function is called to "implement" MIC counter measure
3125 * and is *temporary* only
3126 *
3127 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3128 * we don't do the proper STA disassoc sequence since the
3129 * BSS will be stoped anyway
3130 *
3131 ***ASSUMPTIONS:
3132 *
3133 ***NOTE:
3134 *
3135 * @param pMac Pointer to Global MAC structure
3136 * @return None
3137 */
3138
3139static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3140{
3141 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003142
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003143 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003144 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3145 mac, psessionEntry, false);
3146};
3147
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003148static void
3149__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3150{
3151 tSirSmeStopBssReq stopBssReq;
3152 tSirRetStatus status;
3153 tLimSmeStates prevState;
3154 tpPESession psessionEntry;
3155 uint8_t smesessionId;
3156 uint8_t sessionId;
3157 uint16_t smetransactionId;
3158 uint8_t i = 0;
3159 tpDphHashNode pStaDs = NULL;
3160
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303161 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003162 smesessionId = stopBssReq.sessionId;
3163 smetransactionId = stopBssReq.transactionId;
3164
3165 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003166 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003167 /* Send Stop BSS response to host */
3168 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3169 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3170 smetransactionId);
3171 return;
3172 }
3173
3174 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003175 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003176 &sessionId);
3177 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003178 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003179 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3180 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3181 smetransactionId);
3182 return;
3183 }
3184#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3185 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3186 0, 0);
3187#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3188
3189 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3190 LIM_IS_STA_ROLE(psessionEntry)) {
3191 /**
3192 * Should not have received STOP_BSS_REQ in states
3193 * other than 'normal' state or on STA in Infrastructure
3194 * mode. Log error and return response to host.
3195 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003196 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003197 psessionEntry->limSmeState,
3198 GET_LIM_SYSTEM_ROLE(psessionEntry));
3199 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3200 /* / Send Stop BSS response to host */
3201 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3202 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3203 smetransactionId);
3204 return;
3205 }
3206
3207 if (LIM_IS_AP_ROLE(psessionEntry))
3208 lim_wpspbc_close(pMac, psessionEntry);
3209
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003210 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003211 stopBssReq.reasonCode);
3212
3213 prevState = psessionEntry->limSmeState;
3214
3215 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3216 MTRACE(mac_trace
3217 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3218 psessionEntry->limSmeState));
3219
3220 /* Update SME session Id and Transaction Id */
3221 psessionEntry->smeSessionId = smesessionId;
3222 psessionEntry->transactionId = smetransactionId;
3223
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003224 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3225 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3226 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003227 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003228
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003229 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3230 /* Send disassoc all stations associated thru TKIP */
3231 __lim_counter_measures(pMac, psessionEntry);
3232 else
3233 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003234 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3235 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003236 }
3237
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003238 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3239 /* Free the buffer allocated in START_BSS_REQ */
3240 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3241 psessionEntry->addIeParams.probeRespDataLen = 0;
3242 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003244 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3245 psessionEntry->addIeParams.assocRespDataLen = 0;
3246 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003247
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003248 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3249 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3250 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003251
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003252 /*
3253 * lim_del_bss is also called as part of coalescing,
3254 * when we send DEL BSS followed by Add Bss msg.
3255 */
3256 pMac->lim.gLimIbssCoalescingHappened = false;
3257 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003258 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3259 pStaDs =
3260 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3261 if (NULL == pStaDs)
3262 continue;
3263 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3264 if (eSIR_SUCCESS == status) {
3265 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3266 pStaDs->assocId, psessionEntry);
3267 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3268 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003269 pe_err("lim_del_sta failed with Status: %d", status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303270 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003271 }
3272 }
3273 /* send a delBss to HAL and wait for a response */
3274 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3275
3276 if (status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003277 pe_err("delBss failed for bss %d", psessionEntry->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003278 psessionEntry->limSmeState = prevState;
3279
3280 MTRACE(mac_trace
3281 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3282 psessionEntry->limSmeState));
3283
3284 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3285 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3286 smetransactionId);
3287 }
3288}
3289
3290/**
3291 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3292 * @pMac: Global MAC context
3293 * @pMsg: Message from SME
3294 *
3295 * Wrapper for the function __lim_handle_sme_stop_bss_request
3296 * This message will be defered until softmac come out of
3297 * scan mode. Message should be handled even if we have
3298 * detected radar in the current operating channel.
3299 *
3300 * Return: true - If we consumed the buffer
3301 * false - If have defered the message.
3302 */
3303
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003304static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3305 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003306{
3307 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3308 /**
3309 * If message defered, buffer is not consumed yet.
3310 * So return false
3311 */
3312 return false;
3313 }
3314 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3315 return true;
3316} /*** end __lim_process_sme_stop_bss_req() ***/
3317
3318void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3319 uint32_t body, tpPESession psessionEntry)
3320{
3321
3322 (void)body;
3323 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3324 lim_ibss_delete(pMac, psessionEntry);
3325 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3326 lim_delete_pre_auth_list(pMac);
3327 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3328 psessionEntry->smeSessionId,
3329 psessionEntry->transactionId);
3330 return;
3331}
3332
3333/**
3334 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3335 *
3336 * @mac_ctx: pointer to mac context
3337 * @msg_type: message type
3338 * @msg_buf: pointer to the SME message buffer
3339 *
3340 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3341 * in BTAMP AP.
3342 *
3343 * Return: None
3344 */
3345
3346void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3347 uint32_t *msg_buf)
3348{
3349 tSirSmeAssocCnf assoc_cnf;
3350 tpDphHashNode sta_ds = NULL;
3351 tpPESession session_entry = NULL;
3352 uint8_t session_id;
3353 tpSirAssocReq assoc_req;
3354
3355 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003356 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003357 goto end;
3358 }
3359
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303360 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003361 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003362 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003363 goto end;
3364 }
3365
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003366 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003367 &session_id);
3368 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003369 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003370 goto end;
3371 }
3372
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003373 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003374 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3375 (session_entry->limSmeState !=
3376 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003377 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003378 msg_type, session_entry->limSmeState,
3379 GET_LIM_SYSTEM_ROLE(session_entry));
3380 goto end;
3381 }
3382 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3383 &session_entry->dph.dphHashTable);
3384 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003385 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003386 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303387 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003388
3389 /*
3390 * send a DISASSOC_IND message to WSM to make sure
3391 * the state in WSM and LIM is the same
3392 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003393 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003394 eSIR_SME_STA_NOT_ASSOCIATED,
3395 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3396 session_entry->smeSessionId,
3397 session_entry->transactionId,
3398 session_entry);
3399 goto end;
3400 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303401 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003402 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303403 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003404 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003405 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303406 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003407 goto end;
3408 }
3409
3410 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3411 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3412 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3413 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3414 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003415 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3416 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003417 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303418 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003419 goto end;
3420 }
3421 /*
3422 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3423 * has been received
3424 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003425 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003426 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3427 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3428
3429 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3430 /*
3431 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3432 * when it had received Assoc Request frame. Now, PE just needs
3433 * to send association rsp frame to the requesting BTAMP-STA.
3434 */
3435 sta_ds->mlmStaContext.mlmState =
3436 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003437 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003438 sta_ds->assocId);
3439 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3440 sta_ds->assocId, sta_ds->staAddr,
3441 sta_ds->mlmStaContext.subType, sta_ds,
3442 session_entry);
3443 goto end;
3444 } else {
3445 /*
3446 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3447 * to be associated since the HAL sta entry is created for
3448 * denied STA we need to remove this HAL entry.
3449 * So to do that set updateContext to 1
3450 */
3451 if (!sta_ds->mlmStaContext.updateContext)
3452 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003453 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003454 assoc_cnf.statusCode, sta_ds->assocId);
3455 lim_reject_association(mac_ctx, sta_ds->staAddr,
3456 sta_ds->mlmStaContext.subType,
3457 true, sta_ds->mlmStaContext.authType,
3458 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003459 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003460 session_entry);
3461 }
3462end:
3463 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3464 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3465 assoc_req = (tpSirAssocReq)
3466 session_entry->parsedAssocReq[sta_ds->assocId];
3467 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303468 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003469 assoc_req->assocReqFrame = NULL;
3470 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303471 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003472 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3473 }
3474}
3475
3476static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3477{
3478 tpDphHashNode pStaDs;
3479 tSirMacAddr peerMac;
3480 tpSirAddtsReq pSirAddts;
3481 uint32_t timeout;
3482 tpPESession psessionEntry;
3483 uint8_t sessionId; /* PE sessionId */
3484 uint8_t smesessionId;
3485 uint16_t smetransactionId;
3486
3487 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003488 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003489 return;
3490 }
3491
3492 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3493 &smetransactionId);
3494
3495 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3496
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003497 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3498 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003499 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003500 pe_err("Session Does not exist for given bssId");
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303501 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3502 NULL, pSirAddts->req.tspec,
3503 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003504 return;
3505 }
3506#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3507 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3508 0);
3509#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3510
3511 /* if sta
3512 * - verify assoc state
3513 * - send addts request to ap
3514 * - wait for addts response from ap
3515 * if ap, just ignore with error log
3516 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003517 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3518 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3519 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003520
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003521 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003522 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303523 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003524 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003525
3526 pStaDs =
3527 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3528 &psessionEntry->dph.dphHashTable);
3529
3530 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003531 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303532 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003533 }
3534
3535 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3536 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003537 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303538 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003539 }
3540
3541 pSirAddts->req.wsmTspecPresent = 0;
3542 pSirAddts->req.wmeTspecPresent = 0;
3543 pSirAddts->req.lleTspecPresent = 0;
3544
3545 if ((pStaDs->wsmEnabled) &&
3546 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3547 SIR_MAC_ACCESSPOLICY_EDCA))
3548 pSirAddts->req.wsmTspecPresent = 1;
3549 else if (pStaDs->wmeEnabled)
3550 pSirAddts->req.wmeTspecPresent = 1;
3551 else if (pStaDs->lleEnabled)
3552 pSirAddts->req.lleTspecPresent = 1;
3553 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003554 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303555 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003556 }
3557
3558 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3559 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003560 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003561 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303562 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003563 }
3564
3565 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003566 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003567 pMac->lim.gLimAddtsReq.req.dialogToken,
3568 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3569 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3570 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303571 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003572 }
3573
3574 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3575
3576 /* save the addts request */
3577 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303578 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003579 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3580
3581 /* ship out the message now */
3582 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3583 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303584 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003585 /* start a timer to wait for the response */
3586 if (pSirAddts->timeout)
3587 timeout = pSirAddts->timeout;
3588 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3589 eSIR_SUCCESS) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303590 pe_debug("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003591 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303592 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003593 }
3594
3595 timeout = SYS_MS_TO_TICKS(timeout);
3596 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3597 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003598 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303599 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003600 }
3601 pMac->lim.gLimAddtsRspTimerCount++;
3602 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3603 pMac->lim.gLimAddtsRspTimerCount) !=
3604 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003605 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303606 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003607 }
3608 MTRACE(mac_trace
3609 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3610 eLIM_ADDTS_RSP_TIMER));
3611
3612 /* add the sessionId to the timer object */
3613 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3614 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3615 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003616 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303617 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618 }
3619 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303620
3621send_failure_addts_rsp:
3622 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3623 psessionEntry, pSirAddts->req.tspec,
3624 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003625}
3626
3627static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3628{
3629 tSirMacAddr peerMacAddr;
3630 uint8_t ac;
3631 tSirMacTSInfo *pTsinfo;
3632 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3633 tpDphHashNode pStaDs = NULL;
3634 tpPESession psessionEntry;
3635 uint8_t sessionId;
3636 uint32_t status = eSIR_SUCCESS;
3637 uint8_t smesessionId;
3638 uint16_t smetransactionId;
3639
3640 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3641 &smetransactionId);
3642
3643 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003644 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003645 &sessionId);
3646 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003647 pe_err("Session Does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003648 status = eSIR_FAILURE;
3649 goto end;
3650 }
3651#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3652 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3653 0);
3654#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3655
3656 if (eSIR_SUCCESS !=
3657 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003658 pe_err("lim_validate_delts_req failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003659 status = eSIR_FAILURE;
3660 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3661 smesessionId, smetransactionId);
3662 return;
3663 }
3664
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003665 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3666 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003667 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3668
3669 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3670 pDeltsReq->req.wmeTspecPresent,
3671 &pDeltsReq->req.tsinfo,
3672 &pDeltsReq->req.tspec, psessionEntry);
3673
3674 pTsinfo =
3675 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3676 tsinfo : &pDeltsReq->req.tsinfo;
3677
3678 /* We've successfully send DELTS frame to AP. Update the
3679 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3680 * is no longer trigger enabled or delivery enabled
3681 */
3682 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3683 pTsinfo, CLEAR_UAPSD_MASK);
3684
3685 /* We're deleting the TSPEC, so this particular AC is no longer
3686 * admitted. PE needs to downgrade the EDCA
3687 * parameters(for the AC for which TS is being deleted) to the
3688 * next best AC for which ACM is not enabled, and send the
3689 * updated values to HAL.
3690 */
3691 ac = upToAc(pTsinfo->traffic.userPrio);
3692
3693 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3694 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3695 ~(1 << ac);
3696 } else if (pTsinfo->traffic.direction ==
3697 SIR_MAC_DIRECTION_DNLINK) {
3698 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3699 ~(1 << ac);
3700 } else if (pTsinfo->traffic.direction ==
3701 SIR_MAC_DIRECTION_BIDIR) {
3702 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3703 ~(1 << ac);
3704 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3705 ~(1 << ac);
3706 }
3707
3708 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3709 psessionEntry);
3710
3711 pStaDs =
3712 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3713 &psessionEntry->dph.dphHashTable);
3714 if (pStaDs != NULL) {
3715 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3716 pStaDs->bssId);
3717 status = eSIR_SUCCESS;
3718 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003719 pe_err("Self entry missing in Hash Table");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003720 status = eSIR_FAILURE;
3721 }
3722#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003723 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003724#endif
3725
3726 /* send an sme response back */
3727end:
3728 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3729 smesessionId, smetransactionId);
3730}
3731
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303732void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003733{
3734 /* fetch the sessionEntry based on the sessionId */
3735 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003736
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003737 psessionEntry = pe_find_session_by_session_id(pMac,
3738 pMac->lim.limTimers.gLimAddtsRspTimer.
3739 sessionId);
3740 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003741 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003742 return;
3743 }
3744
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003745 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003746 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003747 GET_LIM_SYSTEM_ROLE(psessionEntry));
3748 pMac->lim.gLimAddtsSent = false;
3749 return;
3750 }
3751
3752 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003753 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003754 return;
3755 }
3756
3757 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003758 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003759 pMac->lim.gLimAddtsRspTimerCount);
3760 return;
3761 }
3762 /* this a real response timeout */
3763 pMac->lim.gLimAddtsSent = false;
3764 pMac->lim.gLimAddtsRspTimerCount++;
3765
3766 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3767 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3768 psessionEntry->smeSessionId,
3769 psessionEntry->transactionId);
3770}
3771
3772/**
3773 * __lim_process_sme_get_statistics_request()
3774 *
3775 ***FUNCTION:
3776 *
3777 *
3778 ***NOTE:
3779 *
3780 * @param pMac Pointer to Global MAC structure
3781 * @param *pMsgBuf A pointer to the SME message buffer
3782 * @return None
3783 */
3784static void
3785__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3786{
3787 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003788 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003789
3790 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3791
3792 msgQ.type = WMA_GET_STATISTICS_REQ;
3793
3794 msgQ.reserved = 0;
3795 msgQ.bodyptr = pMsgBuf;
3796 msgQ.bodyval = 0;
3797 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3798
3799 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303800 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003801 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003802 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003803 return;
3804 }
3805
3806 return;
3807}
3808
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003809#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003810/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003811 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003812 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003813 * @pMac: Pointer to Global MAC structure
3814 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003815 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003816 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003817 */
3818static void
3819__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3820{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003821 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003822
3823 msgQ.type = WMA_TSM_STATS_REQ;
3824 msgQ.reserved = 0;
3825 msgQ.bodyptr = pMsgBuf;
3826 msgQ.bodyval = 0;
3827 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3828
3829 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303830 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003831 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003832 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003833 return;
3834 }
3835}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003836#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003837
Naveen Rawat8029a402017-06-01 10:54:19 -07003838static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3839 struct update_config *msg)
3840{
3841 tpPESession pe_session;
3842
3843 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3844 if (msg == NULL) {
3845 pe_err("Buffer is Pointing to NULL");
3846 return;
3847 }
3848
3849 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3850 msg->sme_session_id);
3851 if (pe_session == NULL) {
3852 pe_warn("Session does not exist for given BSSID");
3853 return;
3854 }
3855
3856 switch (msg->capab) {
3857 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3858 pe_session->htConfig.ht_rx_ldpc = msg->value;
3859 break;
3860 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3861 pe_session->htConfig.ht_tx_stbc = msg->value;
3862 break;
3863 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3864 pe_session->htConfig.ht_rx_stbc = msg->value;
3865 break;
3866 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3867 pe_session->htConfig.ht_sgi20 = msg->value;
3868 break;
3869 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3870 pe_session->htConfig.ht_sgi40 = msg->value;
3871 break;
3872 }
3873
3874 if (LIM_IS_AP_ROLE(pe_session)) {
3875 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3876 lim_send_beacon_ind(mac_ctx, pe_session);
3877 }
3878}
3879
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003880void
3881lim_send_vdev_restart(tpAniSirGlobal pMac,
3882 tpPESession psessionEntry, uint8_t sessionId)
3883{
3884 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003885 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003886 tSirRetStatus retCode = eSIR_SUCCESS;
3887
3888 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003889 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003890 return;
3891 }
3892
3893 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303894 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003895 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003896 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003897 return;
3898 }
3899
3900 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3901 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003902 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003903
3904 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3905 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3906 msgQ.bodyval = 0;
3907
3908 retCode = wma_post_ctrl_msg(pMac, &msgQ);
3909 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003910 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303911 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003912 }
3913}
3914
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303915/**
3916 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3917 * @mac_ctx: Pointer to Global MAC structure
3918 * @msg_buf: Pointer to SME message buffer
3919 *
3920 * Return: None
3921 */
3922static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3923 uint32_t *msg_buf)
3924{
3925 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003926 struct scheduler_msg wma_msg = {0};
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303927 tSirRetStatus status;
3928 tSirRoamOffloadScanReq *req_buffer;
3929 uint16_t local_ie_len;
3930 uint8_t *local_ie_buf;
3931
3932 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3933 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3934 req_buffer->sessionId);
3935
3936 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3937 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003938 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303939 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303940 return;
3941 }
3942
3943 local_ie_len = req_buffer->assoc_ie.length;
3944 /* Update ext cap IE if present */
3945 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003946 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3947 local_ie_buf, &local_ie_len)) {
3948 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003949 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3950 req_buffer->assoc_ie.length = local_ie_len;
3951 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3952 local_ie_buf, local_ie_len);
3953 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303954 }
3955 qdf_mem_free(local_ie_buf);
3956
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303957 if (pe_session)
3958 lim_update_fils_rik(pe_session, req_buffer);
3959
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303960 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3961 wma_msg.bodyptr = req_buffer;
3962
3963 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
3964 if (eSIR_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003965 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303966 qdf_mem_free(req_buffer);
3967 }
3968}
3969
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303970/*
3971 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3972 * @mac_ctx: Pointer to global mac context
3973 * @session: Pointer to PE session
3974 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3975 * 1 - Disable broadcast SSID
3976 *
3977 * Return: None
3978 */
3979static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3980 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003981{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003982 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003983 session->ssidHidden, ssid_hidden);
3984
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003985 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303986 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003987 } else {
3988 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05303989 return;
3990 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003991
3992 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303993 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003994
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003995 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303996}
3997
3998/**
3999 * __lim_process_sme_session_update - process SME session update msg
4000 *
4001 * @mac_ctx: Pointer to global mac context
4002 * @msg_buf: Pointer to the received message buffer
4003 *
4004 * Return: None
4005 */
4006static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
4007 uint32_t *msg_buf)
4008{
4009 struct sir_update_session_param *msg;
4010 tpPESession session;
4011
4012 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004013 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304014 return;
4015 }
4016
4017 msg = (struct sir_update_session_param *) msg_buf;
4018
4019 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
4020 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004021 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304022 msg->session_id);
4023 return;
4024 }
4025
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004026 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304027 msg->param_type, msg->param_val);
4028 switch (msg->param_type) {
4029 case SIR_PARAM_SSID_HIDDEN:
4030 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
4031 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05304032 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
4033 session->ignore_assoc_disallowed = msg->param_val;
4034 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304035 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004036 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304037 break;
4038 }
4039}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004040
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004041/*
4042 Update the beacon Interval dynamically if beaconInterval is different in MCC
4043 */
4044static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4045{
4046 tpSirChangeBIParams pChangeBIParams;
4047 tpPESession psessionEntry;
4048 uint8_t sessionId = 0;
4049 tUpdateBeaconParams beaconParams;
4050
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004051 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004052
4053 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004054 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004055 return;
4056 }
4057
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304058 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004059 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4060
4061 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004062 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004063 &sessionId);
4064 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004065 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004066 return;
4067 }
4068
4069 /*Update sessionEntry Beacon Interval */
4070 if (psessionEntry->beaconParams.beaconInterval !=
4071 pChangeBIParams->beaconInterval) {
4072 psessionEntry->beaconParams.beaconInterval =
4073 pChangeBIParams->beaconInterval;
4074 }
4075
4076 /*Update sch beaconInterval */
4077 if (pMac->sch.schObject.gSchBeaconInterval !=
4078 pChangeBIParams->beaconInterval) {
4079 pMac->sch.schObject.gSchBeaconInterval =
4080 pChangeBIParams->beaconInterval;
4081
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004082 pe_debug("LIM send update BeaconInterval Indication: %d",
4083 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004084
4085 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4086 /* Update beacon */
4087 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4088
4089 beaconParams.bssIdx = psessionEntry->bssIdx;
4090 /* Set change in beacon Interval */
4091 beaconParams.beaconInterval =
4092 pChangeBIParams->beaconInterval;
4093 beaconParams.paramChangeBitmap =
4094 PARAM_BCN_INTERVAL_CHANGED;
4095 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4096 }
4097 }
4098
4099 return;
4100} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4101
4102#ifdef QCA_HT_2040_COEX
4103static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4104 uint32_t *pMsgBuf)
4105{
4106 tpSirSetHT2040Mode pSetHT2040Mode;
4107 tpPESession psessionEntry;
4108 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004109 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004110 tUpdateVHTOpMode *pHtOpMode = NULL;
4111 uint16_t staId = 0;
4112 tpDphHashNode pStaDs = NULL;
4113
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004114 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004115 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004116 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004117 return;
4118 }
4119
4120 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4121
4122 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004123 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004124 &sessionId);
4125 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004126 pe_debug("Session does not exist for given BSSID");
4127 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004128 return;
4129 }
4130
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004131 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004132 pSetHT2040Mode->cbMode);
4133 /*Update sessionEntry HT related fields */
4134 switch (pSetHT2040Mode->cbMode) {
4135 case PHY_SINGLE_CHANNEL_CENTERED:
4136 psessionEntry->htSecondaryChannelOffset =
4137 PHY_SINGLE_CHANNEL_CENTERED;
4138 psessionEntry->htRecommendedTxWidthSet = 0;
4139 if (pSetHT2040Mode->obssEnabled)
4140 psessionEntry->htSupportedChannelWidthSet
4141 = eHT_CHANNEL_WIDTH_40MHZ;
4142 else
4143 psessionEntry->htSupportedChannelWidthSet
4144 = eHT_CHANNEL_WIDTH_20MHZ;
4145 break;
4146 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4147 psessionEntry->htSecondaryChannelOffset =
4148 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4149 psessionEntry->htRecommendedTxWidthSet = 1;
4150 break;
4151 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4152 psessionEntry->htSecondaryChannelOffset =
4153 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4154 psessionEntry->htRecommendedTxWidthSet = 1;
4155 break;
4156 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004157 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004158 return;
4159 }
4160
4161 /* Update beacon */
4162 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4163 lim_send_beacon_ind(pMac, psessionEntry);
4164
4165 /* update OP Mode for each associated peer */
4166 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4167 pStaDs = dph_get_hash_entry(pMac, staId,
4168 &psessionEntry->dph.dphHashTable);
4169 if (NULL == pStaDs)
4170 continue;
4171
4172 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304173 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004174 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004175 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004176 return;
4177 }
4178 pHtOpMode->opMode =
4179 (psessionEntry->htSecondaryChannelOffset ==
4180 PHY_SINGLE_CHANNEL_CENTERED) ?
4181 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4182 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304183 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004184 sizeof(tSirMacAddr));
4185 pHtOpMode->smesessionId = sessionId;
4186
4187 msg.type = WMA_UPDATE_OP_MODE;
4188 msg.reserved = 0;
4189 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004190 if (!QDF_IS_STATUS_SUCCESS
4191 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
4192 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304193 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004194 return;
4195 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004196 pe_debug("Notifed FW about OP mode: %d for staId=%d",
4197 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004198
4199 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004200 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201 }
4202
4203 return;
4204}
4205#endif
4206
4207/* -------------------------------------------------------------------- */
4208/**
4209 * __lim_process_report_message
4210 *
4211 * FUNCTION: Processes the next received Radio Resource Management message
4212 *
4213 * LOGIC:
4214 *
4215 * ASSUMPTIONS:
4216 *
4217 * NOTE:
4218 *
4219 * @param None
4220 * @return None
4221 */
4222
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004223static void __lim_process_report_message(tpAniSirGlobal pMac,
4224 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004225{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004226 switch (pMsg->type) {
4227 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4228 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4229 break;
4230 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004231 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004232 break;
4233 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004234 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004235 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004236}
4237
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004238/* -------------------------------------------------------------------- */
4239/**
4240 * lim_send_set_max_tx_power_req
4241 *
4242 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4243 *
4244 * LOGIC:
4245 *
4246 * ASSUMPTIONS:
4247 *
4248 * NOTE:
4249 *
4250 * @param txPower txPower to be set.
4251 * @param pSessionEntry session entry.
4252 * @return None
4253 */
4254tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004255lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004256 tpPESession pSessionEntry)
4257{
4258 tpMaxTxPowerParams pMaxTxParams = NULL;
4259 tSirRetStatus retCode = eSIR_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004260 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004261
4262 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004263 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004264 return eSIR_FAILURE;
4265 }
4266
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304267 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004268 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004269 pe_err("Unable to allocate memory for pMaxTxParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004270 return eSIR_MEM_ALLOC_FAILED;
4271
4272 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004273 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304274 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304275 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304276 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004277 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304278 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004279
4280 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4281 msgQ.bodyptr = pMaxTxParams;
4282 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004283 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004284 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4285 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4286 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004287 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304288 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004289 }
4290 return retCode;
4291}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004292
4293/**
4294 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4295 *
4296 * @mac_ctx: Pointer to Global MAC structure
4297 * @msg_buf: pointer to the SME message buffer
4298 *
4299 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4300 * from SME. It Register this information within PE.
4301 *
4302 * Return: None
4303 */
4304static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4305 uint32_t *msg_buf)
4306{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304307 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004308 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4309 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4310 struct mgmt_frm_reg_info *next = NULL;
4311 bool match = false;
4312
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004313 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004314 sme_req->registerFrame, sme_req->frameType,
4315 sme_req->matchLen);
4316 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304317 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304318 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4319 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304320 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004321
4322 while (lim_mgmt_regn != NULL) {
4323 if (lim_mgmt_regn->frameType != sme_req->frameType)
4324 goto skip_match;
4325 if (sme_req->matchLen) {
4326 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304327 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004328 sme_req->matchData,
4329 lim_mgmt_regn->matchLen))) {
4330 /* found match! */
4331 match = true;
4332 break;
4333 }
4334 } else {
4335 /* found match! */
4336 match = true;
4337 break;
4338 }
4339skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304340 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304341 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004342 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304343 (qdf_list_node_t *)lim_mgmt_regn,
4344 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304345 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004346 lim_mgmt_regn = next;
4347 next = NULL;
4348 }
4349 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304350 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004351 if (QDF_STATUS_SUCCESS ==
4352 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004353 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004354 (qdf_list_node_t *)lim_mgmt_regn))
4355 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304356 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004357 }
4358
4359 if (sme_req->registerFrame) {
4360 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304361 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004362 sme_req->matchLen);
4363 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004364 lim_mgmt_regn->frameType = sme_req->frameType;
4365 lim_mgmt_regn->matchLen = sme_req->matchLen;
4366 lim_mgmt_regn->sessionId = sme_req->sessionId;
4367 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304368 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004369 sme_req->matchData,
4370 sme_req->matchLen);
4371 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304372 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004373 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304374 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004375 gLimMgmtFrameRegistratinQueue,
4376 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304377 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004378 &mac_ctx->lim.lim_frame_register_lock);
4379 }
4380 }
4381 return;
4382}
4383
4384static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4385{
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004386 pe_debug("Dereg msgType %d", pMac->lim.gDeferMsgTypeForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004387 pMac->lim.gDeferMsgTypeForNOA = 0;
4388 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4389 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304390 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004391 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4392 }
4393}
4394
4395/**
4396 * lim_process_regd_defd_sme_req_after_noa_start()
4397 *
4398 * mac_ctx: Pointer to Global MAC structure
4399 *
4400 * This function is called to process deferred sme req message
4401 * after noa start.
4402 *
4403 * Return: None
4404 */
4405void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4406{
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004407 pe_debug("Process defd sme req %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004408 mac_ctx->lim.gDeferMsgTypeForNOA);
4409
4410 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4411 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004412 pe_warn("start rcvd from FW when no sme deferred msg pending. Do nothing");
4413 pe_warn("It may happen when NOA start ind and timeout happen at the same time");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004414 return;
4415 }
4416 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4417 case eWNI_SME_SCAN_REQ:
4418 __lim_process_sme_scan_req(mac_ctx,
4419 mac_ctx->lim.gpDefdSmeMsgForNOA);
4420 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004421 case eWNI_SME_JOIN_REQ:
4422 __lim_process_sme_join_req(mac_ctx,
4423 mac_ctx->lim.gpDefdSmeMsgForNOA);
4424 break;
4425 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004426 pe_err("Unknown deferred msg type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004427 mac_ctx->lim.gDeferMsgTypeForNOA);
4428 break;
4429 }
4430 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4431}
4432
4433static void
4434__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4435{
4436 tpSirResetAPCapsChange pResetCapsChange;
4437 tpPESession psessionEntry;
4438 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004439
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004440 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004441 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004442 return;
4443 }
4444
4445 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4446 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004447 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4448 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004449 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004450 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004451 return;
4452 }
4453
4454 psessionEntry->limSentCapsChangeNtf = false;
4455 return;
4456}
4457
4458/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304459 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4460 * indication callback in PE.
4461 * @mac_ptr: Mac pointer
4462 * @msg_buf: Msg pointer containing the callback
4463 *
4464 * This function is used save the Management frame
4465 * indication callback in PE.
4466 *
4467 * Return: None
4468 */
4469static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4470 uint32_t *msg_buf)
4471{
4472 struct sir_sme_mgmt_frame_cb_req *sme_req =
4473 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4474
4475 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004476 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304477 return;
4478 }
4479 if (sme_req->callback)
4480 mac_ctx->mgmt_frame_ind_cb =
4481 (sir_mgmt_frame_ind_callback)sme_req->callback;
4482 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004483 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304484}
4485
4486/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304487 *__lim_process_send_disassoc_frame: function processes disassoc frame
4488 * @mac_ctx: pointer to mac context
4489 * @msg_buf: message buffer
4490 *
4491 * function processes disassoc request received from SME
4492 *
4493 * return: none
4494 */
4495static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4496 uint32_t *msg_buf)
4497{
4498 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4499 tSirRetStatus status;
4500 tpPESession session_entry = NULL;
4501 uint8_t sme_session_id;
4502 uint16_t sme_trans_id;
4503
4504 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004505 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304506 return;
4507 }
4508
4509 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4510 &sme_trans_id);
4511
4512 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4513 &sme_send_disassoc_frame_req,
4514 (uint8_t *)msg_buf);
4515
4516 if ((eSIR_FAILURE == status) ||
4517 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4518 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004519 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304520 return;
4521 }
4522
4523 session_entry = pe_find_session_by_sme_session_id(
4524 mac_ctx, sme_session_id);
4525 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004526 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304527 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4528 return;
4529 }
4530
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004531 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 +05304532 sme_send_disassoc_frame_req.msg_type,
4533 sme_send_disassoc_frame_req.length,
4534 sme_send_disassoc_frame_req.session_id,
4535 sme_send_disassoc_frame_req.trans_id,
4536 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4537 sme_send_disassoc_frame_req.reason,
4538 sme_send_disassoc_frame_req.wait_for_ack);
4539
4540 lim_send_disassoc_mgmt_frame(mac_ctx,
4541 sme_send_disassoc_frame_req.reason,
4542 sme_send_disassoc_frame_req.peer_mac,
4543 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4544}
4545
4546/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004547 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4548 * @mac_ctx: Pointer to Global MAC structure
4549 * @pdev_id: pdev id to set the IE.
4550 * @nss: Nss values to prepare the HT IE.
4551 *
4552 * Prepares the HT IE with self capabilities for different
4553 * Nss values and sends the set HT IE req to FW.
4554 *
4555 * Return: None
4556 */
4557static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4558 uint8_t nss)
4559{
4560 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004561 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004562 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004563 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004564 tHtCaps *p_ht_cap;
4565 int i;
4566
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004567 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004568 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4569 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004570 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004571 return;
4572 }
4573 ie_params->nss = i;
4574 ie_params->pdev_id = pdev_id;
4575 ie_params->ie_type = DOT11_HT_IE;
4576 /* 2 for IE len and EID */
4577 ie_params->ie_len = 2 + sizeof(tHtCaps);
4578 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4579 if (NULL == ie_params->ie_ptr) {
4580 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004581 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004582 return;
4583 }
4584 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4585 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4586 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4587 ie_params->ie_len);
4588
4589 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004590 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4591 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004592 if (NULL == p_ie) {
4593 qdf_mem_free(ie_params->ie_ptr);
4594 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004595 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004596 return;
4597 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004598 p_ht_cap = (tHtCaps *)&p_ie[2];
4599 p_ht_cap->supportedMCSSet[1] = 0;
4600 p_ht_cap->txSTBC = 0;
4601 }
4602
4603 msg.type = WMA_SET_PDEV_IE_REQ;
4604 msg.bodyptr = ie_params;
4605 msg.bodyval = 0;
4606
4607 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4608 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004609 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004610 qdf_mem_free(ie_params->ie_ptr);
4611 qdf_mem_free(ie_params);
4612 return;
4613 }
4614 }
4615}
4616
4617/**
4618 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4619 * @mac_ctx: Pointer to Global MAC structure
4620 * @pdev_id: pdev id to set the IE.
4621 * @nss: Nss values to prepare the VHT IE.
4622 *
4623 * Prepares the VHT IE with self capabilities for different
4624 * Nss values and sends the set VHT IE req to FW.
4625 *
4626 * Return: None
4627 */
4628static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4629 uint8_t nss)
4630{
4631 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004632 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004633 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004634 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004635 tSirMacVHTCapabilityInfo *vht_cap;
4636 int i;
4637 tSirVhtMcsInfo *vht_mcs;
4638
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004639 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004640 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4641 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004642 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004643 return;
4644 }
4645 ie_params->nss = i;
4646 ie_params->pdev_id = pdev_id;
4647 ie_params->ie_type = DOT11_VHT_IE;
4648 /* 2 for IE len and EID */
4649 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4650 sizeof(tSirVhtMcsInfo);
4651 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4652 if (NULL == ie_params->ie_ptr) {
4653 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004654 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004655 return;
4656 }
4657 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4658 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4659 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4660 ie_params->ie_len);
4661
4662 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004663 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4664 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004665 if (NULL == p_ie) {
4666 qdf_mem_free(ie_params->ie_ptr);
4667 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004668 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004669 return;
4670 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004671 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4672 vht_cap->txSTBC = 0;
4673 vht_mcs =
4674 (tSirVhtMcsInfo *)&p_ie[2 +
4675 sizeof(tSirMacVHTCapabilityInfo)];
4676 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4677 vht_mcs->rxHighest =
4678 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4679 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4680 vht_mcs->txHighest =
4681 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4682 }
4683 msg.type = WMA_SET_PDEV_IE_REQ;
4684 msg.bodyptr = ie_params;
4685 msg.bodyval = 0;
4686
4687 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4688 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004689 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004690 qdf_mem_free(ie_params->ie_ptr);
4691 qdf_mem_free(ie_params);
4692 return;
4693 }
4694 }
4695}
4696
4697/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004698 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4699 * @mac_ctx: Pointer to Global MAC structure
4700 * @msg_buf: Pointer to the SME message buffer
4701 *
4702 * This function is called by limProcessMessageQueue(). This function sets the
4703 * VDEV IEs to the FW.
4704 *
4705 * Return: None
4706 */
4707static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4708 uint32_t *msg_buf)
4709{
4710 struct sir_set_vdev_ies_per_band *p_msg =
4711 (struct sir_set_vdev_ies_per_band *)msg_buf;
4712
4713 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004714 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004715 return;
4716 }
4717
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004718 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004719 p_msg->vdev_id);
4720 /* intentionally using NULL here so that self capabilty are sent */
4721 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4722 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004723 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004724}
4725
4726/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004727 * lim_process_set_pdev_IEs() - process the set pdev IE req
4728 * @mac_ctx: Pointer to Global MAC structure
4729 * @msg_buf: Pointer to the SME message buffer
4730 *
4731 * This function is called by limProcessMessageQueue(). This
4732 * function sets the PDEV IEs to the FW.
4733 *
4734 * Return: None
4735 */
4736static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4737{
4738 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4739
4740 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4741
4742 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004743 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004744 return;
4745 }
4746
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004747 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004748 ht_vht_cfg->nss);
4749 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4750
4751 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4752 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4753 ht_vht_cfg->nss);
4754}
4755
4756/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304757 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4758 *
4759 * access policy
4760 * @mac_ctx: pointer to mac context
4761 * @msg: message buffer
4762 *
4763 * function processes vendor IE and access policy from SME and updates PE
4764 *
4765 * session entry
4766 *
4767 * return: none
4768*/
4769static void lim_process_sme_update_access_policy_vendor_ie(
4770 tpAniSirGlobal mac_ctx,
4771 uint32_t *msg)
4772{
4773 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4774 struct sPESession *pe_session_entry;
4775 uint8_t num_bytes;
4776
4777 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004778 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304779 return;
4780 }
4781 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4782 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4783 update_vendor_ie->sme_session_id);
4784
4785 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004786 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304787 update_vendor_ie->sme_session_id);
4788 return;
4789 }
4790 if (pe_session_entry->access_policy_vendor_ie)
4791 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4792
4793 num_bytes = update_vendor_ie->ie[1] + 2;
4794 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4795
4796 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004797 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304798 return;
4799 }
4800 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4801 &update_vendor_ie->ie[0], num_bytes);
4802
4803 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4804}
4805
4806/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004807 * lim_process_sme_req_messages()
4808 *
4809 ***FUNCTION:
4810 * This function is called by limProcessMessageQueue(). This
4811 * function processes SME request messages from HDD or upper layer
4812 * application.
4813 *
4814 ***LOGIC:
4815 *
4816 ***ASSUMPTIONS:
4817 *
4818 ***NOTE:
4819 *
4820 * @param pMac Pointer to Global MAC structure
4821 * @param msgType Indicates the SME message type
4822 * @param *pMsgBuf A pointer to the SME message buffer
4823 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4824 * false - if pMsgBuf is not to be freed.
4825 */
4826
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004827bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4828 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004829{
4830 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
4831 uint32_t *pMsgBuf = pMsg->bodyptr;
4832 tpSirSmeScanReq pScanReq;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004833
4834 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004835 lim_msg_str(pMsg->type), pMsg->type,
4836 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4837 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004838
4839 pScanReq = (tpSirSmeScanReq) pMsgBuf;
4840 /* If no insert NOA required then execute the code below */
4841
4842 switch (pMsg->type) {
4843 case eWNI_SME_SYS_READY_IND:
4844 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4845 break;
4846
4847 case eWNI_SME_START_BSS_REQ:
4848 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4849 break;
4850
4851 case eWNI_SME_SCAN_REQ:
4852 __lim_process_sme_scan_req(pMac, pMsgBuf);
4853 break;
4854
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004855 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4856 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4857 break;
4858 case eWNI_SME_JOIN_REQ:
4859 __lim_process_sme_join_req(pMac, pMsgBuf);
4860 break;
4861
4862 case eWNI_SME_REASSOC_REQ:
4863 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4864 break;
4865
4866 case eWNI_SME_DISASSOC_REQ:
4867 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4868 break;
4869
4870 case eWNI_SME_DISASSOC_CNF:
4871 case eWNI_SME_DEAUTH_CNF:
4872 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4873 break;
4874
4875 case eWNI_SME_DEAUTH_REQ:
4876 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4877 break;
4878
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304879 case eWNI_SME_SEND_DISASSOC_FRAME:
4880 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4881 break;
4882
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004883 case eWNI_SME_SETCONTEXT_REQ:
4884 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4885 break;
4886
4887 case eWNI_SME_STOP_BSS_REQ:
4888 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4889 break;
4890
4891 case eWNI_SME_ASSOC_CNF:
4892 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004893 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004894 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4895 pMsgBuf);
4896 break;
4897
4898 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004899 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004900 __lim_process_sme_addts_req(pMac, pMsgBuf);
4901 break;
4902
4903 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004904 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004905 __lim_process_sme_delts_req(pMac, pMsgBuf);
4906 break;
4907
4908 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004909 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004910 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4911 break;
4912
4913 case eWNI_SME_GET_STATISTICS_REQ:
4914 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4915 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4916 bufConsumed = false;
4917 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004918#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004919 case eWNI_SME_GET_TSM_STATS_REQ:
4920 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4921 bufConsumed = false;
4922 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004923#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004924 case eWNI_SME_GET_ASSOC_STAS_REQ:
4925 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4926 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304927 case eWNI_SME_SESSION_UPDATE_PARAM:
4928 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004929 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304930 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4931 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4932 bufConsumed = false;
4933 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004934 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4935 /* Update the beaconInterval */
4936 __lim_process_sme_change_bi(pMac, pMsgBuf);
4937 break;
4938
4939#ifdef QCA_HT_2040_COEX
4940 case eWNI_SME_SET_HT_2040_MODE:
4941 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4942 break;
4943#endif
4944
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004945 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4946 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4947 __lim_process_report_message(pMac, pMsg);
4948 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004949
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004950 case eWNI_SME_FT_PRE_AUTH_REQ:
4951 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4952 break;
4953 case eWNI_SME_FT_UPDATE_KEY:
4954 lim_process_ft_update_key(pMac, pMsgBuf);
4955 break;
4956
4957 case eWNI_SME_FT_AGGR_QOS_REQ:
4958 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4959 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004960
4961 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4962 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4963 break;
4964#ifdef FEATURE_WLAN_TDLS
4965 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4966 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4967 break;
4968 case eWNI_SME_TDLS_ADD_STA_REQ:
4969 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4970 break;
4971 case eWNI_SME_TDLS_DEL_STA_REQ:
4972 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4973 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004974#endif
4975 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4976 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4977 break;
4978
4979 case eWNI_SME_CHANNEL_CHANGE_REQ:
4980 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4981 break;
4982
4983 case eWNI_SME_START_BEACON_REQ:
4984 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4985 break;
4986
4987 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4988 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4989 break;
4990
4991 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4992 lim_process_update_add_ies(pMac, pMsgBuf);
4993 break;
4994
4995 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4996 lim_process_modify_add_ies(pMac, pMsgBuf);
4997 break;
4998 case eWNI_SME_SET_HW_MODE_REQ:
4999 lim_process_set_hw_mode(pMac, pMsgBuf);
5000 break;
5001 case eWNI_SME_NSS_UPDATE_REQ:
5002 lim_process_nss_update_request(pMac, pMsgBuf);
5003 break;
5004 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5005 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5006 break;
5007 case eWNI_SME_SET_IE_REQ:
5008 lim_process_set_ie_req(pMac, pMsgBuf);
5009 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305010 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5011 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5012 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305013 case eWNI_SME_EXT_CHANGE_CHANNEL:
5014 lim_process_ext_change_channel(pMac, pMsgBuf);
5015 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005016 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5017 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5018 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005019 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5020 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005021 break;
5022 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5023 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5024 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07005025 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005026 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005027 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005028 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005029 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305030 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5031 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5032 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07005033 case eWNI_SME_UPDATE_CONFIG:
5034 lim_process_sme_update_config(pMac,
5035 (struct update_config *)pMsgBuf);
5036 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005037 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305038 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005039 pMsg->bodyptr = NULL;
5040 break;
5041 } /* switch (msgType) */
5042
5043 return bufConsumed;
5044} /*** end lim_process_sme_req_messages() ***/
5045
5046/**
5047 * lim_process_sme_start_beacon_req()
5048 *
5049 ***FUNCTION:
5050 * This function is called by limProcessMessageQueue(). This
5051 * function processes SME request messages from HDD or upper layer
5052 * application.
5053 *
5054 ***LOGIC:
5055 *
5056 ***ASSUMPTIONS:
5057 *
5058 ***NOTE:
5059 *
5060 * @param pMac Pointer to Global MAC structure
5061 * @param msgType Indicates the SME message type
5062 * @param *pMsgBuf A pointer to the SME message buffer
5063 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5064 * false - if pMsgBuf is not to be freed.
5065 */
5066static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5067{
5068 tpSirStartBeaconIndication pBeaconStartInd;
5069 tpPESession psessionEntry;
5070 uint8_t sessionId; /* PE sessionID */
5071
5072 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005073 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005074 return;
5075 }
5076
5077 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5078 psessionEntry = pe_find_session_by_bssid(pMac,
5079 pBeaconStartInd->bssid,
5080 &sessionId);
5081 if (psessionEntry == NULL) {
5082 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005083 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005084 return;
5085 }
5086
5087 if (pBeaconStartInd->beaconStartStatus == true) {
5088 /*
5089 * Currently this Indication comes from SAP
5090 * to start Beacon Tx on a DFS channel
5091 * since beaconing has to be done on DFS
5092 * channel only after CAC WAIT is completed.
5093 * On a DFS Channel LIM does not start beacon
5094 * Tx right after the WMA_ADD_BSS_RSP.
5095 */
5096 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05305097 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005098 FL("Start Beacon with ssid %s Ch %d"),
5099 psessionEntry->ssId.ssId,
5100 psessionEntry->currentOperChannel);
5101 lim_send_beacon_ind(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08005102 lim_enable_obss_detection_config(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005103 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005104 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005105 return;
5106 }
5107}
5108
5109/**
5110 * lim_process_sme_channel_change_request() - process sme ch change req
5111 *
5112 * @mac_ctx: Pointer to Global MAC structure
5113 * @msg_buf: pointer to the SME message buffer
5114 *
5115 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5116 *
5117 * Return: None
5118 */
5119static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5120 uint32_t *msg_buf)
5121{
5122 tpSirChanChangeRequest ch_change_req;
5123 tpPESession session_entry;
5124 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005125 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005126 uint32_t val = 0;
5127
5128 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005129 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005130 return;
5131 }
5132 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5133
5134 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5135 ch_change_req->targetChannel);
5136
5137 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5138 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005139 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005140 return;
5141 }
5142
5143 session_entry = pe_find_session_by_bssid(mac_ctx,
5144 ch_change_req->bssid, &session_id);
5145 if (session_entry == NULL) {
5146 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005147 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005148 return;
5149 }
5150
5151 if (session_entry->currentOperChannel ==
5152 ch_change_req->targetChannel) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005153 pe_err("target CH is same as current CH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005154 return;
5155 }
5156
5157 if (LIM_IS_AP_ROLE(session_entry))
5158 session_entry->channelChangeReasonCode =
5159 LIM_SWITCH_CHANNEL_SAP_DFS;
5160 else
5161 session_entry->channelChangeReasonCode =
5162 LIM_SWITCH_CHANNEL_OPERATION;
5163
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005164 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005165 session_entry->currentOperChannel,
5166 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005167 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005168
5169 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005170 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005171 session_entry->ch_center_freq_seg0 =
5172 ch_change_req->center_freq_seg_0;
5173 session_entry->ch_center_freq_seg1 =
5174 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005175 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005176 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005177 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005178 session_entry->htRecommendedTxWidthSet =
5179 session_entry->htSupportedChannelWidthSet;
5180 session_entry->currentOperChannel =
5181 ch_change_req->targetChannel;
5182 session_entry->limRFBand =
5183 lim_get_rf_band(session_entry->currentOperChannel);
5184 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08005185 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005186 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005187 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5188 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005189 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005190 }
5191
5192 session_entry->lim11hEnable = val;
5193 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305194 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005195 &ch_change_req->operational_rateset,
5196 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305197 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005198 &ch_change_req->extended_rateset,
5199 sizeof(session_entry->extRateSet));
5200 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5201 session_entry->ch_center_freq_seg0,
5202 session_entry->ch_center_freq_seg1,
5203 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07005204 max_tx_pwr, session_entry->peSessionId,
5205 ch_change_req->cac_duration_ms,
5206 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005207}
5208
5209/******************************************************************************
5210* lim_start_bss_update_add_ie_buffer()
5211*
5212***FUNCTION:
5213* This function checks the src buffer and its length and then malloc for
5214* dst buffer update the same
5215*
5216***LOGIC:
5217*
5218***ASSUMPTIONS:
5219*
5220***NOTE:
5221*
5222* @param pMac Pointer to Global MAC structure
5223* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5224* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5225* @param *pSrcData_buff A pointer of uint8_t src buffer
5226* @param srcDataLen src buffer length
5227******************************************************************************/
5228
5229static void
5230lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5231 uint8_t **pDstData_buff,
5232 uint16_t *pDstDataLen,
5233 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5234{
5235
5236 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5237 *pDstDataLen = srcDataLen;
5238
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305239 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005240
5241 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005242 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005243 return;
5244 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305245 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005246 } else {
5247 *pDstData_buff = NULL;
5248 *pDstDataLen = 0;
5249 }
5250}
5251
5252/******************************************************************************
5253* lim_update_add_ie_buffer()
5254*
5255***FUNCTION:
5256* This function checks the src buffer and length if src buffer length more
5257* than dst buffer length then free the dst buffer and malloc for the new src
5258* length, and update the dst buffer and length. But if dst buffer is bigger
5259* than src buffer length then it just update the dst buffer and length
5260*
5261***LOGIC:
5262*
5263***ASSUMPTIONS:
5264*
5265***NOTE:
5266*
5267* @param pMac Pointer to Global MAC structure
5268* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5269* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5270* @param *pSrcData_buff A pointer of uint8_t src buffer
5271* @param srcDataLen src buffer length
5272******************************************************************************/
5273
5274static void
5275lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5276 uint8_t **pDstData_buff,
5277 uint16_t *pDstDataLen,
5278 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5279{
5280
5281 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005282 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005283 return;
5284 }
5285
5286 if (srcDataLen > *pDstDataLen) {
5287 *pDstDataLen = srcDataLen;
5288 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305289 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005290 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305291 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005292
5293 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005294 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005295 *pDstDataLen = 0;
5296 return;
5297 }
5298 }
5299
5300 /* copy the content of buffer into dst buffer
5301 */
5302 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305303 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005304
5305}
5306
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005307/**
5308 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5309 * @pMac : Pointer to Global MAC structure
5310 * @pDstData_buff : A pointer to pointer of dst buffer
5311 * @pDstDataLen : A pointer to pointer of dst buffer length
5312 * @pModifyIE : A pointer to tSirModifyIE
5313 *
5314 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5315 *
5316 * Return:
5317 * True or false depending upon whether IE is updated or not
5318 */
5319static bool
5320lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5321 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5322{
Hong Shi1553d692016-09-28 12:16:19 +08005323 int32_t oui_length;
5324 uint8_t *ibss_ie = NULL;
5325 uint8_t *vendor_ie;
5326#define MAC_VENDOR_OUI "\x00\x16\x32"
5327#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005328
5329 ibss_ie = pModifyIE->pIEBuffer;
5330 oui_length = pModifyIE->oui_length;
5331
5332 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005333 pe_err("Invalid set IBSS vendor IE command length %d",
5334 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005335 return false;
5336 }
5337
Hong Shi1553d692016-09-28 12:16:19 +08005338 /*
5339 * Why replace only beacon OUI data here:
5340 * 1. other ie (such as wpa) shall not be overwritten here.
5341 * 2. per spec, beacon oui ie might be set twice and original one
5342 * shall be updated.
5343 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005344 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005345 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5346 if (vendor_ie) {
5347 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5348 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5349 pModifyIE->ieBufferlength);
5350 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005351 uint16_t new_length;
5352 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005353
Naveen Rawat668dee32017-09-29 14:39:40 -07005354 /*
5355 * check for uint16 overflow before using sum of two numbers as
5356 * length of size to malloc
5357 */
5358 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5359 pe_err("U16 overflow due to %d + %d",
5360 pModifyIE->ieBufferlength, *pDstDataLen);
5361 return false;
5362 }
5363
5364 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5365 new_ptr = qdf_mem_malloc(new_length);
Hong Shi1553d692016-09-28 12:16:19 +08005366 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005367 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005368 return false;
5369 }
5370 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5371 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5372 pModifyIE->ieBufferlength);
5373 qdf_mem_free(*pDstData_buff);
5374 *pDstDataLen = new_length;
5375 *pDstData_buff = new_ptr;
5376 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005377 return true;
5378}
5379
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005380/*
5381* lim_process_modify_add_ies() - process modify additional IE req.
5382*
5383* @mac_ctx: Pointer to Global MAC structure
5384* @msg_buf: pointer to the SME message buffer
5385*
5386* This function update the PE buffers for additional IEs.
5387*
5388* Return: None
5389*/
5390static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5391 uint32_t *msg_buf)
5392{
5393 tpSirModifyIEsInd modify_add_ies;
5394 tpPESession session_entry;
5395 uint8_t session_id;
5396 bool ret = false;
5397 tSirAddIeParams *add_ie_params;
5398
5399 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005400 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005401 return;
5402 }
5403
5404 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5405 /* Incoming message has smeSession, use BSSID to find PE session */
5406 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005407 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005408
5409 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005410 pe_err("Session not found for given bssid"
5411 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005412 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005413 goto end;
5414 }
5415 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5416 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5417 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005418 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005419 modify_add_ies->modifyIE.pIEBuffer,
5420 modify_add_ies->modifyIE.ieBufferlength,
5421 modify_add_ies->modifyIE.ieID,
5422 modify_add_ies->modifyIE.ieIDLen,
5423 modify_add_ies->updateType);
5424 goto end;
5425 }
5426 add_ie_params = &session_entry->addIeParams;
5427 switch (modify_add_ies->updateType) {
5428 case eUPDATE_IE_PROBE_RESP:
5429 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005430 if (LIM_IS_IBSS_ROLE(session_entry)) {
5431 lim_update_ibss_prop_add_ies(mac_ctx,
5432 &add_ie_params->probeRespData_buff,
5433 &add_ie_params->probeRespDataLen,
5434 &modify_add_ies->modifyIE);
5435 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005436 break;
5437 case eUPDATE_IE_ASSOC_RESP:
5438 /* assoc resp IE */
5439 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305440 QDF_TRACE(QDF_MODULE_ID_PE,
5441 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005442 "assoc resp add ie not present %d"),
5443 add_ie_params->assocRespDataLen);
5444 }
5445 /* search through the buffer and modify the IE */
5446 break;
5447 case eUPDATE_IE_PROBE_BCN:
5448 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005449 if (LIM_IS_IBSS_ROLE(session_entry)) {
5450 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5451 &add_ie_params->probeRespBCNData_buff,
5452 &add_ie_params->probeRespBCNDataLen,
5453 &modify_add_ies->modifyIE);
5454 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005455 if (ret == true && modify_add_ies->modifyIE.notify) {
5456 lim_handle_param_update(mac_ctx,
5457 modify_add_ies->updateType);
5458 }
5459 break;
5460 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005461 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005462 modify_add_ies->updateType);
5463 break;
5464 }
5465end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305466 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005467 modify_add_ies->modifyIE.pIEBuffer = NULL;
5468}
5469
5470/*
5471* lim_process_update_add_ies() - process additional IE update req
5472*
5473* @mac_ctx: Pointer to Global MAC structure
5474* @msg_buf: pointer to the SME message buffer
5475*
5476* This function update the PE buffers for additional IEs.
5477*
5478* Return: None
5479*/
5480static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5481 uint32_t *msg_buf)
5482{
5483 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5484 uint8_t session_id;
5485 tpPESession session_entry;
5486 tSirAddIeParams *addn_ie;
5487 uint16_t new_length = 0;
5488 uint8_t *new_ptr = NULL;
5489 tSirUpdateIE *update_ie;
5490
5491 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005492 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005493 return;
5494 }
5495 update_ie = &update_add_ies->updateIE;
5496 /* incoming message has smeSession, use BSSID to find PE session */
5497 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005498 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005499
5500 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005501 pe_err("Session not found for given bssid"
5502 MAC_ADDRESS_STR,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005503 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005504 goto end;
5505 }
5506 addn_ie = &session_entry->addIeParams;
5507 /* if len is 0, upper layer requested freeing of buffer */
5508 if (0 == update_ie->ieBufferlength) {
5509 switch (update_add_ies->updateType) {
5510 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305511 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005512 addn_ie->probeRespData_buff = NULL;
5513 addn_ie->probeRespDataLen = 0;
5514 break;
5515 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305516 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005517 addn_ie->assocRespData_buff = NULL;
5518 addn_ie->assocRespDataLen = 0;
5519 break;
5520 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305521 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005522 addn_ie->probeRespBCNData_buff = NULL;
5523 addn_ie->probeRespBCNDataLen = 0;
5524
5525 if (update_ie->notify)
5526 lim_handle_param_update(mac_ctx,
5527 update_add_ies->updateType);
5528 break;
5529 default:
5530 break;
5531 }
5532 return;
5533 }
5534 switch (update_add_ies->updateType) {
5535 case eUPDATE_IE_PROBE_RESP:
5536 if (update_ie->append) {
5537 /*
5538 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005539 * with combined length.
5540 * Multiple back to back append commands
5541 * can lead to a huge length.So, check
5542 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005543 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005544 if (addn_ie->probeRespDataLen >
5545 (USHRT_MAX - update_ie->ieBufferlength)) {
5546 pe_err("IE Length overflow, curr:%d, new:%d",
5547 addn_ie->probeRespDataLen,
5548 update_ie->ieBufferlength);
5549 goto end;
5550 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005551 new_length = update_ie->ieBufferlength +
5552 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305553 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005554 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005555 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005556 goto end;
5557 }
5558 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305559 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005560 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305561 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005562 update_ie->pAdditionIEBuffer,
5563 update_ie->ieBufferlength);
5564 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305565 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005566 /* adjust length accordingly */
5567 addn_ie->probeRespDataLen = new_length;
5568 /* save refernece of local buffer in PE session */
5569 addn_ie->probeRespData_buff = new_ptr;
5570 goto end;
5571 }
5572 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5573 &addn_ie->probeRespDataLen,
5574 update_ie->pAdditionIEBuffer,
5575 update_ie->ieBufferlength);
5576 break;
5577 case eUPDATE_IE_ASSOC_RESP:
5578 /* assoc resp IE */
5579 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5580 &addn_ie->assocRespDataLen,
5581 update_ie->pAdditionIEBuffer,
5582 update_ie->ieBufferlength);
5583 break;
5584 case eUPDATE_IE_PROBE_BCN:
5585 /* probe resp Bcn IE */
5586 lim_update_add_ie_buffer(mac_ctx,
5587 &addn_ie->probeRespBCNData_buff,
5588 &addn_ie->probeRespBCNDataLen,
5589 update_ie->pAdditionIEBuffer,
5590 update_ie->ieBufferlength);
5591 if (update_ie->notify)
5592 lim_handle_param_update(mac_ctx,
5593 update_add_ies->updateType);
5594 break;
5595 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005596 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005597 break;
5598 }
5599end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305600 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005601 update_ie->pAdditionIEBuffer = NULL;
5602}
5603
5604/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305605 * send_extended_chan_switch_action_frame()- function to send ECSA
5606 * action frame for each sta connected to SAP/GO and AP in case of
5607 * STA .
5608 * @mac_ctx: pointer to global mac structure
5609 * @new_channel: new channel to switch to.
5610 * @ch_bandwidth: BW of channel to calculate op_class
5611 * @session_entry: pe session
5612 *
5613 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5614 *
5615 * Return: void
5616 */
5617
5618static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5619 uint16_t new_channel, uint8_t ch_bandwidth,
5620 tpPESession session_entry)
5621{
5622 uint16_t op_class;
5623 uint8_t switch_mode = 0, i;
5624 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005625 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305626
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005627 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305628 mac_ctx->scan.countryCodeCurrent,
5629 new_channel,
5630 ch_bandwidth);
5631
5632 if (LIM_IS_AP_ROLE(session_entry) &&
5633 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005634 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305635
gaoleze2920bd2017-03-21 17:38:42 +08005636 switch_count = session_entry->gLimChannelSwitch.switchCount;
5637
Abhishek Singh518323d2015-10-19 17:42:01 +05305638 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005639 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305640 psta =
5641 session_entry->dph.dphHashTable.pDphNodeArray + i;
5642 if (psta && psta->added)
5643 lim_send_extended_chan_switch_action_frame(
5644 mac_ctx,
5645 psta->staAddr,
5646 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005647 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305648 }
5649 } else if (LIM_IS_STA_ROLE(session_entry)) {
5650 lim_send_extended_chan_switch_action_frame(mac_ctx,
5651 session_entry->bssId,
5652 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005653 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305654 }
5655
5656}
5657
gaolez76d2a162017-03-21 19:23:58 +08005658void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5659 uint16_t new_channel,
5660 uint8_t ch_bandwidth,
5661 tpPESession session_entry)
5662{
5663 uint16_t op_class;
5664 uint8_t switch_mode = 0, i;
5665 uint8_t switch_count;
5666 tpDphHashNode psta;
5667 tpDphHashNode dph_node_array_ptr;
5668
5669 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5670
5671 op_class = wlan_reg_dmn_get_opclass_from_channel(
5672 mac_ctx->scan.countryCodeCurrent,
5673 new_channel, ch_bandwidth);
5674
5675 if (LIM_IS_AP_ROLE(session_entry) &&
5676 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5677 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5678
5679 switch_count = session_entry->gLimChannelSwitch.switchCount;
5680
5681 if (LIM_IS_AP_ROLE(session_entry)) {
5682 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5683 psta = dph_node_array_ptr + i;
5684 if (!(psta && psta->added))
5685 continue;
5686 if (session_entry->lim_non_ecsa_cap_num == 0)
5687 lim_send_extended_chan_switch_action_frame
5688 (mac_ctx, psta->staAddr, switch_mode,
5689 op_class, new_channel, switch_count,
5690 session_entry);
5691 else
5692 lim_send_channel_switch_mgmt_frame
5693 (mac_ctx, psta->staAddr, switch_mode,
5694 new_channel, switch_count,
5695 session_entry);
5696 }
5697 } else if (LIM_IS_STA_ROLE(session_entry)) {
5698 lim_send_extended_chan_switch_action_frame
5699 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5700 new_channel, switch_count, session_entry);
5701 }
5702}
5703
5704/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005705 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5706 *
5707 * @mac_ctx: Pointer to Global MAC structure
5708 * @msg_buf: pointer to the SME message buffer
5709 *
5710 * This function processes SME request messages from HDD or upper layer
5711 * application.
5712 *
5713 * Return: None
5714 */
5715static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5716 uint32_t *msg_buf)
5717{
5718 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5719 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005720 uint8_t session_id;
5721 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005722 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005723
5724 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005725 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005726 return;
5727 }
5728
5729 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5730 session_entry = pe_find_session_by_bssid(mac_ctx,
5731 dfs_csa_ie_req->bssid, &session_id);
5732 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005733 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005734 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5735 return;
5736 }
5737
5738 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005739 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005740 GET_LIM_SYSTEM_ROLE(session_entry));
5741 return;
5742 }
5743
5744 /* target channel */
5745 session_entry->gLimChannelSwitch.primaryChannel =
5746 dfs_csa_ie_req->targetChannel;
5747
5748 /* Channel switch announcement needs to be included in beacon */
5749 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005750 session_entry->gLimChannelSwitch.switchCount =
5751 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005752 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005753 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305754 session_entry->gLimChannelSwitch.sec_ch_offset =
5755 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005756 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005757 session_entry->gLimChannelSwitch.switchMode =
5758 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005759
5760 /*
5761 * Validate if SAP is operating HT or VHT mode and set the Channel
5762 * Switch Wrapper element with the Wide Band Switch subelement.
5763 */
5764 if (true != session_entry->vhtCapability)
5765 goto skip_vht;
5766
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005767 /* Now encode the Wider Ch BW element depending on the ch width */
5768 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005769 switch (dfs_csa_ie_req->ch_params.ch_width) {
5770 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005771 /*
5772 * Wide channel BW sublement in channel wrapper element is not
5773 * required in case of 20 Mhz operation. Currently It is set
5774 * only set in case of 40/80 Mhz Operation.
5775 */
5776 session_entry->dfsIncludeChanWrapperIe = false;
5777 wider_bw_ch_switch->newChanWidth =
5778 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5779 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005780 case CH_WIDTH_40MHZ:
5781 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005782 wider_bw_ch_switch->newChanWidth =
5783 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5784 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005785 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005786 session_entry->dfsIncludeChanWrapperIe = true;
5787 wider_bw_ch_switch->newChanWidth =
5788 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5789 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005790 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005791 session_entry->dfsIncludeChanWrapperIe = true;
5792 wider_bw_ch_switch->newChanWidth =
5793 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5794 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005795 case CH_WIDTH_80P80MHZ:
5796 session_entry->dfsIncludeChanWrapperIe = true;
5797 wider_bw_ch_switch->newChanWidth =
5798 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005799 /*
5800 * This is not applicable for 20/40/80 Mhz.
5801 * Only used when we support 80+80 Mhz operation.
5802 * In case of 80+80 Mhz, this parameter indicates
5803 * center channel frequency index of 80 Mhz channel of
5804 * frequency segment 1.
5805 */
5806 wider_bw_ch_switch->newCenterChanFreq1 =
5807 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005808 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005809 default:
5810 session_entry->dfsIncludeChanWrapperIe = false;
5811 /*
5812 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5813 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5814 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005815 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005816 break;
5817 }
5818 /* Fetch the center channel based on the channel width */
5819 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005820 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005821skip_vht:
5822 /* Send CSA IE request from here */
5823 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5824 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005825 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005826 return;
5827 }
5828
5829 /*
5830 * First beacon update request is sent here, the remaining updates are
5831 * done when the FW responds back after sending the first beacon after
5832 * the template update
5833 */
5834 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305835
5836 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5837 ch_offset = BW80;
5838 else
5839 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5840
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005841 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305842 session_entry->gLimChannelSwitch.switchCount,
5843 session_entry->gLimChannelSwitch.primaryChannel,
5844 session_entry->gLimChannelSwitch.ch_width,
5845 session_entry->dfsIncludeChanWrapperIe,
5846 ch_offset);
5847
gaolez76d2a162017-03-21 19:23:58 +08005848 /* Send ECSA/CSA Action frame after updating the beacon */
5849 if (CHAN_HOP_ALL_BANDS_ENABLE)
5850 lim_send_chan_switch_action_frame(mac_ctx,
5851 session_entry->gLimChannelSwitch.primaryChannel,
5852 ch_offset, session_entry);
5853 else
5854 send_extended_chan_switch_action_frame(mac_ctx,
5855 session_entry->gLimChannelSwitch.primaryChannel,
5856 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005857 session_entry->gLimChannelSwitch.switchCount--;
5858}
5859
5860/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305861 * lim_process_ext_change_channel()- function to send ECSA
5862 * action frame for STA/CLI .
5863 * @mac_ctx: pointer to global mac structure
5864 * @msg: params from sme for new channel.
5865 *
5866 * This function is called to send ECSA frame for STA/CLI.
5867 *
5868 * Return: void
5869 */
5870
5871static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5872 uint32_t *msg)
5873{
5874 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5875 (struct sir_sme_ext_cng_chan_req *) msg;
5876 tpPESession session_entry = NULL;
5877
5878 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005879 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305880 return;
5881 }
5882 session_entry =
5883 pe_find_session_by_sme_session_id(mac_ctx,
5884 ext_chng_channel->session_id);
5885 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005886 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305887 ext_chng_channel->session_id);
5888 return;
5889 }
5890 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005891 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305892 return;
5893 }
5894 send_extended_chan_switch_action_frame(mac_ctx,
5895 ext_chng_channel->new_channel,
5896 0, session_entry);
5897}
5898
5899/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005900 * lim_process_nss_update_request() - process sme nss update req
5901 *
5902 * @mac_ctx: Pointer to Global MAC structure
5903 * @msg_buf: pointer to the SME message buffer
5904 *
5905 * This function processes SME request messages from HDD or upper layer
5906 * application.
5907 *
5908 * Return: None
5909 */
5910static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5911 uint32_t *msg_buf)
5912{
5913 struct sir_nss_update_request *nss_update_req_ptr;
5914 tpPESession session_entry = NULL;
5915
5916 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005917 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005918 return;
5919 }
5920
5921 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305922 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005923 nss_update_req_ptr->vdev_id);
5924 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005925 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005926 nss_update_req_ptr->vdev_id);
5927 return;
5928 }
5929
5930 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005931 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005932 GET_LIM_SYSTEM_ROLE(session_entry));
5933 return;
5934 }
5935
5936 /* populate nss field in the beacon */
5937 session_entry->gLimOperatingMode.present = 1;
5938 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05305939 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
5940
5941 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
5942 (session_entry->ch_width > CH_WIDTH_80MHZ))
5943 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
5944
5945 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
5946
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005947 /* Send nss update request from here */
5948 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5949 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005950 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005951 return;
5952 }
5953
5954 lim_send_beacon_ind(mac_ctx, session_entry);
5955}
5956
5957/**
5958 * lim_process_set_ie_req() - process sme set IE request
5959 *
5960 * @mac_ctx: Pointer to Global MAC structure
5961 * @msg_buf: pointer to the SME message buffer
5962 *
5963 * This function processes SME request messages from HDD or upper layer
5964 * application.
5965 *
5966 * Return: None
5967 */
5968static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5969{
5970 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305971 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005972
5973 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005974 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005975 return;
5976 }
5977
5978 msg = (struct send_extcap_ie *)msg_buf;
5979 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305980 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005981 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005982
5983}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005984
5985#ifdef WLAN_FEATURE_11AX_BSS_COLOR
5986void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5987{
5988 struct sir_set_he_bss_color *bss_color;
5989 tpPESession session_entry = NULL;
5990 tUpdateBeaconParams beacon_params;
5991
5992 if (!msg_buf) {
5993 pe_err("Buffer is Pointing to NULL");
5994 return;
5995 }
5996
5997 bss_color = (struct sir_set_he_bss_color *)msg_buf;
5998 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5999 bss_color->session_id);
6000 if (!session_entry) {
6001 pe_err("Session not found for given session_id %d",
6002 bss_color->session_id);
6003 return;
6004 }
6005
6006 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6007 pe_err("Invalid SystemRole %d",
6008 GET_LIM_SYSTEM_ROLE(session_entry));
6009 return;
6010 }
6011
6012 if (bss_color->bss_color == session_entry->he_op.bss_color) {
6013 pe_err("No change in BSS color, current BSS color %d",
6014 bss_color->bss_color);
6015 return;
6016 }
6017 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
6018 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
6019 session_entry->he_op.bss_col_disabled = 1;
6020 session_entry->he_bss_color_change.countdown =
6021 BSS_COLOR_SWITCH_COUNTDOWN;
6022 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
6023 session_entry->he_op.bss_color =
6024 session_entry->he_bss_color_change.new_color;
Naveen Rawatdf221b72017-11-15 11:32:31 -08006025 beacon_params.bss_color = session_entry->he_op.bss_color;
6026 beacon_params.bss_color_disabled =
6027 session_entry->he_op.bss_col_disabled;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006028 session_entry->bss_color_changing = 1;
6029
6030 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6031 eSIR_SUCCESS) {
6032 pe_err("Unable to set op mode IE in beacon");
6033 return;
6034 }
6035
6036 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
6037}
6038#endif