blob: e28321e3260df98acdc374ef801abf7b64c5b7ff [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
1482/**
1483 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1484 * @mac_ctx: Pointer to Global MAC structure
1485 * @msg_buf: A pointer to the SME message buffer
1486 *
1487 * This function is called to process SME_JOIN_REQ message
1488 * from HDD or upper layer application.
1489 *
1490 * Return: None
1491 */
1492static void
1493__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1494{
1495 tpSirSmeJoinReq sme_join_req = NULL;
1496 tLimMlmJoinReq *mlm_join_req;
1497 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1498 uint32_t val = 0;
1499 uint16_t n_size;
1500 uint8_t session_id;
1501 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301502 uint8_t sme_session_id = 0;
1503 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001504 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001505 uint16_t ie_len;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001506 const uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001507 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001508 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001509
Arif Hussain995fcaf2016-07-18 11:28:22 -07001510 if (!mac_ctx || !msg_buf) {
1511 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1512 FL("JOIN REQ with invalid data"));
1513 return;
1514 }
1515
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001516/* FEATURE_WLAN_DIAG_SUPPORT */
1517#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1518 /*
1519 * Not sending any session, since it is not created yet.
1520 * The response whould have correct state.
1521 */
1522 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1523#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1524
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001525 /*
1526 * Expect Join request in idle state.
1527 * Reassociate request is expected in link established state.
1528 */
1529
1530 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1531 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1532 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1533 msg_buf);
1534
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301535 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001536 if (NULL == sme_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001537 pe_err("AllocateMemory failed for sme_join_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001538 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301539 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001540 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301541 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001542 n_size);
1543
1544 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1545 /* Received invalid eWNI_SME_JOIN_REQ */
1546 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001547 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001548 sme_join_req->sessionId);
1549 ret_code = eSIR_SME_INVALID_PARAMETERS;
1550 goto end;
1551 }
1552
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001553 /*
1554 * Update the capability here itself as this is used in
1555 * lim_extract_ap_capability() below. If not updated issues
1556 * like not honoring power constraint on 1st association after
1557 * driver loading might occur.
1558 */
1559 lim_update_rrm_capability(mac_ctx, sme_join_req);
1560
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001561 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001562 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001563 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001564 &session_id);
1565
1566 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001567 pe_err("Session(%d) Already exists for BSSID: "
1568 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001569 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001570 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001571 session->limSmeState);
1572
1573 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1574 session->smeSessionId == sme_join_req->sessionId) {
1575 /*
1576 * Received eWNI_SME_JOIN_REQ for same
1577 * BSS as currently associated.
1578 * Log the event and send success
1579 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001580 pe_warn("SessionId: %d", session_id);
1581 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582 /* Send Join success response to host */
1583 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1584 session = NULL;
1585 goto end;
1586 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001587 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001588 ret_code = eSIR_SME_REFUSED;
1589 session = NULL;
1590 goto end;
1591 }
1592 } else {
1593 /*
1594 * Session Entry does not exist for given BSSId
1595 * Try to Create a new session
1596 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001597 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001598 &session_id, mac_ctx->lim.maxStation,
1599 eSIR_INFRASTRUCTURE_MODE);
1600 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001601 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001602 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1603 goto end;
1604 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001605 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001606 session_id);
1607 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001608 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001609
1610 /*
1611 * Store Session related parameters
1612 * Store PE session Id in session Table
1613 */
1614 session->peSessionId = session_id;
1615
1616 /* store the smejoin req handle in session table */
1617 session->pLimJoinReq = sme_join_req;
1618
1619 /* Store SME session Id in sessionTable */
1620 session->smeSessionId = sme_join_req->sessionId;
1621
1622 /* Store SME transaction Id in session Table */
1623 session->transactionId = sme_join_req->transactionId;
1624
1625 /* Store beaconInterval */
1626 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001627 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001628
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301629 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001630 sizeof(session->htConfig));
1631
Sandeep Puligilla98917432016-06-10 13:50:28 -07001632 qdf_mem_copy(&(session->vht_config),
1633 &(sme_join_req->vht_config),
1634 sizeof(session->vht_config));
1635
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001636 /* Copying of bssId is already done, while creating session */
1637 sir_copy_mac_addr(session->selfMacAddr,
1638 sme_join_req->selfMacAddr);
1639 session->bssType = sme_join_req->bsstype;
1640
1641 session->statypeForBss = STA_ENTRY_PEER;
1642 session->limWmeEnabled = sme_join_req->isWMEenabled;
1643 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301644 session->wps_registration = sme_join_req->wps_registration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001645
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301646 session->enable_bcast_probe_rsp =
1647 sme_join_req->enable_bcast_probe_rsp;
1648
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001649 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001650 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001651 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1652
Naveen Rawat08db88f2017-09-08 15:07:48 -07001653 vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001654 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001655 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001656
1657 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001658 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001659 session->isCiscoVendorAP = true;
1660 } else {
1661 session->isCiscoVendorAP = false;
1662 }
1663
1664 /* Copy the dot 11 mode in to the session table */
1665
1666 session->dot11mode = sme_join_req->dot11mode;
1667#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1668 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1669#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001670 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001671 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1672 session->enableHtSmps = sme_join_req->enableHtSmps;
1673 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001674 session->send_smps_action =
1675 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001676 /*
1677 * By default supported NSS 1x1 is set to true
1678 * and later on updated while determining session
1679 * supported rates which is the intersection of
1680 * self and peer rates
1681 */
1682 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301683 /*Store Persona */
1684 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001685 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 -08001686 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001687 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001688 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301689 session->supported_nss_1x1,
1690 session->pePersona,
1691 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001692
1693 /*Store Persona */
1694 session->pePersona = sme_join_req->staPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +05301695 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301696 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d force_24ghz_in_ht20 %d"),
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001697 session->pePersona, sme_join_req->cbMode,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301698 session->nwType, session->dot11mode,
1699 sme_join_req->force_24ghz_in_ht20);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001700
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001701 /* Copy The channel Id to the session Table */
1702 session->currentOperChannel = bss_desc->channelId;
1703 if (IS_5G_CH(session->currentOperChannel))
1704 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001705 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001706 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1707 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1708 session->vdev_nss = vdev_type_nss->p2p_cli;
1709 else
1710 session->vdev_nss = vdev_type_nss->sta;
1711 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001712 session->vhtCapability =
1713 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001714 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301715 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001716 session->vht_config.su_beam_formee =
1717 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001719 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001720 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001721 session->enableVhtpAid =
1722 sme_join_req->enableVhtpAid;
1723 session->enableVhtGid =
1724 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001725 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001726 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001727 }
Krunal Soni53993f72016-07-08 18:20:03 -07001728
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001729 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301730 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001731 session->vht_config.su_beam_formee,
1732 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001733 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001734 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001735 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001736 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301737 session->force_24ghz_in_ht20 =
1738 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001739 /* cbMode is already merged value of peer and self -
1740 * done by csr in csr_get_cb_mode_from_ies */
1741 session->htSupportedChannelWidthSet =
1742 (sme_join_req->cbMode) ? 1 : 0;
1743 session->htRecommendedTxWidthSet =
1744 session->htSupportedChannelWidthSet;
1745 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1746
1747 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1748 session->ch_center_freq_seg0 =
1749 session->currentOperChannel - 2;
1750 session->ch_width = CH_WIDTH_40MHZ;
1751 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1752 sme_join_req->cbMode) {
1753 session->ch_center_freq_seg0 =
1754 session->currentOperChannel + 2;
1755 session->ch_width = CH_WIDTH_40MHZ;
1756 } else {
1757 session->ch_center_freq_seg0 = 0;
1758 session->ch_width = CH_WIDTH_20MHZ;
1759 }
1760
Naveen Rawataeca1b92017-10-16 16:55:31 -07001761 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1762 lim_update_session_he_capable(mac_ctx, session);
1763 lim_copy_join_req_he_cap(session, sme_join_req);
1764 }
1765
1766
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001767 /* Record if management frames need to be protected */
1768#ifdef WLAN_FEATURE_11W
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +05301769 if ((eSIR_ED_AES_128_CMAC ==
1770 sme_join_req->MgmtEncryptionType) ||
1771 (eSIR_ED_AES_GMAC_128 == sme_join_req->MgmtEncryptionType) ||
1772 (eSIR_ED_AES_GMAC_256 == sme_join_req->MgmtEncryptionType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001773 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001774 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001775 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001776#endif
1777
1778#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001779 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001780#endif
1781
1782 /* Copy the SSID from smejoinreq to session entry */
1783 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301784 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001785 session->ssId.length);
1786
1787 /*
1788 * Determin 11r or ESE connection based on input from SME
1789 * which inturn is dependent on the profile the user wants
1790 * to connect to, So input is coming from supplicant
1791 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001792 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001793#ifdef FEATURE_WLAN_ESE
1794 session->isESEconnection = sme_join_req->isESEconnection;
1795#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796 session->isFastTransitionEnabled =
1797 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001798
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001799 session->isFastRoamIniFeatureEnabled =
1800 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001801 session->txLdpcIniFeatureEnabled =
1802 sme_join_req->txLdpcIniFeatureEnabled;
1803
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301804 lim_update_fils_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001805 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1806 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807 } else {
1808 /*
1809 * Throw an error and return and make
1810 * sure to delete the session.
1811 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001812 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001813 session->bssType);
1814 ret_code = eSIR_SME_INVALID_PARAMETERS;
1815 goto end;
1816 }
1817
1818 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301819 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001820 &sme_join_req->addIEScan, sizeof(tSirAddie));
1821
1822 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301823 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001824 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1825
1826 val = sizeof(tLimMlmJoinReq) +
1827 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301828 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829 if (NULL == mlm_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001830 pe_err("AllocateMemory failed for mlmJoinReq");
Nitesh Shah0102cac2016-07-13 14:38:30 +05301831 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1832 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001834
1835 /* PE SessionId is stored as a part of JoinReq */
1836 mlm_join_req->sessionId = session->peSessionId;
1837
1838 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1839 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1840 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001841 pe_err("couldn't retrieve JoinFailureTimer value"
1842 " setting to default value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001843 mlm_join_req->joinFailureTimeout =
1844 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1845 }
1846
1847 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301848 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001849 (void *)&sme_join_req->operationalRateSet,
1850 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301851 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001852 (void *)&sme_join_req->extendedRateSet,
1853 sizeof(tSirMacRateSet));
1854 /*
1855 * this may not be needed anymore now, as rateSet is now
1856 * included in the session entry and MLM has session context.
1857 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301858 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001859 (void *)&session->rateSet,
1860 sizeof(tSirMacRateSet));
1861
1862 session->encryptType = sme_join_req->UCEncryptionType;
1863
1864 mlm_join_req->bssDescription.length =
1865 session->pLimJoinReq->bssDescription.length;
1866
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301867 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868 (uint8_t *)
1869 &session->pLimJoinReq->bssDescription.bssId,
1870 session->pLimJoinReq->bssDescription.length + 2);
1871
1872 session->limCurrentBssCaps =
1873 session->pLimJoinReq->bssDescription.capabilityInfo;
1874
1875 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1876 session->currentOperChannel);
1877 local_power_constraint = reg_max;
1878
1879 lim_extract_ap_capability(mac_ctx,
1880 (uint8_t *)
1881 session->pLimJoinReq->bssDescription.ieFields,
1882 lim_get_ielen_from_bss_description(
1883 &session->pLimJoinReq->bssDescription),
1884 &session->limCurrentBssQosCaps,
1885 &session->limCurrentBssPropCap,
1886 &session->gLimCurrentBssUapsd,
1887 &local_power_constraint, session);
1888
Krunal Soni53993f72016-07-08 18:20:03 -07001889 /*
1890 * Once the AP capabilities are available then set the
1891 * beam forming capabilities accordingly.
1892 */
1893 if (session->nss == 1) {
1894 session->vht_config.su_beam_former = 0;
1895 session->vht_config.tx_stbc = 0;
1896 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301897 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001898 }
1899
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001900 session->maxTxPower = lim_get_max_tx_power(reg_max,
1901 local_power_constraint,
1902 mac_ctx->roam.configParam.nTxPowerCap);
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301903
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001904 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301905 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001906
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301907 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1908 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1909 pe_debug("Update MaxTxPower in join Req to %d",
1910 sme_join_req->powerCap.maxTxPower);
1911 }
1912
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001913 if (session->gLimCurrentBssUapsd) {
1914 session->gUapsdPerAcBitmask =
1915 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001916 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001917 session->gUapsdPerAcBitmask);
1918
1919 /* resetting the dynamic uapsd mask */
1920 session->gUapsdPerAcDeliveryEnableMask = 0;
1921 session->gUapsdPerAcTriggerEnableMask = 0;
1922 }
1923
1924 session->limRFBand =
1925 lim_get_rf_band(session->currentOperChannel);
1926
1927 /* Initialize 11h Enable Flag */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001928 if (BAND_5G == session->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001929 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1930 &val) != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001931 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001932 session->lim11hEnable =
1933 WNI_CFG_11H_ENABLED_STADEF;
1934 } else {
1935 session->lim11hEnable = val;
1936 }
1937 } else {
1938 session->lim11hEnable = 0;
1939 }
1940
1941 /*
1942 * To care of the scenario when STA transitions from
1943 * IBSS to Infrastructure mode.
1944 */
1945 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1946
1947 session->limPrevSmeState = session->limSmeState;
1948 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1949 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1950 session->peSessionId,
1951 session->limSmeState));
1952
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001953 /* Indicate whether spectrum management is enabled */
1954 session->spectrumMgtEnabled =
1955 sme_join_req->spectrumMgtIndicator;
1956
1957 /* Enable the spectrum management if this is a DFS channel */
1958 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001959 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001960 session->currentOperChannel))
1961 session->spectrumMgtEnabled = true;
1962
1963 session->isOSENConnection = sme_join_req->isOSENConnection;
1964
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001965 /* Issue LIM_MLM_JOIN_REQ to MLM */
1966 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1967 (uint32_t *) mlm_join_req);
1968 return;
1969
1970 } else {
1971 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001972 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001973 mac_ctx->lim.gLimSmeState);
1974 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1975 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1976 session = NULL;
1977 goto end;
1978 }
1979
1980end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301981 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1982 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983
1984 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301985 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001986 sme_join_req = NULL;
1987 if (NULL != session)
1988 session->pLimJoinReq = NULL;
1989 }
1990 if (ret_code != eSIR_SME_SUCCESS) {
1991 if (NULL != session) {
1992 pe_delete_session(mac_ctx, session);
1993 session = NULL;
1994 }
1995 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001996 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001997 sme_session_id, ret_code);
1998 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1999 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
2000 sme_transaction_id);
2001}
2002
Amar Singhala297bfa2015-10-15 15:07:29 -07002003uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002004 uint8_t iniTxPower)
2005{
2006 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302007 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002008
Anurag Chouhan6d760662016-02-20 16:05:43 +05302009 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002010 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2011 maxTxPower = txPower;
2012 else if (txPower < MIN_TX_PWR_CAP)
2013 maxTxPower = MIN_TX_PWR_CAP;
2014 else
2015 maxTxPower = MAX_TX_PWR_CAP;
2016
2017 return maxTxPower;
2018}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002019
2020/**
2021 * __lim_process_sme_reassoc_req() - process reassoc req
2022 *
2023 * @mac_ctx: Pointer to Global MAC structure
2024 * @msg_buf: pointer to the SME message buffer
2025 *
2026 * This function is called to process SME_REASSOC_REQ message
2027 * from HDD or upper layer application.
2028 *
2029 * Return: None
2030 */
2031
2032static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2033 uint32_t *msg_buf)
2034{
2035 uint16_t caps;
2036 uint32_t val;
2037 tpSirSmeJoinReq reassoc_req = NULL;
2038 tLimMlmReassocReq *mlm_reassoc_req;
2039 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2040 tpPESession session_entry = NULL;
2041 uint8_t session_id;
2042 uint8_t sme_session_id;
2043 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002044 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002045 uint32_t tele_bcn_en = 0;
2046 uint16_t size;
2047
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002048 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302049 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002050 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002051 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002052
2053 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2054 goto end;
2055 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302056 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002057
2058 if (!lim_is_sme_join_req_valid(mac_ctx,
2059 (tpSirSmeJoinReq)reassoc_req)) {
2060 /*
2061 * Received invalid eWNI_SME_REASSOC_REQ
2062 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002063 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002064
2065 ret_code = eSIR_SME_INVALID_PARAMETERS;
2066 goto end;
2067 }
2068
2069 session_entry = pe_find_session_by_bssid(mac_ctx,
2070 reassoc_req->bssDescription.bssId,
2071 &session_id);
2072 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002073 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002074 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2075 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002076 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002077 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
2078 &sme_session_id, &transaction_id);
2079 session_entry =
2080 pe_find_session_by_sme_session_id(mac_ctx,
2081 sme_session_id);
2082 if (session_entry != NULL)
2083 lim_handle_sme_join_result(mac_ctx,
2084 eSIR_SME_INVALID_PARAMETERS,
2085 eSIR_MAC_UNSPEC_FAILURE_STATUS,
2086 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002087 goto end;
2088 }
2089#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2090 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2091 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2092#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2093 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2094
2095 /* Store the reassoc handle in the session Table */
2096 session_entry->pLimReAssocReq = reassoc_req;
2097
2098 session_entry->dot11mode = reassoc_req->dot11mode;
2099 session_entry->vhtCapability =
2100 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002101
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302102 if (session_entry->vhtCapability) {
2103 if (session_entry->pePersona == QDF_STA_MODE) {
2104 session_entry->vht_config.su_beam_formee =
2105 reassoc_req->vht_config.su_beam_formee;
2106 } else {
2107 reassoc_req->vht_config.su_beam_formee = 0;
2108 }
2109 session_entry->enableVhtpAid =
2110 reassoc_req->enableVhtpAid;
2111 session_entry->enableVhtGid =
2112 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002113 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302114 }
2115
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002116 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302117 session_entry->vhtCapability,
2118 session_entry->vht_config.su_beam_formee,
2119 session_entry->vht_config.su_beam_former);
2120
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002121 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2122 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002123 session_entry->send_smps_action =
2124 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002125 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002126 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002127 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002128 session_entry->send_smps_action,
2129 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002130 /*
2131 * Reassociate request is expected
2132 * in link established state only.
2133 */
2134
2135 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002136 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2137 /*
2138 * May be from 11r FT pre-auth. So lets check it
2139 * before we bail out
2140 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002141 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002142 session_entry->peSessionId);
2143
2144 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302145 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002146 session_entry->limReAssocbssId,
2147 6)) {
2148 lim_print_mac_addr(mac_ctx,
2149 reassoc_req->bssDescription.
2150 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002151 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002152 ret_code = eSIR_SME_INVALID_PARAMETERS;
2153 goto end;
2154 }
2155
2156 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2157 session_entry);
2158 return;
2159 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002160 /*
2161 * Should not have received eWNI_SME_REASSOC_REQ
2162 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002163 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002164 session_entry->limSmeState);
2165 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2166
2167 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2168 goto end;
2169 }
2170
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302171 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002172 session_entry->pLimReAssocReq->bssDescription.bssId,
2173 sizeof(tSirMacAddr));
2174
2175 session_entry->limReassocChannelId =
2176 session_entry->pLimReAssocReq->bssDescription.channelId;
2177
2178 session_entry->reAssocHtSupportedChannelWidthSet =
2179 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2180 session_entry->reAssocHtRecommendedTxWidthSet =
2181 session_entry->reAssocHtSupportedChannelWidthSet;
2182 session_entry->reAssocHtSecondaryChannelOffset =
2183 session_entry->pLimReAssocReq->cbMode;
2184
2185 session_entry->limReassocBssCaps =
2186 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2187 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2188 session_entry->currentOperChannel);
2189 local_pwr_constraint = reg_max;
2190
2191 lim_extract_ap_capability(mac_ctx,
2192 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2193 lim_get_ielen_from_bss_description(
2194 &session_entry->pLimReAssocReq->bssDescription),
2195 &session_entry->limReassocBssQosCaps,
2196 &session_entry->limReassocBssPropCap,
2197 &session_entry->gLimCurrentBssUapsd,
2198 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302199 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002200 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302201 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002202 /* Copy the SSID from session entry to local variable */
2203 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302204 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002205 reassoc_req->ssId.ssId,
2206 session_entry->limReassocSSID.length);
2207 if (session_entry->gLimCurrentBssUapsd) {
2208 session_entry->gUapsdPerAcBitmask =
2209 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002210 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002211 session_entry->gUapsdPerAcBitmask);
2212 }
2213
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302214 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002215 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002216 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002217
2218 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2219 goto end;
2220 }
2221
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302222 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002223 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2224
2225 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2226 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002227 eSIR_SUCCESS)
2228 pe_err("could not retrieve ReassocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002229
2230 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002231 eSIR_SUCCESS)
2232 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302233
2234 lim_update_caps_info_for_bss(mac_ctx, &caps,
2235 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002236 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302237
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002238 mlm_reassoc_req->capabilityInfo = caps;
2239
2240 /* Update PE session_id */
2241 mlm_reassoc_req->sessionId = session_id;
2242
2243 /*
2244 * If telescopic beaconing is enabled, set listen interval to
2245 * WNI_CFG_TELE_BCN_MAX_LI
2246 */
2247 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2248 &tele_bcn_en) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002249 pe_err("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002250
2251 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2252
2253 if (tele_bcn_en) {
2254 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2255 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002256 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002257 } else {
2258 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2259 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002260 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002261 }
2262
2263 mlm_reassoc_req->listenInterval = (uint16_t) val;
2264
2265 /* Indicate whether spectrum management is enabled */
2266 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2267
2268 /* Enable the spectrum management if this is a DFS channel */
2269 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002270 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002271 session_entry->currentOperChannel))
2272 session_entry->spectrumMgtEnabled = true;
2273
2274 session_entry->limPrevSmeState = session_entry->limSmeState;
2275 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2276
2277 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2278 session_entry->peSessionId,
2279 session_entry->limSmeState));
2280
2281 lim_post_mlm_message(mac_ctx,
2282 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2283 return;
2284end:
2285 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302286 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002287 if (session_entry)
2288 session_entry->pLimReAssocReq = NULL;
2289 }
2290
2291 if (session_entry) {
2292 /*
2293 * error occurred after we determined the session so extract
2294 * session and transaction info from there
2295 */
2296 sme_session_id = session_entry->smeSessionId;
2297 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002298 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002299 /*
2300 * error occurred before or during the time we determined
2301 * the session so extract the session and transaction info
2302 * from the message
2303 */
2304 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2305 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002306 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002307 /*
2308 * Send Reassoc failure response to host
2309 * (note session_entry may be NULL, but that's OK)
2310 */
2311 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2312 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2313 session_entry, sme_session_id,
2314 transaction_id);
2315}
2316
2317bool send_disassoc_frame = 1;
2318/**
2319 * __lim_process_sme_disassoc_req()
2320 *
2321 ***FUNCTION:
2322 * This function is called to process SME_DISASSOC_REQ message
2323 * from HDD or upper layer application.
2324 *
2325 ***LOGIC:
2326 *
2327 ***ASSUMPTIONS:
2328 *
2329 ***NOTE:
2330 *
2331 * @param pMac Pointer to Global MAC structure
2332 * @param *pMsgBuf A pointer to the SME message buffer
2333 * @return None
2334 */
2335
2336static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2337{
2338 uint16_t disassocTrigger, reasonCode;
2339 tLimMlmDisassocReq *pMlmDisassocReq;
2340 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2341 tSirSmeDisassocReq smeDisassocReq;
2342 tpPESession psessionEntry = NULL;
2343 uint8_t sessionId;
2344 uint8_t smesessionId;
2345 uint16_t smetransactionId;
2346
2347 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002348 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002349 return;
2350 }
2351
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302352 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002353 smesessionId = smeDisassocReq.sessionId;
2354 smetransactionId = smeDisassocReq.transactionId;
2355 if (!lim_is_sme_disassoc_req_valid(pMac,
2356 &smeDisassocReq,
2357 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002358 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002359 if (pMac->lim.gLimRspReqd) {
2360 pMac->lim.gLimRspReqd = false;
2361
2362 retCode = eSIR_SME_INVALID_PARAMETERS;
2363 disassocTrigger = eLIM_HOST_DISASSOC;
2364 goto sendDisassoc;
2365 }
2366
2367 return;
2368 }
2369
2370 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002371 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002372 &sessionId);
2373 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002374 pe_err("session does not exist for given bssId "
2375 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002376 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002377 retCode = eSIR_SME_INVALID_PARAMETERS;
2378 disassocTrigger = eLIM_HOST_DISASSOC;
2379 goto sendDisassoc;
2380 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002381 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2382 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002383 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2384 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002385 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002386
2387#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2388 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2389 0, smeDisassocReq.reasonCode);
2390#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2391
2392 /* Update SME session Id and SME transaction ID */
2393
2394 psessionEntry->smeSessionId = smesessionId;
2395 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002396 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002397 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002398
2399 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2400 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002401 switch (psessionEntry->limSmeState) {
2402 case eLIM_SME_ASSOCIATED_STATE:
2403 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002404 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002405 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002406 psessionEntry->limPrevSmeState =
2407 psessionEntry->limSmeState;
2408 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002409 /* Delete all TDLS peers connected before leaving BSS */
2410 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002411 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2412 psessionEntry->peSessionId,
2413 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002414 break;
2415
2416 case eLIM_SME_WT_DEAUTH_STATE:
2417 /* PE shall still process the DISASSOC_REQ and proceed with
2418 * link tear down even if it had already sent a DEAUTH_IND to
2419 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2420 * its been set when PE entered WT_DEAUTH_STATE.
2421 */
2422 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2423 MTRACE(mac_trace
2424 (pMac, TRACE_CODE_SME_STATE,
2425 psessionEntry->peSessionId,
2426 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002427 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002428 break;
2429
2430 case eLIM_SME_WT_DISASSOC_STATE:
2431 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2432 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2433 * PE can continue processing DISASSOC_REQ and send the response instead
2434 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2435 * for disassoc frame.
2436 *
2437 * It will send a disassoc, which is ok. However, we can use the global flag
2438 * sendDisassoc to not send disassoc frame.
2439 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002440 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002441 break;
2442
2443 case eLIM_SME_JOIN_FAILURE_STATE: {
2444 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002445 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002446 if (pMac->lim.gLimRspReqd) {
2447 retCode = eSIR_SME_SUCCESS;
2448 disassocTrigger = eLIM_HOST_DISASSOC;
2449 goto sendDisassoc;
2450 }
2451 }
2452 break;
2453 default:
2454 /**
2455 * STA is not currently associated.
2456 * Log error and send response to host
2457 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002458 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002459 psessionEntry->limSmeState);
2460 lim_print_sme_state(pMac, LOGE,
2461 psessionEntry->limSmeState);
2462
2463 if (pMac->lim.gLimRspReqd) {
2464 if (psessionEntry->limSmeState !=
2465 eLIM_SME_WT_ASSOC_STATE)
2466 pMac->lim.gLimRspReqd = false;
2467
2468 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2469 disassocTrigger = eLIM_HOST_DISASSOC;
2470 goto sendDisassoc;
2471 }
2472
2473 return;
2474 }
2475
2476 break;
2477
2478 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002479 /* Fall through */
2480 break;
2481
2482 case eLIM_STA_IN_IBSS_ROLE:
2483 default:
2484 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002485 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002486 GET_LIM_SYSTEM_ROLE(psessionEntry));
2487
2488 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2489 disassocTrigger = eLIM_HOST_DISASSOC;
2490 goto sendDisassoc;
2491 } /* end switch (pMac->lim.gLimSystemRole) */
2492
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302493 disassocTrigger = eLIM_HOST_DISASSOC;
2494 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002495
2496 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002497 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002498 send_disassoc_frame = 0;
2499 }
2500 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002501 pe_debug("Sending Disasscoc with disassoc Trigger"
2502 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002503 disassocTrigger, reasonCode);
2504
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302505 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002506 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002507 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002508 return;
2509 }
2510
Anurag Chouhanc5548422016-02-24 18:33:27 +05302511 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002512 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002513
2514 pMlmDisassocReq->reasonCode = reasonCode;
2515 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2516
2517 /* Update PE session ID */
2518 pMlmDisassocReq->sessionId = sessionId;
2519
2520 lim_post_mlm_message(pMac,
2521 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2522 return;
2523
2524sendDisassoc:
2525 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002526 lim_send_sme_disassoc_ntf(pMac,
2527 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002528 retCode,
2529 disassocTrigger,
2530 1, smesessionId, smetransactionId,
2531 psessionEntry);
2532 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002533 lim_send_sme_disassoc_ntf(pMac,
2534 smeDisassocReq.peer_macaddr.bytes,
2535 retCode, disassocTrigger, 1,
2536 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002537
2538} /*** end __lim_process_sme_disassoc_req() ***/
2539
2540/** -----------------------------------------------------------------
2541 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2542
2543 This function is called to process SME_DISASSOC_CNF message
2544 from HDD or upper layer application.
2545
2546 \param pMac - global mac structure
2547 \param pStaDs - station dph hash node
2548 \return none
2549 \sa
2550 ----------------------------------------------------------------- */
2551static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2552{
2553 tSirSmeDisassocCnf smeDisassocCnf;
2554 uint16_t aid;
2555 tpDphHashNode pStaDs;
2556 tpPESession psessionEntry;
2557 uint8_t sessionId;
2558
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302559 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002560 sizeof(struct sSirSmeDisassocCnf));
2561
2562 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002563 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002564 &sessionId);
2565 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002566 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002567 return;
2568 }
2569
2570 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002571 pe_err("received invalid SME_DISASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002572 return;
2573 }
2574#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2575 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2576 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2577 psessionEntry,
2578 (uint16_t) smeDisassocCnf.statusCode, 0);
2579 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2580 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2581 psessionEntry,
2582 (uint16_t) smeDisassocCnf.statusCode, 0);
2583#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2584
2585 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2586 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002587 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2588 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2589 && (psessionEntry->limSmeState !=
2590 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002591 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002592 psessionEntry->limSmeState);
2593 lim_print_sme_state(pMac, LOGE,
2594 psessionEntry->limSmeState);
2595 return;
2596 }
2597 break;
2598
2599 case eLIM_AP_ROLE:
2600 /* Fall through */
2601 break;
2602
2603 case eLIM_STA_IN_IBSS_ROLE:
2604 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002605 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606 GET_LIM_SYSTEM_ROLE(psessionEntry));
2607
2608 return;
2609 }
2610
2611 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2612 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2613 LIM_IS_AP_ROLE(psessionEntry)) {
2614 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002615 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002616 &psessionEntry->dph.dphHashTable);
2617 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002618 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2619 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002620 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002621 return;
2622 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302623
2624 if ((pStaDs->mlmStaContext.mlmState ==
2625 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2626 (pStaDs->mlmStaContext.mlmState ==
2627 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002628 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002629 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302630 pStaDs->mlmStaContext.mlmState);
2631 return;
2632 }
2633
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002634 /* Delete FT session if there exists one */
2635 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002636 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2637
2638 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002639 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002640 }
2641
2642 return;
2643}
2644
2645/**
2646 * __lim_process_sme_deauth_req() - process sme deauth req
2647 * @mac_ctx: Pointer to Global MAC structure
2648 * @msg_buf: pointer to the SME message buffer
2649 *
2650 * This function is called to process SME_DEAUTH_REQ message
2651 * from HDD or upper layer application.
2652 *
2653 * Return: None
2654 */
2655
2656static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2657 uint32_t *msg_buf)
2658{
2659 uint16_t deauth_trigger, reason_code;
2660 tLimMlmDeauthReq *mlm_deauth_req;
2661 tSirSmeDeauthReq sme_deauth_req;
2662 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2663 tpPESession session_entry;
2664 uint8_t session_id; /* PE sessionId */
2665 uint8_t sme_session_id;
2666 uint16_t sme_transaction_id;
2667
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302668 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002669 sme_session_id = sme_deauth_req.sessionId;
2670 sme_transaction_id = sme_deauth_req.transactionId;
2671
2672 /*
2673 * We need to get a session first but we don't even know
2674 * if the message is correct.
2675 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002676 session_entry = pe_find_session_by_bssid(mac_ctx,
2677 sme_deauth_req.bssid.bytes,
2678 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002679 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002680 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002681 ret_code = eSIR_SME_INVALID_PARAMETERS;
2682 deauth_trigger = eLIM_HOST_DEAUTH;
2683 goto send_deauth;
2684 }
2685
2686 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2687 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002688 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002689 mac_ctx->lim.gLimRspReqd = false;
2690
2691 ret_code = eSIR_SME_INVALID_PARAMETERS;
2692 deauth_trigger = eLIM_HOST_DEAUTH;
2693 goto send_deauth;
2694 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002695 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2696 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002697 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2698 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002699 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002700#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2701 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2702 session_entry, 0, sme_deauth_req.reasonCode);
2703#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2704
2705 /* Update SME session ID and Transaction ID */
2706 session_entry->smeSessionId = sme_session_id;
2707 session_entry->transactionId = sme_transaction_id;
2708
2709 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2710 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002711 switch (session_entry->limSmeState) {
2712 case eLIM_SME_ASSOCIATED_STATE:
2713 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302714 /* Delete all TDLS peers connected before leaving BSS */
2715 lim_delete_tdls_peers(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002716 case eLIM_SME_WT_ASSOC_STATE:
2717 case eLIM_SME_JOIN_FAILURE_STATE:
2718 case eLIM_SME_IDLE_STATE:
2719 session_entry->limPrevSmeState =
2720 session_entry->limSmeState;
2721 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2722 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2723 session_entry->peSessionId,
2724 session_entry->limSmeState));
2725 /* Send Deauthentication request to MLM below */
2726 break;
2727 case eLIM_SME_WT_DEAUTH_STATE:
2728 case eLIM_SME_WT_DISASSOC_STATE:
2729 /*
2730 * PE Recieved a Deauth/Disassoc frame. Normally it get
2731 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2732 * Which means host is also trying to disconnect.
2733 * PE can continue processing DEAUTH_REQ and send
2734 * the response instead of failing the request.
2735 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2736 * was sent for deauth/disassoc frame.
2737 */
2738 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002739 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002740 break;
2741 default:
2742 /*
2743 * STA is not in a state to deauthenticate with
2744 * peer. Log error and send response to host.
2745 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002746 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002747 session_entry->limSmeState);
2748 lim_print_sme_state(mac_ctx, LOGE,
2749 session_entry->limSmeState);
2750
2751 if (mac_ctx->lim.gLimRspReqd) {
2752 mac_ctx->lim.gLimRspReqd = false;
2753
2754 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2755 deauth_trigger = eLIM_HOST_DEAUTH;
2756
wadesong42968e92017-06-08 14:11:21 +08002757 /*
2758 * here we received deauth request from AP so
2759 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2760 * have ISSUED delSta then mlm state should be
2761 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2762 * delBSS rsp then mlm state should be
2763 * eLIM_MLM_IDLE_STATE so the below condition
2764 * captures the state where delSta not done
2765 * and firmware still in connected state.
2766 */
2767 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002768 eLIM_SME_WT_DEAUTH_STATE &&
2769 session_entry->limMlmState !=
2770 eLIM_MLM_IDLE_STATE &&
2771 session_entry->limMlmState !=
2772 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002773 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002774 goto send_deauth;
2775 }
2776 return;
2777 }
2778 break;
2779
2780 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002781 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002782 if (mac_ctx->lim.gLimRspReqd) {
2783 mac_ctx->lim.gLimRspReqd = false;
2784 ret_code = eSIR_SME_INVALID_PARAMETERS;
2785 deauth_trigger = eLIM_HOST_DEAUTH;
2786 goto send_deauth;
2787 }
2788 return;
2789 case eLIM_AP_ROLE:
2790 break;
2791 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002792 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002793 GET_LIM_SYSTEM_ROLE(session_entry));
2794 if (mac_ctx->lim.gLimRspReqd) {
2795 mac_ctx->lim.gLimRspReqd = false;
2796 ret_code = eSIR_SME_INVALID_PARAMETERS;
2797 deauth_trigger = eLIM_HOST_DEAUTH;
2798 goto send_deauth;
2799 }
2800 return;
2801 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2802
2803 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2804 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002805 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002806 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2807 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2808 } else {
2809 deauth_trigger = eLIM_HOST_DEAUTH;
2810 reason_code = sme_deauth_req.reasonCode;
2811 }
2812
2813 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302814 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002815 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002816 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002817 if (mac_ctx->lim.gLimRspReqd) {
2818 mac_ctx->lim.gLimRspReqd = false;
2819 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2820 deauth_trigger = eLIM_HOST_DEAUTH;
2821 goto send_deauth;
2822 }
2823 return;
2824 }
2825
Anurag Chouhanc5548422016-02-24 18:33:27 +05302826 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002827 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002828
2829 mlm_deauth_req->reasonCode = reason_code;
2830 mlm_deauth_req->deauthTrigger = deauth_trigger;
2831
2832 /* Update PE session Id */
2833 mlm_deauth_req->sessionId = session_id;
2834
2835 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2836 (uint32_t *)mlm_deauth_req);
2837 return;
2838
2839send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002840 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2841 ret_code, deauth_trigger, 1,
2842 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002843}
2844
2845/**
2846 * __lim_process_sme_set_context_req()
2847 *
2848 * @mac_ctx: Pointer to Global MAC structure
2849 * @msg_buf: pointer to the SME message buffer
2850 *
2851 * This function is called to process SME_SETCONTEXT_REQ message
2852 * from HDD or upper layer application.
2853 *
2854 * Return: None
2855 */
2856
2857static void
2858__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2859{
2860 tpSirSmeSetContextReq set_context_req;
2861 tLimMlmSetKeysReq *mlm_set_key_req;
2862 tpPESession session_entry;
2863 uint8_t session_id; /* PE sessionID */
2864 uint8_t sme_session_id;
2865 uint16_t sme_transaction_id;
2866
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002867 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002868 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002869 return;
2870 }
2871
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302872 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002873 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002874 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002875 return;
2876 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302877 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002878 sizeof(struct sSirSmeSetContextReq));
2879 sme_session_id = set_context_req->sessionId;
2880 sme_transaction_id = set_context_req->transactionId;
2881
2882 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002883 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002884 goto end;
2885 }
2886
2887 if (set_context_req->keyMaterial.numKeys >
2888 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002889 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002890 set_context_req->keyMaterial.numKeys);
2891 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002892 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002893 eSIR_SME_INVALID_PARAMETERS, NULL,
2894 sme_session_id, sme_transaction_id);
2895 goto end;
2896 }
2897
2898 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002899 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002900 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002901 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002902 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002903 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002904 eSIR_SME_INVALID_PARAMETERS, NULL,
2905 sme_session_id, sme_transaction_id);
2906 goto end;
2907 }
2908#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2909 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2910 session_entry, 0, 0);
2911#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2912
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002913 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002914 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2915 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002916 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002917 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2918 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302919 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002920 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002921 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002922 goto end;
2923 }
2924 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2925 mlm_set_key_req->numKeys =
2926 set_context_req->keyMaterial.numKeys;
2927 if (mlm_set_key_req->numKeys >
2928 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002929 pe_err("no.of keys exceeded max num of default keys limit");
Jingxiang Ge4168a232018-01-03 18:47:15 +08002930 qdf_mem_free(mlm_set_key_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002931 goto end;
2932 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302933 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002934 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002935
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302936 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002937 (uint8_t *) &set_context_req->keyMaterial.key,
2938 sizeof(tSirKeys) *
2939 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2940 numKeys : 1));
2941
2942 mlm_set_key_req->sessionId = session_id;
2943 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002944 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002945 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002946
2947 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2948 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2949 LIM_IS_AP_ROLE(session_entry)) {
2950 if (set_context_req->keyMaterial.key[0].keyLength) {
2951 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002952
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002953 key_id =
2954 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302955 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002956 &session_entry->WEPKeyMaterial[key_id],
2957 (uint8_t *) &set_context_req->keyMaterial,
2958 sizeof(tSirKeyMaterial));
2959 } else {
2960 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002961
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2963 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302964 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002965 &mlm_set_key_req->key[i],
2966 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2967 sizeof(tSirKeys));
2968 }
2969 }
2970 }
2971 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2972 (uint32_t *) mlm_set_key_req);
2973 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002974 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002975 GET_LIM_SYSTEM_ROLE(session_entry),
2976 session_entry->limSmeState);
2977 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2978
2979 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002980 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002981 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2982 session_entry, sme_session_id,
2983 sme_transaction_id);
2984 }
2985end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302986 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002987 return;
2988}
2989
2990/**
2991 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2992 *
2993 * @mac_ctx: Pointer to Global MAC structure
2994 * @msg_buf: pointer to the SME message buffer
2995 *
2996 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2997 * from HDD or upper layer application.
2998 *
2999 * Return: None
3000 */
3001
Jeff Johnson801f1532016-10-07 07:54:50 -07003002static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3003 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003004{
3005 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3006 tpDphHashNode sta_ds = NULL;
3007 tpPESession session_entry = NULL;
3008 tSap_Event sap_event;
3009 tpWLAN_SAPEventCB sap_event_cb = NULL;
3010 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3011 uint8_t session_id = CSR_SESSION_ID_INVALID;
3012 uint8_t assoc_id = 0;
3013 uint8_t sta_cnt = 0;
3014
3015 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003016 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003017 return;
3018 }
3019
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303020 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003021 sizeof(struct sSirSmeGetAssocSTAsReq));
3022 /*
3023 * Get Associated stations from PE.
3024 * Find PE session Entry
3025 */
3026 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003027 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003028 &session_id);
3029 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003030 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003031 goto lim_assoc_sta_end;
3032 }
3033
3034 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003035 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003036 session_entry->limSmeState,
3037 GET_LIM_SYSTEM_ROLE(session_entry));
3038 goto lim_assoc_sta_end;
3039 }
3040 /* Retrieve values obtained in the request message */
3041 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3042 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3043
3044 if (NULL == assoc_sta_tmp)
3045 goto lim_assoc_sta_end;
3046 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3047 assoc_id++) {
3048 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3049 &session_entry->dph.dphHashTable);
3050 if (NULL == sta_ds)
3051 continue;
3052 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303053 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003054 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303055 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003056 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3057 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3058
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303059 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003060 (uint8_t *)&sta_ds->supportedRates,
3061 sizeof(tSirSupportedRates));
3062 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3063 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3064 assoc_sta_tmp->Support40Mhz =
3065 sta_ds->htDsssCckRate40MHzSupport;
3066
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003067 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003068 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003069 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003070 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003071 pe_debug("Association Id: %d Station Index: %d",
3072 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003073 assoc_sta_tmp++;
3074 sta_cnt++;
3075 }
3076 }
3077lim_assoc_sta_end:
3078 /*
3079 * Call hdd callback with sap event to send the list of
3080 * associated stations from PE
3081 */
3082 if (sap_event_cb != NULL) {
3083 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3084 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303085 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003086 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3087 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3088 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3089 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3090 }
3091}
3092
3093/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003094 * __lim_counter_measures()
3095 *
3096 * FUNCTION:
3097 * This function is called to "implement" MIC counter measure
3098 * and is *temporary* only
3099 *
3100 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3101 * we don't do the proper STA disassoc sequence since the
3102 * BSS will be stoped anyway
3103 *
3104 ***ASSUMPTIONS:
3105 *
3106 ***NOTE:
3107 *
3108 * @param pMac Pointer to Global MAC structure
3109 * @return None
3110 */
3111
3112static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3113{
3114 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003115
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003116 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003117 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3118 mac, psessionEntry, false);
3119};
3120
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003121static void
3122__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3123{
3124 tSirSmeStopBssReq stopBssReq;
3125 tSirRetStatus status;
3126 tLimSmeStates prevState;
3127 tpPESession psessionEntry;
3128 uint8_t smesessionId;
3129 uint8_t sessionId;
3130 uint16_t smetransactionId;
3131 uint8_t i = 0;
3132 tpDphHashNode pStaDs = NULL;
3133
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303134 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003135 smesessionId = stopBssReq.sessionId;
3136 smetransactionId = stopBssReq.transactionId;
3137
3138 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003139 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003140 /* Send Stop BSS response to host */
3141 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3142 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3143 smetransactionId);
3144 return;
3145 }
3146
3147 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003148 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003149 &sessionId);
3150 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003151 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003152 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3153 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3154 smetransactionId);
3155 return;
3156 }
3157#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3158 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3159 0, 0);
3160#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3161
3162 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3163 LIM_IS_STA_ROLE(psessionEntry)) {
3164 /**
3165 * Should not have received STOP_BSS_REQ in states
3166 * other than 'normal' state or on STA in Infrastructure
3167 * mode. Log error and return response to host.
3168 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003169 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003170 psessionEntry->limSmeState,
3171 GET_LIM_SYSTEM_ROLE(psessionEntry));
3172 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3173 /* / Send Stop BSS response to host */
3174 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3175 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3176 smetransactionId);
3177 return;
3178 }
3179
3180 if (LIM_IS_AP_ROLE(psessionEntry))
3181 lim_wpspbc_close(pMac, psessionEntry);
3182
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003183 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003184 stopBssReq.reasonCode);
3185
3186 prevState = psessionEntry->limSmeState;
3187
3188 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3189 MTRACE(mac_trace
3190 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3191 psessionEntry->limSmeState));
3192
3193 /* Update SME session Id and Transaction Id */
3194 psessionEntry->smeSessionId = smesessionId;
3195 psessionEntry->transactionId = smetransactionId;
3196
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003197 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3198 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3199 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003200 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003201
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003202 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3203 /* Send disassoc all stations associated thru TKIP */
3204 __lim_counter_measures(pMac, psessionEntry);
3205 else
3206 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003207 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3208 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003209 }
3210
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003211 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3212 /* Free the buffer allocated in START_BSS_REQ */
3213 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3214 psessionEntry->addIeParams.probeRespDataLen = 0;
3215 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003216
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003217 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3218 psessionEntry->addIeParams.assocRespDataLen = 0;
3219 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003220
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003221 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3222 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3223 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003224
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003225 /*
3226 * lim_del_bss is also called as part of coalescing,
3227 * when we send DEL BSS followed by Add Bss msg.
3228 */
3229 pMac->lim.gLimIbssCoalescingHappened = false;
3230 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003231 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3232 pStaDs =
3233 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3234 if (NULL == pStaDs)
3235 continue;
3236 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3237 if (eSIR_SUCCESS == status) {
3238 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3239 pStaDs->assocId, psessionEntry);
3240 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3241 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003242 pe_err("lim_del_sta failed with Status: %d", status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303243 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003244 }
3245 }
3246 /* send a delBss to HAL and wait for a response */
3247 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3248
3249 if (status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003250 pe_err("delBss failed for bss %d", psessionEntry->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003251 psessionEntry->limSmeState = prevState;
3252
3253 MTRACE(mac_trace
3254 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3255 psessionEntry->limSmeState));
3256
3257 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3258 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3259 smetransactionId);
3260 }
3261}
3262
3263/**
3264 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3265 * @pMac: Global MAC context
3266 * @pMsg: Message from SME
3267 *
3268 * Wrapper for the function __lim_handle_sme_stop_bss_request
3269 * This message will be defered until softmac come out of
3270 * scan mode. Message should be handled even if we have
3271 * detected radar in the current operating channel.
3272 *
3273 * Return: true - If we consumed the buffer
3274 * false - If have defered the message.
3275 */
3276
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003277static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3278 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279{
3280 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3281 /**
3282 * If message defered, buffer is not consumed yet.
3283 * So return false
3284 */
3285 return false;
3286 }
3287 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3288 return true;
3289} /*** end __lim_process_sme_stop_bss_req() ***/
3290
3291void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3292 uint32_t body, tpPESession psessionEntry)
3293{
3294
3295 (void)body;
3296 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3297 lim_ibss_delete(pMac, psessionEntry);
3298 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3299 lim_delete_pre_auth_list(pMac);
3300 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3301 psessionEntry->smeSessionId,
3302 psessionEntry->transactionId);
3303 return;
3304}
3305
3306/**
3307 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3308 *
3309 * @mac_ctx: pointer to mac context
3310 * @msg_type: message type
3311 * @msg_buf: pointer to the SME message buffer
3312 *
3313 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3314 * in BTAMP AP.
3315 *
3316 * Return: None
3317 */
3318
3319void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3320 uint32_t *msg_buf)
3321{
3322 tSirSmeAssocCnf assoc_cnf;
3323 tpDphHashNode sta_ds = NULL;
3324 tpPESession session_entry = NULL;
3325 uint8_t session_id;
3326 tpSirAssocReq assoc_req;
3327
3328 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003329 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330 goto end;
3331 }
3332
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303333 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003334 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003335 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003336 goto end;
3337 }
3338
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003339 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003340 &session_id);
3341 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003342 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003343 goto end;
3344 }
3345
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003346 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003347 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3348 (session_entry->limSmeState !=
3349 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003350 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003351 msg_type, session_entry->limSmeState,
3352 GET_LIM_SYSTEM_ROLE(session_entry));
3353 goto end;
3354 }
3355 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3356 &session_entry->dph.dphHashTable);
3357 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003358 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003359 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303360 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003361
3362 /*
3363 * send a DISASSOC_IND message to WSM to make sure
3364 * the state in WSM and LIM is the same
3365 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003366 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003367 eSIR_SME_STA_NOT_ASSOCIATED,
3368 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3369 session_entry->smeSessionId,
3370 session_entry->transactionId,
3371 session_entry);
3372 goto end;
3373 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303374 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003375 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303376 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003377 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003378 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303379 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003380 goto end;
3381 }
3382
3383 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3384 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3385 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3386 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3387 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003388 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3389 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003390 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303391 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003392 goto end;
3393 }
3394 /*
3395 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3396 * has been received
3397 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003398 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003399 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3400 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3401
3402 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3403 /*
3404 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3405 * when it had received Assoc Request frame. Now, PE just needs
3406 * to send association rsp frame to the requesting BTAMP-STA.
3407 */
3408 sta_ds->mlmStaContext.mlmState =
3409 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003410 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003411 sta_ds->assocId);
3412 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3413 sta_ds->assocId, sta_ds->staAddr,
3414 sta_ds->mlmStaContext.subType, sta_ds,
3415 session_entry);
3416 goto end;
3417 } else {
3418 /*
3419 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3420 * to be associated since the HAL sta entry is created for
3421 * denied STA we need to remove this HAL entry.
3422 * So to do that set updateContext to 1
3423 */
3424 if (!sta_ds->mlmStaContext.updateContext)
3425 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003426 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003427 assoc_cnf.statusCode, sta_ds->assocId);
3428 lim_reject_association(mac_ctx, sta_ds->staAddr,
3429 sta_ds->mlmStaContext.subType,
3430 true, sta_ds->mlmStaContext.authType,
3431 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003432 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003433 session_entry);
3434 }
3435end:
3436 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3437 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3438 assoc_req = (tpSirAssocReq)
3439 session_entry->parsedAssocReq[sta_ds->assocId];
3440 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303441 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003442 assoc_req->assocReqFrame = NULL;
3443 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303444 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003445 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3446 }
3447}
3448
3449static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3450{
3451 tpDphHashNode pStaDs;
3452 tSirMacAddr peerMac;
3453 tpSirAddtsReq pSirAddts;
3454 uint32_t timeout;
3455 tpPESession psessionEntry;
3456 uint8_t sessionId; /* PE sessionId */
3457 uint8_t smesessionId;
3458 uint16_t smetransactionId;
3459
3460 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003461 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462 return;
3463 }
3464
3465 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3466 &smetransactionId);
3467
3468 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3469
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003470 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3471 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003472 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003473 pe_err("Session Does not exist for given bssId");
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303474 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3475 NULL, pSirAddts->req.tspec,
3476 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003477 return;
3478 }
3479#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3480 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3481 0);
3482#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3483
3484 /* if sta
3485 * - verify assoc state
3486 * - send addts request to ap
3487 * - wait for addts response from ap
3488 * if ap, just ignore with error log
3489 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003490 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3491 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3492 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003493
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003494 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003495 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303496 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003497 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003498
3499 pStaDs =
3500 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3501 &psessionEntry->dph.dphHashTable);
3502
3503 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003504 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303505 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003506 }
3507
3508 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3509 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003510 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303511 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003512 }
3513
3514 pSirAddts->req.wsmTspecPresent = 0;
3515 pSirAddts->req.wmeTspecPresent = 0;
3516 pSirAddts->req.lleTspecPresent = 0;
3517
3518 if ((pStaDs->wsmEnabled) &&
3519 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3520 SIR_MAC_ACCESSPOLICY_EDCA))
3521 pSirAddts->req.wsmTspecPresent = 1;
3522 else if (pStaDs->wmeEnabled)
3523 pSirAddts->req.wmeTspecPresent = 1;
3524 else if (pStaDs->lleEnabled)
3525 pSirAddts->req.lleTspecPresent = 1;
3526 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003527 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303528 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003529 }
3530
3531 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3532 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003533 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003534 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303535 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003536 }
3537
3538 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003539 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003540 pMac->lim.gLimAddtsReq.req.dialogToken,
3541 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3542 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3543 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303544 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003545 }
3546
3547 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3548
3549 /* save the addts request */
3550 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303551 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003552 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3553
3554 /* ship out the message now */
3555 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3556 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303557 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003558 /* start a timer to wait for the response */
3559 if (pSirAddts->timeout)
3560 timeout = pSirAddts->timeout;
3561 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3562 eSIR_SUCCESS) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303563 pe_debug("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003564 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303565 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003566 }
3567
3568 timeout = SYS_MS_TO_TICKS(timeout);
3569 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3570 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003571 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303572 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003573 }
3574 pMac->lim.gLimAddtsRspTimerCount++;
3575 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3576 pMac->lim.gLimAddtsRspTimerCount) !=
3577 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003578 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303579 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003580 }
3581 MTRACE(mac_trace
3582 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3583 eLIM_ADDTS_RSP_TIMER));
3584
3585 /* add the sessionId to the timer object */
3586 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3587 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3588 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003589 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303590 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003591 }
3592 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303593
3594send_failure_addts_rsp:
3595 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3596 psessionEntry, pSirAddts->req.tspec,
3597 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598}
3599
3600static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3601{
3602 tSirMacAddr peerMacAddr;
3603 uint8_t ac;
3604 tSirMacTSInfo *pTsinfo;
3605 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3606 tpDphHashNode pStaDs = NULL;
3607 tpPESession psessionEntry;
3608 uint8_t sessionId;
3609 uint32_t status = eSIR_SUCCESS;
3610 uint8_t smesessionId;
3611 uint16_t smetransactionId;
3612
3613 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3614 &smetransactionId);
3615
3616 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003617 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618 &sessionId);
3619 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003620 pe_err("Session Does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003621 status = eSIR_FAILURE;
3622 goto end;
3623 }
3624#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3625 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3626 0);
3627#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3628
3629 if (eSIR_SUCCESS !=
3630 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003631 pe_err("lim_validate_delts_req failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003632 status = eSIR_FAILURE;
3633 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3634 smesessionId, smetransactionId);
3635 return;
3636 }
3637
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003638 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3639 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003640 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3641
3642 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3643 pDeltsReq->req.wmeTspecPresent,
3644 &pDeltsReq->req.tsinfo,
3645 &pDeltsReq->req.tspec, psessionEntry);
3646
3647 pTsinfo =
3648 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3649 tsinfo : &pDeltsReq->req.tsinfo;
3650
3651 /* We've successfully send DELTS frame to AP. Update the
3652 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3653 * is no longer trigger enabled or delivery enabled
3654 */
3655 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3656 pTsinfo, CLEAR_UAPSD_MASK);
3657
3658 /* We're deleting the TSPEC, so this particular AC is no longer
3659 * admitted. PE needs to downgrade the EDCA
3660 * parameters(for the AC for which TS is being deleted) to the
3661 * next best AC for which ACM is not enabled, and send the
3662 * updated values to HAL.
3663 */
3664 ac = upToAc(pTsinfo->traffic.userPrio);
3665
3666 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3667 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3668 ~(1 << ac);
3669 } else if (pTsinfo->traffic.direction ==
3670 SIR_MAC_DIRECTION_DNLINK) {
3671 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3672 ~(1 << ac);
3673 } else if (pTsinfo->traffic.direction ==
3674 SIR_MAC_DIRECTION_BIDIR) {
3675 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3676 ~(1 << ac);
3677 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3678 ~(1 << ac);
3679 }
3680
3681 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3682 psessionEntry);
3683
3684 pStaDs =
3685 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3686 &psessionEntry->dph.dphHashTable);
3687 if (pStaDs != NULL) {
3688 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3689 pStaDs->bssId);
3690 status = eSIR_SUCCESS;
3691 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003692 pe_err("Self entry missing in Hash Table");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003693 status = eSIR_FAILURE;
3694 }
3695#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003696 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003697#endif
3698
3699 /* send an sme response back */
3700end:
3701 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3702 smesessionId, smetransactionId);
3703}
3704
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303705void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003706{
3707 /* fetch the sessionEntry based on the sessionId */
3708 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003709
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003710 psessionEntry = pe_find_session_by_session_id(pMac,
3711 pMac->lim.limTimers.gLimAddtsRspTimer.
3712 sessionId);
3713 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003714 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003715 return;
3716 }
3717
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003718 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003719 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003720 GET_LIM_SYSTEM_ROLE(psessionEntry));
3721 pMac->lim.gLimAddtsSent = false;
3722 return;
3723 }
3724
3725 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003726 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003727 return;
3728 }
3729
3730 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003731 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003732 pMac->lim.gLimAddtsRspTimerCount);
3733 return;
3734 }
3735 /* this a real response timeout */
3736 pMac->lim.gLimAddtsSent = false;
3737 pMac->lim.gLimAddtsRspTimerCount++;
3738
3739 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3740 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3741 psessionEntry->smeSessionId,
3742 psessionEntry->transactionId);
3743}
3744
3745/**
3746 * __lim_process_sme_get_statistics_request()
3747 *
3748 ***FUNCTION:
3749 *
3750 *
3751 ***NOTE:
3752 *
3753 * @param pMac Pointer to Global MAC structure
3754 * @param *pMsgBuf A pointer to the SME message buffer
3755 * @return None
3756 */
3757static void
3758__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3759{
3760 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003761 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003762
3763 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3764
3765 msgQ.type = WMA_GET_STATISTICS_REQ;
3766
3767 msgQ.reserved = 0;
3768 msgQ.bodyptr = pMsgBuf;
3769 msgQ.bodyval = 0;
3770 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3771
3772 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303773 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003774 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003775 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003776 return;
3777 }
3778
3779 return;
3780}
3781
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003782#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003783/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003784 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003785 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003786 * @pMac: Pointer to Global MAC structure
3787 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003788 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003789 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003790 */
3791static void
3792__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3793{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003794 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003795
3796 msgQ.type = WMA_TSM_STATS_REQ;
3797 msgQ.reserved = 0;
3798 msgQ.bodyptr = pMsgBuf;
3799 msgQ.bodyval = 0;
3800 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3801
3802 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303803 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003804 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003805 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003806 return;
3807 }
3808}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003809#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003810
Naveen Rawat8029a402017-06-01 10:54:19 -07003811static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3812 struct update_config *msg)
3813{
3814 tpPESession pe_session;
3815
3816 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3817 if (msg == NULL) {
3818 pe_err("Buffer is Pointing to NULL");
3819 return;
3820 }
3821
3822 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3823 msg->sme_session_id);
3824 if (pe_session == NULL) {
3825 pe_warn("Session does not exist for given BSSID");
3826 return;
3827 }
3828
3829 switch (msg->capab) {
3830 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3831 pe_session->htConfig.ht_rx_ldpc = msg->value;
3832 break;
3833 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3834 pe_session->htConfig.ht_tx_stbc = msg->value;
3835 break;
3836 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3837 pe_session->htConfig.ht_rx_stbc = msg->value;
3838 break;
3839 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3840 pe_session->htConfig.ht_sgi20 = msg->value;
3841 break;
3842 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3843 pe_session->htConfig.ht_sgi40 = msg->value;
3844 break;
3845 }
3846
3847 if (LIM_IS_AP_ROLE(pe_session)) {
3848 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3849 lim_send_beacon_ind(mac_ctx, pe_session);
3850 }
3851}
3852
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003853void
3854lim_send_vdev_restart(tpAniSirGlobal pMac,
3855 tpPESession psessionEntry, uint8_t sessionId)
3856{
3857 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003858 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003859 tSirRetStatus retCode = eSIR_SUCCESS;
3860
3861 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003862 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003863 return;
3864 }
3865
3866 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303867 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003868 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003869 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003870 return;
3871 }
3872
3873 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3874 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003875 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003876
3877 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3878 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3879 msgQ.bodyval = 0;
3880
3881 retCode = wma_post_ctrl_msg(pMac, &msgQ);
3882 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003883 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303884 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003885 }
3886}
3887
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303888/**
3889 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3890 * @mac_ctx: Pointer to Global MAC structure
3891 * @msg_buf: Pointer to SME message buffer
3892 *
3893 * Return: None
3894 */
3895static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3896 uint32_t *msg_buf)
3897{
3898 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003899 struct scheduler_msg wma_msg = {0};
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303900 tSirRetStatus status;
3901 tSirRoamOffloadScanReq *req_buffer;
3902 uint16_t local_ie_len;
3903 uint8_t *local_ie_buf;
3904
3905 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3906 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3907 req_buffer->sessionId);
3908
3909 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3910 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003911 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303912 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303913 return;
3914 }
3915
3916 local_ie_len = req_buffer->assoc_ie.length;
3917 /* Update ext cap IE if present */
3918 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003919 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3920 local_ie_buf, &local_ie_len)) {
3921 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003922 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3923 req_buffer->assoc_ie.length = local_ie_len;
3924 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3925 local_ie_buf, local_ie_len);
3926 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303927 }
3928 qdf_mem_free(local_ie_buf);
3929
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303930 if (pe_session)
3931 lim_update_fils_rik(pe_session, req_buffer);
3932
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303933 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3934 wma_msg.bodyptr = req_buffer;
3935
3936 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
3937 if (eSIR_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003938 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303939 qdf_mem_free(req_buffer);
3940 }
3941}
3942
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303943/*
3944 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3945 * @mac_ctx: Pointer to global mac context
3946 * @session: Pointer to PE session
3947 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3948 * 1 - Disable broadcast SSID
3949 *
3950 * Return: None
3951 */
3952static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3953 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003954{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003955 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003956 session->ssidHidden, ssid_hidden);
3957
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003958 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303959 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003960 } else {
3961 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05303962 return;
3963 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003964
3965 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303966 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003967
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003968 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303969}
3970
3971/**
3972 * __lim_process_sme_session_update - process SME session update msg
3973 *
3974 * @mac_ctx: Pointer to global mac context
3975 * @msg_buf: Pointer to the received message buffer
3976 *
3977 * Return: None
3978 */
3979static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
3980 uint32_t *msg_buf)
3981{
3982 struct sir_update_session_param *msg;
3983 tpPESession session;
3984
3985 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003986 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303987 return;
3988 }
3989
3990 msg = (struct sir_update_session_param *) msg_buf;
3991
3992 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
3993 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003994 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303995 msg->session_id);
3996 return;
3997 }
3998
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003999 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304000 msg->param_type, msg->param_val);
4001 switch (msg->param_type) {
4002 case SIR_PARAM_SSID_HIDDEN:
4003 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
4004 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05304005 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
4006 session->ignore_assoc_disallowed = msg->param_val;
4007 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304008 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004009 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304010 break;
4011 }
4012}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004013
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004014/*
4015 Update the beacon Interval dynamically if beaconInterval is different in MCC
4016 */
4017static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4018{
4019 tpSirChangeBIParams pChangeBIParams;
4020 tpPESession psessionEntry;
4021 uint8_t sessionId = 0;
4022 tUpdateBeaconParams beaconParams;
4023
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004024 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004025
4026 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004027 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004028 return;
4029 }
4030
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304031 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004032 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4033
4034 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004035 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004036 &sessionId);
4037 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004038 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004039 return;
4040 }
4041
4042 /*Update sessionEntry Beacon Interval */
4043 if (psessionEntry->beaconParams.beaconInterval !=
4044 pChangeBIParams->beaconInterval) {
4045 psessionEntry->beaconParams.beaconInterval =
4046 pChangeBIParams->beaconInterval;
4047 }
4048
4049 /*Update sch beaconInterval */
4050 if (pMac->sch.schObject.gSchBeaconInterval !=
4051 pChangeBIParams->beaconInterval) {
4052 pMac->sch.schObject.gSchBeaconInterval =
4053 pChangeBIParams->beaconInterval;
4054
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004055 pe_debug("LIM send update BeaconInterval Indication: %d",
4056 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004057
4058 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4059 /* Update beacon */
4060 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4061
4062 beaconParams.bssIdx = psessionEntry->bssIdx;
4063 /* Set change in beacon Interval */
4064 beaconParams.beaconInterval =
4065 pChangeBIParams->beaconInterval;
4066 beaconParams.paramChangeBitmap =
4067 PARAM_BCN_INTERVAL_CHANGED;
4068 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4069 }
4070 }
4071
4072 return;
4073} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4074
4075#ifdef QCA_HT_2040_COEX
4076static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4077 uint32_t *pMsgBuf)
4078{
4079 tpSirSetHT2040Mode pSetHT2040Mode;
4080 tpPESession psessionEntry;
4081 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004082 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004083 tUpdateVHTOpMode *pHtOpMode = NULL;
4084 uint16_t staId = 0;
4085 tpDphHashNode pStaDs = NULL;
4086
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004087 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004088 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004089 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004090 return;
4091 }
4092
4093 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4094
4095 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004096 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004097 &sessionId);
4098 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004099 pe_debug("Session does not exist for given BSSID");
4100 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004101 return;
4102 }
4103
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004104 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004105 pSetHT2040Mode->cbMode);
4106 /*Update sessionEntry HT related fields */
4107 switch (pSetHT2040Mode->cbMode) {
4108 case PHY_SINGLE_CHANNEL_CENTERED:
4109 psessionEntry->htSecondaryChannelOffset =
4110 PHY_SINGLE_CHANNEL_CENTERED;
4111 psessionEntry->htRecommendedTxWidthSet = 0;
4112 if (pSetHT2040Mode->obssEnabled)
4113 psessionEntry->htSupportedChannelWidthSet
4114 = eHT_CHANNEL_WIDTH_40MHZ;
4115 else
4116 psessionEntry->htSupportedChannelWidthSet
4117 = eHT_CHANNEL_WIDTH_20MHZ;
4118 break;
4119 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4120 psessionEntry->htSecondaryChannelOffset =
4121 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4122 psessionEntry->htRecommendedTxWidthSet = 1;
4123 break;
4124 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4125 psessionEntry->htSecondaryChannelOffset =
4126 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4127 psessionEntry->htRecommendedTxWidthSet = 1;
4128 break;
4129 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004130 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004131 return;
4132 }
4133
4134 /* Update beacon */
4135 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4136 lim_send_beacon_ind(pMac, psessionEntry);
4137
4138 /* update OP Mode for each associated peer */
4139 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4140 pStaDs = dph_get_hash_entry(pMac, staId,
4141 &psessionEntry->dph.dphHashTable);
4142 if (NULL == pStaDs)
4143 continue;
4144
4145 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304146 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004147 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004148 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004149 return;
4150 }
4151 pHtOpMode->opMode =
4152 (psessionEntry->htSecondaryChannelOffset ==
4153 PHY_SINGLE_CHANNEL_CENTERED) ?
4154 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4155 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304156 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004157 sizeof(tSirMacAddr));
4158 pHtOpMode->smesessionId = sessionId;
4159
4160 msg.type = WMA_UPDATE_OP_MODE;
4161 msg.reserved = 0;
4162 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004163 if (!QDF_IS_STATUS_SUCCESS
4164 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
4165 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304166 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004167 return;
4168 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004169 pe_debug("Notifed FW about OP mode: %d for staId=%d",
4170 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004171
4172 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004173 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004174 }
4175
4176 return;
4177}
4178#endif
4179
4180/* -------------------------------------------------------------------- */
4181/**
4182 * __lim_process_report_message
4183 *
4184 * FUNCTION: Processes the next received Radio Resource Management message
4185 *
4186 * LOGIC:
4187 *
4188 * ASSUMPTIONS:
4189 *
4190 * NOTE:
4191 *
4192 * @param None
4193 * @return None
4194 */
4195
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004196static void __lim_process_report_message(tpAniSirGlobal pMac,
4197 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004198{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004199 switch (pMsg->type) {
4200 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4201 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4202 break;
4203 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004204 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004205 break;
4206 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004207 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004208 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004209}
4210
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004211/* -------------------------------------------------------------------- */
4212/**
4213 * lim_send_set_max_tx_power_req
4214 *
4215 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4216 *
4217 * LOGIC:
4218 *
4219 * ASSUMPTIONS:
4220 *
4221 * NOTE:
4222 *
4223 * @param txPower txPower to be set.
4224 * @param pSessionEntry session entry.
4225 * @return None
4226 */
4227tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004228lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004229 tpPESession pSessionEntry)
4230{
4231 tpMaxTxPowerParams pMaxTxParams = NULL;
4232 tSirRetStatus retCode = eSIR_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004233 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004234
4235 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004236 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004237 return eSIR_FAILURE;
4238 }
4239
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304240 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004241 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004242 pe_err("Unable to allocate memory for pMaxTxParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004243 return eSIR_MEM_ALLOC_FAILED;
4244
4245 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004246 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304247 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304248 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304249 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004250 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304251 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004252
4253 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4254 msgQ.bodyptr = pMaxTxParams;
4255 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004256 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004257 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4258 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4259 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004260 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304261 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004262 }
4263 return retCode;
4264}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004265
4266/**
4267 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4268 *
4269 * @mac_ctx: Pointer to Global MAC structure
4270 * @msg_buf: pointer to the SME message buffer
4271 *
4272 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4273 * from SME. It Register this information within PE.
4274 *
4275 * Return: None
4276 */
4277static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4278 uint32_t *msg_buf)
4279{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304280 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004281 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4282 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4283 struct mgmt_frm_reg_info *next = NULL;
4284 bool match = false;
4285
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004286 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004287 sme_req->registerFrame, sme_req->frameType,
4288 sme_req->matchLen);
4289 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304290 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304291 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4292 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304293 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004294
4295 while (lim_mgmt_regn != NULL) {
4296 if (lim_mgmt_regn->frameType != sme_req->frameType)
4297 goto skip_match;
4298 if (sme_req->matchLen) {
4299 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304300 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004301 sme_req->matchData,
4302 lim_mgmt_regn->matchLen))) {
4303 /* found match! */
4304 match = true;
4305 break;
4306 }
4307 } else {
4308 /* found match! */
4309 match = true;
4310 break;
4311 }
4312skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304313 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304314 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004315 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304316 (qdf_list_node_t *)lim_mgmt_regn,
4317 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304318 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004319 lim_mgmt_regn = next;
4320 next = NULL;
4321 }
4322 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304323 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004324 if (QDF_STATUS_SUCCESS ==
4325 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004326 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004327 (qdf_list_node_t *)lim_mgmt_regn))
4328 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304329 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004330 }
4331
4332 if (sme_req->registerFrame) {
4333 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304334 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004335 sme_req->matchLen);
4336 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004337 lim_mgmt_regn->frameType = sme_req->frameType;
4338 lim_mgmt_regn->matchLen = sme_req->matchLen;
4339 lim_mgmt_regn->sessionId = sme_req->sessionId;
4340 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304341 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004342 sme_req->matchData,
4343 sme_req->matchLen);
4344 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304345 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004346 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304347 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004348 gLimMgmtFrameRegistratinQueue,
4349 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304350 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004351 &mac_ctx->lim.lim_frame_register_lock);
4352 }
4353 }
4354 return;
4355}
4356
4357static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4358{
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004359 pe_debug("Dereg msgType %d", pMac->lim.gDeferMsgTypeForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004360 pMac->lim.gDeferMsgTypeForNOA = 0;
4361 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4362 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304363 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004364 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4365 }
4366}
4367
4368/**
4369 * lim_process_regd_defd_sme_req_after_noa_start()
4370 *
4371 * mac_ctx: Pointer to Global MAC structure
4372 *
4373 * This function is called to process deferred sme req message
4374 * after noa start.
4375 *
4376 * Return: None
4377 */
4378void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4379{
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004380 pe_debug("Process defd sme req %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004381 mac_ctx->lim.gDeferMsgTypeForNOA);
4382
4383 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4384 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004385 pe_warn("start rcvd from FW when no sme deferred msg pending. Do nothing");
4386 pe_warn("It may happen when NOA start ind and timeout happen at the same time");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004387 return;
4388 }
4389 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4390 case eWNI_SME_SCAN_REQ:
4391 __lim_process_sme_scan_req(mac_ctx,
4392 mac_ctx->lim.gpDefdSmeMsgForNOA);
4393 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004394 case eWNI_SME_JOIN_REQ:
4395 __lim_process_sme_join_req(mac_ctx,
4396 mac_ctx->lim.gpDefdSmeMsgForNOA);
4397 break;
4398 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004399 pe_err("Unknown deferred msg type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004400 mac_ctx->lim.gDeferMsgTypeForNOA);
4401 break;
4402 }
4403 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4404}
4405
4406static void
4407__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4408{
4409 tpSirResetAPCapsChange pResetCapsChange;
4410 tpPESession psessionEntry;
4411 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004412
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004413 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004414 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004415 return;
4416 }
4417
4418 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4419 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004420 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4421 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004422 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004423 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004424 return;
4425 }
4426
4427 psessionEntry->limSentCapsChangeNtf = false;
4428 return;
4429}
4430
4431/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304432 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4433 * indication callback in PE.
4434 * @mac_ptr: Mac pointer
4435 * @msg_buf: Msg pointer containing the callback
4436 *
4437 * This function is used save the Management frame
4438 * indication callback in PE.
4439 *
4440 * Return: None
4441 */
4442static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4443 uint32_t *msg_buf)
4444{
4445 struct sir_sme_mgmt_frame_cb_req *sme_req =
4446 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4447
4448 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004449 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304450 return;
4451 }
4452 if (sme_req->callback)
4453 mac_ctx->mgmt_frame_ind_cb =
4454 (sir_mgmt_frame_ind_callback)sme_req->callback;
4455 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004456 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304457}
4458
4459/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304460 *__lim_process_send_disassoc_frame: function processes disassoc frame
4461 * @mac_ctx: pointer to mac context
4462 * @msg_buf: message buffer
4463 *
4464 * function processes disassoc request received from SME
4465 *
4466 * return: none
4467 */
4468static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4469 uint32_t *msg_buf)
4470{
4471 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4472 tSirRetStatus status;
4473 tpPESession session_entry = NULL;
4474 uint8_t sme_session_id;
4475 uint16_t sme_trans_id;
4476
4477 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004478 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304479 return;
4480 }
4481
4482 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4483 &sme_trans_id);
4484
4485 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4486 &sme_send_disassoc_frame_req,
4487 (uint8_t *)msg_buf);
4488
4489 if ((eSIR_FAILURE == status) ||
4490 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4491 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004492 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304493 return;
4494 }
4495
4496 session_entry = pe_find_session_by_sme_session_id(
4497 mac_ctx, sme_session_id);
4498 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004499 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304500 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4501 return;
4502 }
4503
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004504 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 +05304505 sme_send_disassoc_frame_req.msg_type,
4506 sme_send_disassoc_frame_req.length,
4507 sme_send_disassoc_frame_req.session_id,
4508 sme_send_disassoc_frame_req.trans_id,
4509 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4510 sme_send_disassoc_frame_req.reason,
4511 sme_send_disassoc_frame_req.wait_for_ack);
4512
4513 lim_send_disassoc_mgmt_frame(mac_ctx,
4514 sme_send_disassoc_frame_req.reason,
4515 sme_send_disassoc_frame_req.peer_mac,
4516 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4517}
4518
4519/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004520 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4521 * @mac_ctx: Pointer to Global MAC structure
4522 * @pdev_id: pdev id to set the IE.
4523 * @nss: Nss values to prepare the HT IE.
4524 *
4525 * Prepares the HT IE with self capabilities for different
4526 * Nss values and sends the set HT IE req to FW.
4527 *
4528 * Return: None
4529 */
4530static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4531 uint8_t nss)
4532{
4533 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004534 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004535 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004536 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004537 tHtCaps *p_ht_cap;
4538 int i;
4539
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004540 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004541 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4542 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004543 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004544 return;
4545 }
4546 ie_params->nss = i;
4547 ie_params->pdev_id = pdev_id;
4548 ie_params->ie_type = DOT11_HT_IE;
4549 /* 2 for IE len and EID */
4550 ie_params->ie_len = 2 + sizeof(tHtCaps);
4551 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4552 if (NULL == ie_params->ie_ptr) {
4553 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004554 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004555 return;
4556 }
4557 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4558 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4559 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4560 ie_params->ie_len);
4561
4562 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004563 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4564 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004565 if (NULL == p_ie) {
4566 qdf_mem_free(ie_params->ie_ptr);
4567 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004568 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004569 return;
4570 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004571 p_ht_cap = (tHtCaps *)&p_ie[2];
4572 p_ht_cap->supportedMCSSet[1] = 0;
4573 p_ht_cap->txSTBC = 0;
4574 }
4575
4576 msg.type = WMA_SET_PDEV_IE_REQ;
4577 msg.bodyptr = ie_params;
4578 msg.bodyval = 0;
4579
4580 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4581 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004582 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004583 qdf_mem_free(ie_params->ie_ptr);
4584 qdf_mem_free(ie_params);
4585 return;
4586 }
4587 }
4588}
4589
4590/**
4591 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4592 * @mac_ctx: Pointer to Global MAC structure
4593 * @pdev_id: pdev id to set the IE.
4594 * @nss: Nss values to prepare the VHT IE.
4595 *
4596 * Prepares the VHT IE with self capabilities for different
4597 * Nss values and sends the set VHT IE req to FW.
4598 *
4599 * Return: None
4600 */
4601static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4602 uint8_t nss)
4603{
4604 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004605 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004606 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004607 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004608 tSirMacVHTCapabilityInfo *vht_cap;
4609 int i;
4610 tSirVhtMcsInfo *vht_mcs;
4611
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004612 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004613 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4614 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004615 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004616 return;
4617 }
4618 ie_params->nss = i;
4619 ie_params->pdev_id = pdev_id;
4620 ie_params->ie_type = DOT11_VHT_IE;
4621 /* 2 for IE len and EID */
4622 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4623 sizeof(tSirVhtMcsInfo);
4624 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4625 if (NULL == ie_params->ie_ptr) {
4626 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004627 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004628 return;
4629 }
4630 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4631 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4632 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4633 ie_params->ie_len);
4634
4635 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004636 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4637 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004638 if (NULL == p_ie) {
4639 qdf_mem_free(ie_params->ie_ptr);
4640 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004641 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004642 return;
4643 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004644 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4645 vht_cap->txSTBC = 0;
4646 vht_mcs =
4647 (tSirVhtMcsInfo *)&p_ie[2 +
4648 sizeof(tSirMacVHTCapabilityInfo)];
4649 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4650 vht_mcs->rxHighest =
4651 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4652 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4653 vht_mcs->txHighest =
4654 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4655 }
4656 msg.type = WMA_SET_PDEV_IE_REQ;
4657 msg.bodyptr = ie_params;
4658 msg.bodyval = 0;
4659
4660 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4661 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004662 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004663 qdf_mem_free(ie_params->ie_ptr);
4664 qdf_mem_free(ie_params);
4665 return;
4666 }
4667 }
4668}
4669
4670/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004671 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4672 * @mac_ctx: Pointer to Global MAC structure
4673 * @msg_buf: Pointer to the SME message buffer
4674 *
4675 * This function is called by limProcessMessageQueue(). This function sets the
4676 * VDEV IEs to the FW.
4677 *
4678 * Return: None
4679 */
4680static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4681 uint32_t *msg_buf)
4682{
4683 struct sir_set_vdev_ies_per_band *p_msg =
4684 (struct sir_set_vdev_ies_per_band *)msg_buf;
4685
4686 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004687 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004688 return;
4689 }
4690
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004691 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004692 p_msg->vdev_id);
4693 /* intentionally using NULL here so that self capabilty are sent */
4694 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4695 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004696 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004697}
4698
4699/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004700 * lim_process_set_pdev_IEs() - process the set pdev IE req
4701 * @mac_ctx: Pointer to Global MAC structure
4702 * @msg_buf: Pointer to the SME message buffer
4703 *
4704 * This function is called by limProcessMessageQueue(). This
4705 * function sets the PDEV IEs to the FW.
4706 *
4707 * Return: None
4708 */
4709static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4710{
4711 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4712
4713 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4714
4715 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004716 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004717 return;
4718 }
4719
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004720 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004721 ht_vht_cfg->nss);
4722 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4723
4724 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4725 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4726 ht_vht_cfg->nss);
4727}
4728
4729/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304730 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4731 *
4732 * access policy
4733 * @mac_ctx: pointer to mac context
4734 * @msg: message buffer
4735 *
4736 * function processes vendor IE and access policy from SME and updates PE
4737 *
4738 * session entry
4739 *
4740 * return: none
4741*/
4742static void lim_process_sme_update_access_policy_vendor_ie(
4743 tpAniSirGlobal mac_ctx,
4744 uint32_t *msg)
4745{
4746 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4747 struct sPESession *pe_session_entry;
4748 uint8_t num_bytes;
4749
4750 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004751 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304752 return;
4753 }
4754 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4755 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4756 update_vendor_ie->sme_session_id);
4757
4758 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004759 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304760 update_vendor_ie->sme_session_id);
4761 return;
4762 }
4763 if (pe_session_entry->access_policy_vendor_ie)
4764 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4765
4766 num_bytes = update_vendor_ie->ie[1] + 2;
4767 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4768
4769 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004770 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304771 return;
4772 }
4773 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4774 &update_vendor_ie->ie[0], num_bytes);
4775
4776 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4777}
4778
4779/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004780 * lim_process_sme_req_messages()
4781 *
4782 ***FUNCTION:
4783 * This function is called by limProcessMessageQueue(). This
4784 * function processes SME request messages from HDD or upper layer
4785 * application.
4786 *
4787 ***LOGIC:
4788 *
4789 ***ASSUMPTIONS:
4790 *
4791 ***NOTE:
4792 *
4793 * @param pMac Pointer to Global MAC structure
4794 * @param msgType Indicates the SME message type
4795 * @param *pMsgBuf A pointer to the SME message buffer
4796 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4797 * false - if pMsgBuf is not to be freed.
4798 */
4799
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004800bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4801 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004802{
4803 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
4804 uint32_t *pMsgBuf = pMsg->bodyptr;
4805 tpSirSmeScanReq pScanReq;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004806
4807 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004808 lim_msg_str(pMsg->type), pMsg->type,
4809 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4810 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004811
4812 pScanReq = (tpSirSmeScanReq) pMsgBuf;
4813 /* If no insert NOA required then execute the code below */
4814
4815 switch (pMsg->type) {
4816 case eWNI_SME_SYS_READY_IND:
4817 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4818 break;
4819
4820 case eWNI_SME_START_BSS_REQ:
4821 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4822 break;
4823
4824 case eWNI_SME_SCAN_REQ:
4825 __lim_process_sme_scan_req(pMac, pMsgBuf);
4826 break;
4827
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004828 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4829 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4830 break;
4831 case eWNI_SME_JOIN_REQ:
4832 __lim_process_sme_join_req(pMac, pMsgBuf);
4833 break;
4834
4835 case eWNI_SME_REASSOC_REQ:
4836 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4837 break;
4838
4839 case eWNI_SME_DISASSOC_REQ:
4840 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4841 break;
4842
4843 case eWNI_SME_DISASSOC_CNF:
4844 case eWNI_SME_DEAUTH_CNF:
4845 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4846 break;
4847
4848 case eWNI_SME_DEAUTH_REQ:
4849 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4850 break;
4851
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304852 case eWNI_SME_SEND_DISASSOC_FRAME:
4853 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4854 break;
4855
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004856 case eWNI_SME_SETCONTEXT_REQ:
4857 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4858 break;
4859
4860 case eWNI_SME_STOP_BSS_REQ:
4861 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4862 break;
4863
4864 case eWNI_SME_ASSOC_CNF:
4865 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004866 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004867 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4868 pMsgBuf);
4869 break;
4870
4871 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004872 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004873 __lim_process_sme_addts_req(pMac, pMsgBuf);
4874 break;
4875
4876 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004877 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004878 __lim_process_sme_delts_req(pMac, pMsgBuf);
4879 break;
4880
4881 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004882 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004883 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4884 break;
4885
4886 case eWNI_SME_GET_STATISTICS_REQ:
4887 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4888 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4889 bufConsumed = false;
4890 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004891#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004892 case eWNI_SME_GET_TSM_STATS_REQ:
4893 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4894 bufConsumed = false;
4895 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004896#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004897 case eWNI_SME_GET_ASSOC_STAS_REQ:
4898 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4899 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304900 case eWNI_SME_SESSION_UPDATE_PARAM:
4901 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004902 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304903 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4904 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4905 bufConsumed = false;
4906 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004907 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4908 /* Update the beaconInterval */
4909 __lim_process_sme_change_bi(pMac, pMsgBuf);
4910 break;
4911
4912#ifdef QCA_HT_2040_COEX
4913 case eWNI_SME_SET_HT_2040_MODE:
4914 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4915 break;
4916#endif
4917
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004918 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4919 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4920 __lim_process_report_message(pMac, pMsg);
4921 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004922
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004923 case eWNI_SME_FT_PRE_AUTH_REQ:
4924 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4925 break;
4926 case eWNI_SME_FT_UPDATE_KEY:
4927 lim_process_ft_update_key(pMac, pMsgBuf);
4928 break;
4929
4930 case eWNI_SME_FT_AGGR_QOS_REQ:
4931 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4932 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004933
4934 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4935 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4936 break;
4937#ifdef FEATURE_WLAN_TDLS
4938 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4939 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4940 break;
4941 case eWNI_SME_TDLS_ADD_STA_REQ:
4942 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4943 break;
4944 case eWNI_SME_TDLS_DEL_STA_REQ:
4945 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4946 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004947#endif
4948 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4949 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4950 break;
4951
4952 case eWNI_SME_CHANNEL_CHANGE_REQ:
4953 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4954 break;
4955
4956 case eWNI_SME_START_BEACON_REQ:
4957 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4958 break;
4959
4960 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4961 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4962 break;
4963
4964 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4965 lim_process_update_add_ies(pMac, pMsgBuf);
4966 break;
4967
4968 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4969 lim_process_modify_add_ies(pMac, pMsgBuf);
4970 break;
4971 case eWNI_SME_SET_HW_MODE_REQ:
4972 lim_process_set_hw_mode(pMac, pMsgBuf);
4973 break;
4974 case eWNI_SME_NSS_UPDATE_REQ:
4975 lim_process_nss_update_request(pMac, pMsgBuf);
4976 break;
4977 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4978 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4979 break;
4980 case eWNI_SME_SET_IE_REQ:
4981 lim_process_set_ie_req(pMac, pMsgBuf);
4982 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304983 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4984 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
4985 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304986 case eWNI_SME_EXT_CHANGE_CHANNEL:
4987 lim_process_ext_change_channel(pMac, pMsgBuf);
4988 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08004989 case eWNI_SME_SET_ANTENNA_MODE_REQ:
4990 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
4991 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004992 case eWNI_SME_PDEV_SET_HT_VHT_IE:
4993 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07004994 break;
4995 case eWNI_SME_SET_VDEV_IES_PER_BAND:
4996 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
4997 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07004998 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07004999 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005000 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005001 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005002 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305003 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5004 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5005 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07005006 case eWNI_SME_UPDATE_CONFIG:
5007 lim_process_sme_update_config(pMac,
5008 (struct update_config *)pMsgBuf);
5009 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005010 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305011 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005012 pMsg->bodyptr = NULL;
5013 break;
5014 } /* switch (msgType) */
5015
5016 return bufConsumed;
5017} /*** end lim_process_sme_req_messages() ***/
5018
5019/**
5020 * lim_process_sme_start_beacon_req()
5021 *
5022 ***FUNCTION:
5023 * This function is called by limProcessMessageQueue(). This
5024 * function processes SME request messages from HDD or upper layer
5025 * application.
5026 *
5027 ***LOGIC:
5028 *
5029 ***ASSUMPTIONS:
5030 *
5031 ***NOTE:
5032 *
5033 * @param pMac Pointer to Global MAC structure
5034 * @param msgType Indicates the SME message type
5035 * @param *pMsgBuf A pointer to the SME message buffer
5036 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5037 * false - if pMsgBuf is not to be freed.
5038 */
5039static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5040{
5041 tpSirStartBeaconIndication pBeaconStartInd;
5042 tpPESession psessionEntry;
5043 uint8_t sessionId; /* PE sessionID */
5044
5045 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005046 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005047 return;
5048 }
5049
5050 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5051 psessionEntry = pe_find_session_by_bssid(pMac,
5052 pBeaconStartInd->bssid,
5053 &sessionId);
5054 if (psessionEntry == NULL) {
5055 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005056 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005057 return;
5058 }
5059
5060 if (pBeaconStartInd->beaconStartStatus == true) {
5061 /*
5062 * Currently this Indication comes from SAP
5063 * to start Beacon Tx on a DFS channel
5064 * since beaconing has to be done on DFS
5065 * channel only after CAC WAIT is completed.
5066 * On a DFS Channel LIM does not start beacon
5067 * Tx right after the WMA_ADD_BSS_RSP.
5068 */
5069 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05305070 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005071 FL("Start Beacon with ssid %s Ch %d"),
5072 psessionEntry->ssId.ssId,
5073 psessionEntry->currentOperChannel);
5074 lim_send_beacon_ind(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08005075 lim_enable_obss_detection_config(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005076 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005077 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005078 return;
5079 }
5080}
5081
5082/**
5083 * lim_process_sme_channel_change_request() - process sme ch change req
5084 *
5085 * @mac_ctx: Pointer to Global MAC structure
5086 * @msg_buf: pointer to the SME message buffer
5087 *
5088 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5089 *
5090 * Return: None
5091 */
5092static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5093 uint32_t *msg_buf)
5094{
5095 tpSirChanChangeRequest ch_change_req;
5096 tpPESession session_entry;
5097 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005098 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005099 uint32_t val = 0;
5100
5101 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005102 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005103 return;
5104 }
5105 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5106
5107 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5108 ch_change_req->targetChannel);
5109
5110 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5111 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005112 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005113 return;
5114 }
5115
5116 session_entry = pe_find_session_by_bssid(mac_ctx,
5117 ch_change_req->bssid, &session_id);
5118 if (session_entry == NULL) {
5119 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005120 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005121 return;
5122 }
5123
5124 if (session_entry->currentOperChannel ==
5125 ch_change_req->targetChannel) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005126 pe_err("target CH is same as current CH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005127 return;
5128 }
5129
5130 if (LIM_IS_AP_ROLE(session_entry))
5131 session_entry->channelChangeReasonCode =
5132 LIM_SWITCH_CHANNEL_SAP_DFS;
5133 else
5134 session_entry->channelChangeReasonCode =
5135 LIM_SWITCH_CHANNEL_OPERATION;
5136
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005137 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005138 session_entry->currentOperChannel,
5139 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005140 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005141
5142 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005143 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005144 session_entry->ch_center_freq_seg0 =
5145 ch_change_req->center_freq_seg_0;
5146 session_entry->ch_center_freq_seg1 =
5147 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005148 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005149 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005150 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005151 session_entry->htRecommendedTxWidthSet =
5152 session_entry->htSupportedChannelWidthSet;
5153 session_entry->currentOperChannel =
5154 ch_change_req->targetChannel;
5155 session_entry->limRFBand =
5156 lim_get_rf_band(session_entry->currentOperChannel);
5157 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08005158 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005159 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005160 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5161 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005162 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005163 }
5164
5165 session_entry->lim11hEnable = val;
5166 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305167 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005168 &ch_change_req->operational_rateset,
5169 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305170 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005171 &ch_change_req->extended_rateset,
5172 sizeof(session_entry->extRateSet));
5173 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5174 session_entry->ch_center_freq_seg0,
5175 session_entry->ch_center_freq_seg1,
5176 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07005177 max_tx_pwr, session_entry->peSessionId,
5178 ch_change_req->cac_duration_ms,
5179 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005180}
5181
5182/******************************************************************************
5183* lim_start_bss_update_add_ie_buffer()
5184*
5185***FUNCTION:
5186* This function checks the src buffer and its length and then malloc for
5187* dst buffer update the same
5188*
5189***LOGIC:
5190*
5191***ASSUMPTIONS:
5192*
5193***NOTE:
5194*
5195* @param pMac Pointer to Global MAC structure
5196* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5197* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5198* @param *pSrcData_buff A pointer of uint8_t src buffer
5199* @param srcDataLen src buffer length
5200******************************************************************************/
5201
5202static void
5203lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5204 uint8_t **pDstData_buff,
5205 uint16_t *pDstDataLen,
5206 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5207{
5208
5209 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5210 *pDstDataLen = srcDataLen;
5211
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305212 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005213
5214 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005215 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005216 return;
5217 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305218 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005219 } else {
5220 *pDstData_buff = NULL;
5221 *pDstDataLen = 0;
5222 }
5223}
5224
5225/******************************************************************************
5226* lim_update_add_ie_buffer()
5227*
5228***FUNCTION:
5229* This function checks the src buffer and length if src buffer length more
5230* than dst buffer length then free the dst buffer and malloc for the new src
5231* length, and update the dst buffer and length. But if dst buffer is bigger
5232* than src buffer length then it just update the dst buffer and length
5233*
5234***LOGIC:
5235*
5236***ASSUMPTIONS:
5237*
5238***NOTE:
5239*
5240* @param pMac Pointer to Global MAC structure
5241* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5242* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5243* @param *pSrcData_buff A pointer of uint8_t src buffer
5244* @param srcDataLen src buffer length
5245******************************************************************************/
5246
5247static void
5248lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5249 uint8_t **pDstData_buff,
5250 uint16_t *pDstDataLen,
5251 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5252{
5253
5254 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005255 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005256 return;
5257 }
5258
5259 if (srcDataLen > *pDstDataLen) {
5260 *pDstDataLen = srcDataLen;
5261 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305262 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005263 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305264 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005265
5266 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005267 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005268 *pDstDataLen = 0;
5269 return;
5270 }
5271 }
5272
5273 /* copy the content of buffer into dst buffer
5274 */
5275 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305276 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005277
5278}
5279
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005280/**
5281 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5282 * @pMac : Pointer to Global MAC structure
5283 * @pDstData_buff : A pointer to pointer of dst buffer
5284 * @pDstDataLen : A pointer to pointer of dst buffer length
5285 * @pModifyIE : A pointer to tSirModifyIE
5286 *
5287 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5288 *
5289 * Return:
5290 * True or false depending upon whether IE is updated or not
5291 */
5292static bool
5293lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5294 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5295{
Hong Shi1553d692016-09-28 12:16:19 +08005296 int32_t oui_length;
5297 uint8_t *ibss_ie = NULL;
5298 uint8_t *vendor_ie;
5299#define MAC_VENDOR_OUI "\x00\x16\x32"
5300#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005301
5302 ibss_ie = pModifyIE->pIEBuffer;
5303 oui_length = pModifyIE->oui_length;
5304
5305 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005306 pe_err("Invalid set IBSS vendor IE command length %d",
5307 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005308 return false;
5309 }
5310
Hong Shi1553d692016-09-28 12:16:19 +08005311 /*
5312 * Why replace only beacon OUI data here:
5313 * 1. other ie (such as wpa) shall not be overwritten here.
5314 * 2. per spec, beacon oui ie might be set twice and original one
5315 * shall be updated.
5316 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005317 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005318 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5319 if (vendor_ie) {
5320 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5321 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5322 pModifyIE->ieBufferlength);
5323 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005324 uint16_t new_length;
5325 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005326
Naveen Rawat668dee32017-09-29 14:39:40 -07005327 /*
5328 * check for uint16 overflow before using sum of two numbers as
5329 * length of size to malloc
5330 */
5331 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5332 pe_err("U16 overflow due to %d + %d",
5333 pModifyIE->ieBufferlength, *pDstDataLen);
5334 return false;
5335 }
5336
5337 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5338 new_ptr = qdf_mem_malloc(new_length);
Hong Shi1553d692016-09-28 12:16:19 +08005339 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005340 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005341 return false;
5342 }
5343 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5344 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5345 pModifyIE->ieBufferlength);
5346 qdf_mem_free(*pDstData_buff);
5347 *pDstDataLen = new_length;
5348 *pDstData_buff = new_ptr;
5349 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005350 return true;
5351}
5352
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005353/*
5354* lim_process_modify_add_ies() - process modify additional IE req.
5355*
5356* @mac_ctx: Pointer to Global MAC structure
5357* @msg_buf: pointer to the SME message buffer
5358*
5359* This function update the PE buffers for additional IEs.
5360*
5361* Return: None
5362*/
5363static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5364 uint32_t *msg_buf)
5365{
5366 tpSirModifyIEsInd modify_add_ies;
5367 tpPESession session_entry;
5368 uint8_t session_id;
5369 bool ret = false;
5370 tSirAddIeParams *add_ie_params;
5371
5372 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005373 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005374 return;
5375 }
5376
5377 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5378 /* Incoming message has smeSession, use BSSID to find PE session */
5379 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005380 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005381
5382 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005383 pe_err("Session not found for given bssid"
5384 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005385 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005386 goto end;
5387 }
5388 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5389 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5390 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005391 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005392 modify_add_ies->modifyIE.pIEBuffer,
5393 modify_add_ies->modifyIE.ieBufferlength,
5394 modify_add_ies->modifyIE.ieID,
5395 modify_add_ies->modifyIE.ieIDLen,
5396 modify_add_ies->updateType);
5397 goto end;
5398 }
5399 add_ie_params = &session_entry->addIeParams;
5400 switch (modify_add_ies->updateType) {
5401 case eUPDATE_IE_PROBE_RESP:
5402 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005403 if (LIM_IS_IBSS_ROLE(session_entry)) {
5404 lim_update_ibss_prop_add_ies(mac_ctx,
5405 &add_ie_params->probeRespData_buff,
5406 &add_ie_params->probeRespDataLen,
5407 &modify_add_ies->modifyIE);
5408 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005409 break;
5410 case eUPDATE_IE_ASSOC_RESP:
5411 /* assoc resp IE */
5412 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305413 QDF_TRACE(QDF_MODULE_ID_PE,
5414 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005415 "assoc resp add ie not present %d"),
5416 add_ie_params->assocRespDataLen);
5417 }
5418 /* search through the buffer and modify the IE */
5419 break;
5420 case eUPDATE_IE_PROBE_BCN:
5421 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005422 if (LIM_IS_IBSS_ROLE(session_entry)) {
5423 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5424 &add_ie_params->probeRespBCNData_buff,
5425 &add_ie_params->probeRespBCNDataLen,
5426 &modify_add_ies->modifyIE);
5427 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005428 if (ret == true && modify_add_ies->modifyIE.notify) {
5429 lim_handle_param_update(mac_ctx,
5430 modify_add_ies->updateType);
5431 }
5432 break;
5433 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005434 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005435 modify_add_ies->updateType);
5436 break;
5437 }
5438end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305439 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005440 modify_add_ies->modifyIE.pIEBuffer = NULL;
5441}
5442
5443/*
5444* lim_process_update_add_ies() - process additional IE update req
5445*
5446* @mac_ctx: Pointer to Global MAC structure
5447* @msg_buf: pointer to the SME message buffer
5448*
5449* This function update the PE buffers for additional IEs.
5450*
5451* Return: None
5452*/
5453static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5454 uint32_t *msg_buf)
5455{
5456 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5457 uint8_t session_id;
5458 tpPESession session_entry;
5459 tSirAddIeParams *addn_ie;
5460 uint16_t new_length = 0;
5461 uint8_t *new_ptr = NULL;
5462 tSirUpdateIE *update_ie;
5463
5464 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005465 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005466 return;
5467 }
5468 update_ie = &update_add_ies->updateIE;
5469 /* incoming message has smeSession, use BSSID to find PE session */
5470 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005471 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005472
5473 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005474 pe_err("Session not found for given bssid"
5475 MAC_ADDRESS_STR,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005476 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005477 goto end;
5478 }
5479 addn_ie = &session_entry->addIeParams;
5480 /* if len is 0, upper layer requested freeing of buffer */
5481 if (0 == update_ie->ieBufferlength) {
5482 switch (update_add_ies->updateType) {
5483 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305484 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005485 addn_ie->probeRespData_buff = NULL;
5486 addn_ie->probeRespDataLen = 0;
5487 break;
5488 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305489 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005490 addn_ie->assocRespData_buff = NULL;
5491 addn_ie->assocRespDataLen = 0;
5492 break;
5493 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305494 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005495 addn_ie->probeRespBCNData_buff = NULL;
5496 addn_ie->probeRespBCNDataLen = 0;
5497
5498 if (update_ie->notify)
5499 lim_handle_param_update(mac_ctx,
5500 update_add_ies->updateType);
5501 break;
5502 default:
5503 break;
5504 }
5505 return;
5506 }
5507 switch (update_add_ies->updateType) {
5508 case eUPDATE_IE_PROBE_RESP:
5509 if (update_ie->append) {
5510 /*
5511 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005512 * with combined length.
5513 * Multiple back to back append commands
5514 * can lead to a huge length.So, check
5515 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005516 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005517 if (addn_ie->probeRespDataLen >
5518 (USHRT_MAX - update_ie->ieBufferlength)) {
5519 pe_err("IE Length overflow, curr:%d, new:%d",
5520 addn_ie->probeRespDataLen,
5521 update_ie->ieBufferlength);
5522 goto end;
5523 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005524 new_length = update_ie->ieBufferlength +
5525 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305526 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005527 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005528 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005529 goto end;
5530 }
5531 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305532 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005533 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305534 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005535 update_ie->pAdditionIEBuffer,
5536 update_ie->ieBufferlength);
5537 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305538 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005539 /* adjust length accordingly */
5540 addn_ie->probeRespDataLen = new_length;
5541 /* save refernece of local buffer in PE session */
5542 addn_ie->probeRespData_buff = new_ptr;
5543 goto end;
5544 }
5545 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5546 &addn_ie->probeRespDataLen,
5547 update_ie->pAdditionIEBuffer,
5548 update_ie->ieBufferlength);
5549 break;
5550 case eUPDATE_IE_ASSOC_RESP:
5551 /* assoc resp IE */
5552 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5553 &addn_ie->assocRespDataLen,
5554 update_ie->pAdditionIEBuffer,
5555 update_ie->ieBufferlength);
5556 break;
5557 case eUPDATE_IE_PROBE_BCN:
5558 /* probe resp Bcn IE */
5559 lim_update_add_ie_buffer(mac_ctx,
5560 &addn_ie->probeRespBCNData_buff,
5561 &addn_ie->probeRespBCNDataLen,
5562 update_ie->pAdditionIEBuffer,
5563 update_ie->ieBufferlength);
5564 if (update_ie->notify)
5565 lim_handle_param_update(mac_ctx,
5566 update_add_ies->updateType);
5567 break;
5568 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005569 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005570 break;
5571 }
5572end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305573 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005574 update_ie->pAdditionIEBuffer = NULL;
5575}
5576
5577/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305578 * send_extended_chan_switch_action_frame()- function to send ECSA
5579 * action frame for each sta connected to SAP/GO and AP in case of
5580 * STA .
5581 * @mac_ctx: pointer to global mac structure
5582 * @new_channel: new channel to switch to.
5583 * @ch_bandwidth: BW of channel to calculate op_class
5584 * @session_entry: pe session
5585 *
5586 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5587 *
5588 * Return: void
5589 */
5590
5591static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5592 uint16_t new_channel, uint8_t ch_bandwidth,
5593 tpPESession session_entry)
5594{
5595 uint16_t op_class;
5596 uint8_t switch_mode = 0, i;
5597 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005598 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305599
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005600 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305601 mac_ctx->scan.countryCodeCurrent,
5602 new_channel,
5603 ch_bandwidth);
5604
5605 if (LIM_IS_AP_ROLE(session_entry) &&
5606 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005607 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305608
gaoleze2920bd2017-03-21 17:38:42 +08005609 switch_count = session_entry->gLimChannelSwitch.switchCount;
5610
Abhishek Singh518323d2015-10-19 17:42:01 +05305611 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005612 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305613 psta =
5614 session_entry->dph.dphHashTable.pDphNodeArray + i;
5615 if (psta && psta->added)
5616 lim_send_extended_chan_switch_action_frame(
5617 mac_ctx,
5618 psta->staAddr,
5619 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005620 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305621 }
5622 } else if (LIM_IS_STA_ROLE(session_entry)) {
5623 lim_send_extended_chan_switch_action_frame(mac_ctx,
5624 session_entry->bssId,
5625 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005626 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305627 }
5628
5629}
5630
gaolez76d2a162017-03-21 19:23:58 +08005631void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5632 uint16_t new_channel,
5633 uint8_t ch_bandwidth,
5634 tpPESession session_entry)
5635{
5636 uint16_t op_class;
5637 uint8_t switch_mode = 0, i;
5638 uint8_t switch_count;
5639 tpDphHashNode psta;
5640 tpDphHashNode dph_node_array_ptr;
5641
5642 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5643
5644 op_class = wlan_reg_dmn_get_opclass_from_channel(
5645 mac_ctx->scan.countryCodeCurrent,
5646 new_channel, ch_bandwidth);
5647
5648 if (LIM_IS_AP_ROLE(session_entry) &&
5649 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5650 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5651
5652 switch_count = session_entry->gLimChannelSwitch.switchCount;
5653
5654 if (LIM_IS_AP_ROLE(session_entry)) {
5655 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5656 psta = dph_node_array_ptr + i;
5657 if (!(psta && psta->added))
5658 continue;
5659 if (session_entry->lim_non_ecsa_cap_num == 0)
5660 lim_send_extended_chan_switch_action_frame
5661 (mac_ctx, psta->staAddr, switch_mode,
5662 op_class, new_channel, switch_count,
5663 session_entry);
5664 else
5665 lim_send_channel_switch_mgmt_frame
5666 (mac_ctx, psta->staAddr, switch_mode,
5667 new_channel, switch_count,
5668 session_entry);
5669 }
5670 } else if (LIM_IS_STA_ROLE(session_entry)) {
5671 lim_send_extended_chan_switch_action_frame
5672 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5673 new_channel, switch_count, session_entry);
5674 }
5675}
5676
5677/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005678 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5679 *
5680 * @mac_ctx: Pointer to Global MAC structure
5681 * @msg_buf: pointer to the SME message buffer
5682 *
5683 * This function processes SME request messages from HDD or upper layer
5684 * application.
5685 *
5686 * Return: None
5687 */
5688static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5689 uint32_t *msg_buf)
5690{
5691 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5692 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005693 uint8_t session_id;
5694 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005695 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005696
5697 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005698 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005699 return;
5700 }
5701
5702 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5703 session_entry = pe_find_session_by_bssid(mac_ctx,
5704 dfs_csa_ie_req->bssid, &session_id);
5705 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005706 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005707 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5708 return;
5709 }
5710
5711 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005712 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005713 GET_LIM_SYSTEM_ROLE(session_entry));
5714 return;
5715 }
5716
5717 /* target channel */
5718 session_entry->gLimChannelSwitch.primaryChannel =
5719 dfs_csa_ie_req->targetChannel;
5720
5721 /* Channel switch announcement needs to be included in beacon */
5722 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005723 session_entry->gLimChannelSwitch.switchCount =
5724 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005725 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005726 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305727 session_entry->gLimChannelSwitch.sec_ch_offset =
5728 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005729 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005730 session_entry->gLimChannelSwitch.switchMode =
5731 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005732
5733 /*
5734 * Validate if SAP is operating HT or VHT mode and set the Channel
5735 * Switch Wrapper element with the Wide Band Switch subelement.
5736 */
5737 if (true != session_entry->vhtCapability)
5738 goto skip_vht;
5739
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005740 /* Now encode the Wider Ch BW element depending on the ch width */
5741 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005742 switch (dfs_csa_ie_req->ch_params.ch_width) {
5743 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005744 /*
5745 * Wide channel BW sublement in channel wrapper element is not
5746 * required in case of 20 Mhz operation. Currently It is set
5747 * only set in case of 40/80 Mhz Operation.
5748 */
5749 session_entry->dfsIncludeChanWrapperIe = false;
5750 wider_bw_ch_switch->newChanWidth =
5751 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5752 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005753 case CH_WIDTH_40MHZ:
5754 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005755 wider_bw_ch_switch->newChanWidth =
5756 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5757 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005758 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005759 session_entry->dfsIncludeChanWrapperIe = true;
5760 wider_bw_ch_switch->newChanWidth =
5761 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5762 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005763 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005764 session_entry->dfsIncludeChanWrapperIe = true;
5765 wider_bw_ch_switch->newChanWidth =
5766 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5767 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005768 case CH_WIDTH_80P80MHZ:
5769 session_entry->dfsIncludeChanWrapperIe = true;
5770 wider_bw_ch_switch->newChanWidth =
5771 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005772 /*
5773 * This is not applicable for 20/40/80 Mhz.
5774 * Only used when we support 80+80 Mhz operation.
5775 * In case of 80+80 Mhz, this parameter indicates
5776 * center channel frequency index of 80 Mhz channel of
5777 * frequency segment 1.
5778 */
5779 wider_bw_ch_switch->newCenterChanFreq1 =
5780 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005781 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005782 default:
5783 session_entry->dfsIncludeChanWrapperIe = false;
5784 /*
5785 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5786 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5787 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005788 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005789 break;
5790 }
5791 /* Fetch the center channel based on the channel width */
5792 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005793 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005794skip_vht:
5795 /* Send CSA IE request from here */
5796 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5797 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005798 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005799 return;
5800 }
5801
5802 /*
5803 * First beacon update request is sent here, the remaining updates are
5804 * done when the FW responds back after sending the first beacon after
5805 * the template update
5806 */
5807 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305808
5809 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5810 ch_offset = BW80;
5811 else
5812 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5813
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005814 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305815 session_entry->gLimChannelSwitch.switchCount,
5816 session_entry->gLimChannelSwitch.primaryChannel,
5817 session_entry->gLimChannelSwitch.ch_width,
5818 session_entry->dfsIncludeChanWrapperIe,
5819 ch_offset);
5820
gaolez76d2a162017-03-21 19:23:58 +08005821 /* Send ECSA/CSA Action frame after updating the beacon */
5822 if (CHAN_HOP_ALL_BANDS_ENABLE)
5823 lim_send_chan_switch_action_frame(mac_ctx,
5824 session_entry->gLimChannelSwitch.primaryChannel,
5825 ch_offset, session_entry);
5826 else
5827 send_extended_chan_switch_action_frame(mac_ctx,
5828 session_entry->gLimChannelSwitch.primaryChannel,
5829 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005830 session_entry->gLimChannelSwitch.switchCount--;
5831}
5832
5833/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305834 * lim_process_ext_change_channel()- function to send ECSA
5835 * action frame for STA/CLI .
5836 * @mac_ctx: pointer to global mac structure
5837 * @msg: params from sme for new channel.
5838 *
5839 * This function is called to send ECSA frame for STA/CLI.
5840 *
5841 * Return: void
5842 */
5843
5844static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5845 uint32_t *msg)
5846{
5847 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5848 (struct sir_sme_ext_cng_chan_req *) msg;
5849 tpPESession session_entry = NULL;
5850
5851 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005852 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305853 return;
5854 }
5855 session_entry =
5856 pe_find_session_by_sme_session_id(mac_ctx,
5857 ext_chng_channel->session_id);
5858 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005859 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305860 ext_chng_channel->session_id);
5861 return;
5862 }
5863 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005864 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305865 return;
5866 }
5867 send_extended_chan_switch_action_frame(mac_ctx,
5868 ext_chng_channel->new_channel,
5869 0, session_entry);
5870}
5871
5872/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005873 * lim_process_nss_update_request() - process sme nss update req
5874 *
5875 * @mac_ctx: Pointer to Global MAC structure
5876 * @msg_buf: pointer to the SME message buffer
5877 *
5878 * This function processes SME request messages from HDD or upper layer
5879 * application.
5880 *
5881 * Return: None
5882 */
5883static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5884 uint32_t *msg_buf)
5885{
5886 struct sir_nss_update_request *nss_update_req_ptr;
5887 tpPESession session_entry = NULL;
5888
5889 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005890 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005891 return;
5892 }
5893
5894 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305895 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005896 nss_update_req_ptr->vdev_id);
5897 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005898 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005899 nss_update_req_ptr->vdev_id);
5900 return;
5901 }
5902
5903 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005904 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005905 GET_LIM_SYSTEM_ROLE(session_entry));
5906 return;
5907 }
5908
5909 /* populate nss field in the beacon */
5910 session_entry->gLimOperatingMode.present = 1;
5911 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05305912 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
5913
5914 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
5915 (session_entry->ch_width > CH_WIDTH_80MHZ))
5916 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
5917
5918 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
5919
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005920 /* Send nss update request from here */
5921 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5922 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005923 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005924 return;
5925 }
5926
5927 lim_send_beacon_ind(mac_ctx, session_entry);
5928}
5929
5930/**
5931 * lim_process_set_ie_req() - process sme set IE request
5932 *
5933 * @mac_ctx: Pointer to Global MAC structure
5934 * @msg_buf: pointer to the SME message buffer
5935 *
5936 * This function processes SME request messages from HDD or upper layer
5937 * application.
5938 *
5939 * Return: None
5940 */
5941static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5942{
5943 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305944 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005945
5946 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005947 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005948 return;
5949 }
5950
5951 msg = (struct send_extcap_ie *)msg_buf;
5952 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305953 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005954 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005955
5956}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07005957
5958#ifdef WLAN_FEATURE_11AX_BSS_COLOR
5959void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5960{
5961 struct sir_set_he_bss_color *bss_color;
5962 tpPESession session_entry = NULL;
5963 tUpdateBeaconParams beacon_params;
5964
5965 if (!msg_buf) {
5966 pe_err("Buffer is Pointing to NULL");
5967 return;
5968 }
5969
5970 bss_color = (struct sir_set_he_bss_color *)msg_buf;
5971 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5972 bss_color->session_id);
5973 if (!session_entry) {
5974 pe_err("Session not found for given session_id %d",
5975 bss_color->session_id);
5976 return;
5977 }
5978
5979 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5980 pe_err("Invalid SystemRole %d",
5981 GET_LIM_SYSTEM_ROLE(session_entry));
5982 return;
5983 }
5984
5985 if (bss_color->bss_color == session_entry->he_op.bss_color) {
5986 pe_err("No change in BSS color, current BSS color %d",
5987 bss_color->bss_color);
5988 return;
5989 }
5990 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
5991 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
5992 session_entry->he_op.bss_col_disabled = 1;
5993 session_entry->he_bss_color_change.countdown =
5994 BSS_COLOR_SWITCH_COUNTDOWN;
5995 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
5996 session_entry->he_op.bss_color =
5997 session_entry->he_bss_color_change.new_color;
Naveen Rawatdf221b72017-11-15 11:32:31 -08005998 beacon_params.bss_color = session_entry->he_op.bss_color;
5999 beacon_params.bss_color_disabled =
6000 session_entry->he_op.bss_col_disabled;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006001 session_entry->bss_color_changing = 1;
6002
6003 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6004 eSIR_SUCCESS) {
6005 pe_err("Unable to set op mode IE in beacon");
6006 return;
6007 }
6008
6009 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
6010}
6011#endif