blob: 10bcdd0c553ab58233637c816d6fa6ed75a49405 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302 * Copyright (c) 2012-2017 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 ||
1088 SIR_BAND_5_GHZ == 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
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001729 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1730 lim_update_session_he_capable(mac_ctx, session);
1731 lim_copy_join_req_he_cap(session, sme_join_req);
1732 }
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001733
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001734 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301735 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001736 session->vht_config.su_beam_formee,
1737 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001738 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001739 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001740 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001741 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301742 session->force_24ghz_in_ht20 =
1743 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001744 /* cbMode is already merged value of peer and self -
1745 * done by csr in csr_get_cb_mode_from_ies */
1746 session->htSupportedChannelWidthSet =
1747 (sme_join_req->cbMode) ? 1 : 0;
1748 session->htRecommendedTxWidthSet =
1749 session->htSupportedChannelWidthSet;
1750 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1751
1752 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1753 session->ch_center_freq_seg0 =
1754 session->currentOperChannel - 2;
1755 session->ch_width = CH_WIDTH_40MHZ;
1756 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1757 sme_join_req->cbMode) {
1758 session->ch_center_freq_seg0 =
1759 session->currentOperChannel + 2;
1760 session->ch_width = CH_WIDTH_40MHZ;
1761 } else {
1762 session->ch_center_freq_seg0 = 0;
1763 session->ch_width = CH_WIDTH_20MHZ;
1764 }
1765
1766 /* Record if management frames need to be protected */
1767#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001768 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001769 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001770 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001771 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001772#endif
1773
1774#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001775 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001776#endif
1777
1778 /* Copy the SSID from smejoinreq to session entry */
1779 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301780 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001781 session->ssId.length);
1782
1783 /*
1784 * Determin 11r or ESE connection based on input from SME
1785 * which inturn is dependent on the profile the user wants
1786 * to connect to, So input is coming from supplicant
1787 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001788 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001789#ifdef FEATURE_WLAN_ESE
1790 session->isESEconnection = sme_join_req->isESEconnection;
1791#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001792 session->isFastTransitionEnabled =
1793 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001794
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001795 session->isFastRoamIniFeatureEnabled =
1796 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001797 session->txLdpcIniFeatureEnabled =
1798 sme_join_req->txLdpcIniFeatureEnabled;
1799
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301800 lim_update_fils_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001801 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1802 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001803 } else {
1804 /*
1805 * Throw an error and return and make
1806 * sure to delete the session.
1807 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001808 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809 session->bssType);
1810 ret_code = eSIR_SME_INVALID_PARAMETERS;
1811 goto end;
1812 }
1813
1814 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301815 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001816 &sme_join_req->addIEScan, sizeof(tSirAddie));
1817
1818 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301819 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001820 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1821
1822 val = sizeof(tLimMlmJoinReq) +
1823 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301824 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001825 if (NULL == mlm_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001826 pe_err("AllocateMemory failed for mlmJoinReq");
Nitesh Shah0102cac2016-07-13 14:38:30 +05301827 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1828 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001830
1831 /* PE SessionId is stored as a part of JoinReq */
1832 mlm_join_req->sessionId = session->peSessionId;
1833
1834 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1835 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1836 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001837 pe_err("couldn't retrieve JoinFailureTimer value"
1838 " setting to default value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001839 mlm_join_req->joinFailureTimeout =
1840 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1841 }
1842
1843 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301844 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001845 (void *)&sme_join_req->operationalRateSet,
1846 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301847 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001848 (void *)&sme_join_req->extendedRateSet,
1849 sizeof(tSirMacRateSet));
1850 /*
1851 * this may not be needed anymore now, as rateSet is now
1852 * included in the session entry and MLM has session context.
1853 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301854 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001855 (void *)&session->rateSet,
1856 sizeof(tSirMacRateSet));
1857
1858 session->encryptType = sme_join_req->UCEncryptionType;
1859
1860 mlm_join_req->bssDescription.length =
1861 session->pLimJoinReq->bssDescription.length;
1862
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301863 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001864 (uint8_t *)
1865 &session->pLimJoinReq->bssDescription.bssId,
1866 session->pLimJoinReq->bssDescription.length + 2);
1867
1868 session->limCurrentBssCaps =
1869 session->pLimJoinReq->bssDescription.capabilityInfo;
1870
1871 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1872 session->currentOperChannel);
1873 local_power_constraint = reg_max;
1874
1875 lim_extract_ap_capability(mac_ctx,
1876 (uint8_t *)
1877 session->pLimJoinReq->bssDescription.ieFields,
1878 lim_get_ielen_from_bss_description(
1879 &session->pLimJoinReq->bssDescription),
1880 &session->limCurrentBssQosCaps,
1881 &session->limCurrentBssPropCap,
1882 &session->gLimCurrentBssUapsd,
1883 &local_power_constraint, session);
1884
Krunal Soni53993f72016-07-08 18:20:03 -07001885 /*
1886 * Once the AP capabilities are available then set the
1887 * beam forming capabilities accordingly.
1888 */
1889 if (session->nss == 1) {
1890 session->vht_config.su_beam_former = 0;
1891 session->vht_config.tx_stbc = 0;
1892 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301893 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001894 }
1895
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001896 session->maxTxPower = lim_get_max_tx_power(reg_max,
1897 local_power_constraint,
1898 mac_ctx->roam.configParam.nTxPowerCap);
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301899
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001900 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301901 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001902
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301903 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1904 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1905 pe_debug("Update MaxTxPower in join Req to %d",
1906 sme_join_req->powerCap.maxTxPower);
1907 }
1908
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001909 if (session->gLimCurrentBssUapsd) {
1910 session->gUapsdPerAcBitmask =
1911 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001912 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001913 session->gUapsdPerAcBitmask);
1914
1915 /* resetting the dynamic uapsd mask */
1916 session->gUapsdPerAcDeliveryEnableMask = 0;
1917 session->gUapsdPerAcTriggerEnableMask = 0;
1918 }
1919
1920 session->limRFBand =
1921 lim_get_rf_band(session->currentOperChannel);
1922
1923 /* Initialize 11h Enable Flag */
1924 if (SIR_BAND_5_GHZ == session->limRFBand) {
1925 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1926 &val) != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001927 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001928 session->lim11hEnable =
1929 WNI_CFG_11H_ENABLED_STADEF;
1930 } else {
1931 session->lim11hEnable = val;
1932 }
1933 } else {
1934 session->lim11hEnable = 0;
1935 }
1936
1937 /*
1938 * To care of the scenario when STA transitions from
1939 * IBSS to Infrastructure mode.
1940 */
1941 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1942
1943 session->limPrevSmeState = session->limSmeState;
1944 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1945 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1946 session->peSessionId,
1947 session->limSmeState));
1948
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001949 /* Indicate whether spectrum management is enabled */
1950 session->spectrumMgtEnabled =
1951 sme_join_req->spectrumMgtIndicator;
1952
1953 /* Enable the spectrum management if this is a DFS channel */
1954 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001955 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001956 session->currentOperChannel))
1957 session->spectrumMgtEnabled = true;
1958
1959 session->isOSENConnection = sme_join_req->isOSENConnection;
1960
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001961 /* Issue LIM_MLM_JOIN_REQ to MLM */
1962 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1963 (uint32_t *) mlm_join_req);
1964 return;
1965
1966 } else {
1967 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001968 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001969 mac_ctx->lim.gLimSmeState);
1970 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1971 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1972 session = NULL;
1973 goto end;
1974 }
1975
1976end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301977 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1978 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001979
1980 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301981 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001982 sme_join_req = NULL;
1983 if (NULL != session)
1984 session->pLimJoinReq = NULL;
1985 }
1986 if (ret_code != eSIR_SME_SUCCESS) {
1987 if (NULL != session) {
1988 pe_delete_session(mac_ctx, session);
1989 session = NULL;
1990 }
1991 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001992 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001993 sme_session_id, ret_code);
1994 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1995 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1996 sme_transaction_id);
1997}
1998
Amar Singhala297bfa2015-10-15 15:07:29 -07001999uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000 uint8_t iniTxPower)
2001{
2002 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302003 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002004
Anurag Chouhan6d760662016-02-20 16:05:43 +05302005 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002006 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2007 maxTxPower = txPower;
2008 else if (txPower < MIN_TX_PWR_CAP)
2009 maxTxPower = MIN_TX_PWR_CAP;
2010 else
2011 maxTxPower = MAX_TX_PWR_CAP;
2012
2013 return maxTxPower;
2014}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002015
2016/**
2017 * __lim_process_sme_reassoc_req() - process reassoc req
2018 *
2019 * @mac_ctx: Pointer to Global MAC structure
2020 * @msg_buf: pointer to the SME message buffer
2021 *
2022 * This function is called to process SME_REASSOC_REQ message
2023 * from HDD or upper layer application.
2024 *
2025 * Return: None
2026 */
2027
2028static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2029 uint32_t *msg_buf)
2030{
2031 uint16_t caps;
2032 uint32_t val;
2033 tpSirSmeJoinReq reassoc_req = NULL;
2034 tLimMlmReassocReq *mlm_reassoc_req;
2035 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2036 tpPESession session_entry = NULL;
2037 uint8_t session_id;
2038 uint8_t sme_session_id;
2039 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002040 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002041 uint32_t tele_bcn_en = 0;
2042 uint16_t size;
2043
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002044 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302045 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002046 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002047 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002048
2049 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2050 goto end;
2051 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302052 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002053
2054 if (!lim_is_sme_join_req_valid(mac_ctx,
2055 (tpSirSmeJoinReq)reassoc_req)) {
2056 /*
2057 * Received invalid eWNI_SME_REASSOC_REQ
2058 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002059 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002060
2061 ret_code = eSIR_SME_INVALID_PARAMETERS;
2062 goto end;
2063 }
2064
2065 session_entry = pe_find_session_by_bssid(mac_ctx,
2066 reassoc_req->bssDescription.bssId,
2067 &session_id);
2068 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002069 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002070 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2071 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002072 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002073 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
2074 &sme_session_id, &transaction_id);
2075 session_entry =
2076 pe_find_session_by_sme_session_id(mac_ctx,
2077 sme_session_id);
2078 if (session_entry != NULL)
2079 lim_handle_sme_join_result(mac_ctx,
2080 eSIR_SME_INVALID_PARAMETERS,
2081 eSIR_MAC_UNSPEC_FAILURE_STATUS,
2082 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002083 goto end;
2084 }
2085#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2086 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2087 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2088#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2089 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2090
2091 /* Store the reassoc handle in the session Table */
2092 session_entry->pLimReAssocReq = reassoc_req;
2093
2094 session_entry->dot11mode = reassoc_req->dot11mode;
2095 session_entry->vhtCapability =
2096 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002097
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302098 if (session_entry->vhtCapability) {
2099 if (session_entry->pePersona == QDF_STA_MODE) {
2100 session_entry->vht_config.su_beam_formee =
2101 reassoc_req->vht_config.su_beam_formee;
2102 } else {
2103 reassoc_req->vht_config.su_beam_formee = 0;
2104 }
2105 session_entry->enableVhtpAid =
2106 reassoc_req->enableVhtpAid;
2107 session_entry->enableVhtGid =
2108 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002109 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302110 }
2111
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002112 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302113 session_entry->vhtCapability,
2114 session_entry->vht_config.su_beam_formee,
2115 session_entry->vht_config.su_beam_former);
2116
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002117 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2118 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002119 session_entry->send_smps_action =
2120 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002121 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002122 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002123 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002124 session_entry->send_smps_action,
2125 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002126 /*
2127 * Reassociate request is expected
2128 * in link established state only.
2129 */
2130
2131 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002132 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2133 /*
2134 * May be from 11r FT pre-auth. So lets check it
2135 * before we bail out
2136 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002137 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002138 session_entry->peSessionId);
2139
2140 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302141 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002142 session_entry->limReAssocbssId,
2143 6)) {
2144 lim_print_mac_addr(mac_ctx,
2145 reassoc_req->bssDescription.
2146 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002147 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002148 ret_code = eSIR_SME_INVALID_PARAMETERS;
2149 goto end;
2150 }
2151
2152 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2153 session_entry);
2154 return;
2155 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002156 /*
2157 * Should not have received eWNI_SME_REASSOC_REQ
2158 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002159 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002160 session_entry->limSmeState);
2161 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2162
2163 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2164 goto end;
2165 }
2166
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302167 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002168 session_entry->pLimReAssocReq->bssDescription.bssId,
2169 sizeof(tSirMacAddr));
2170
2171 session_entry->limReassocChannelId =
2172 session_entry->pLimReAssocReq->bssDescription.channelId;
2173
2174 session_entry->reAssocHtSupportedChannelWidthSet =
2175 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2176 session_entry->reAssocHtRecommendedTxWidthSet =
2177 session_entry->reAssocHtSupportedChannelWidthSet;
2178 session_entry->reAssocHtSecondaryChannelOffset =
2179 session_entry->pLimReAssocReq->cbMode;
2180
2181 session_entry->limReassocBssCaps =
2182 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2183 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2184 session_entry->currentOperChannel);
2185 local_pwr_constraint = reg_max;
2186
2187 lim_extract_ap_capability(mac_ctx,
2188 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2189 lim_get_ielen_from_bss_description(
2190 &session_entry->pLimReAssocReq->bssDescription),
2191 &session_entry->limReassocBssQosCaps,
2192 &session_entry->limReassocBssPropCap,
2193 &session_entry->gLimCurrentBssUapsd,
2194 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302195 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002196 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302197 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002198 /* Copy the SSID from session entry to local variable */
2199 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302200 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002201 reassoc_req->ssId.ssId,
2202 session_entry->limReassocSSID.length);
2203 if (session_entry->gLimCurrentBssUapsd) {
2204 session_entry->gUapsdPerAcBitmask =
2205 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002206 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002207 session_entry->gUapsdPerAcBitmask);
2208 }
2209
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302210 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002211 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002212 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002213
2214 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2215 goto end;
2216 }
2217
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302218 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002219 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2220
2221 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2222 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002223 eSIR_SUCCESS)
2224 pe_err("could not retrieve ReassocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002225
2226 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002227 eSIR_SUCCESS)
2228 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302229
2230 lim_update_caps_info_for_bss(mac_ctx, &caps,
2231 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002232 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302233
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002234 mlm_reassoc_req->capabilityInfo = caps;
2235
2236 /* Update PE session_id */
2237 mlm_reassoc_req->sessionId = session_id;
2238
2239 /*
2240 * If telescopic beaconing is enabled, set listen interval to
2241 * WNI_CFG_TELE_BCN_MAX_LI
2242 */
2243 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2244 &tele_bcn_en) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002245 pe_err("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002246
2247 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2248
2249 if (tele_bcn_en) {
2250 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2251 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002252 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002253 } else {
2254 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &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 }
2258
2259 mlm_reassoc_req->listenInterval = (uint16_t) val;
2260
2261 /* Indicate whether spectrum management is enabled */
2262 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2263
2264 /* Enable the spectrum management if this is a DFS channel */
2265 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002266 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002267 session_entry->currentOperChannel))
2268 session_entry->spectrumMgtEnabled = true;
2269
2270 session_entry->limPrevSmeState = session_entry->limSmeState;
2271 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2272
2273 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2274 session_entry->peSessionId,
2275 session_entry->limSmeState));
2276
2277 lim_post_mlm_message(mac_ctx,
2278 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2279 return;
2280end:
2281 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302282 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002283 if (session_entry)
2284 session_entry->pLimReAssocReq = NULL;
2285 }
2286
2287 if (session_entry) {
2288 /*
2289 * error occurred after we determined the session so extract
2290 * session and transaction info from there
2291 */
2292 sme_session_id = session_entry->smeSessionId;
2293 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002294 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002295 /*
2296 * error occurred before or during the time we determined
2297 * the session so extract the session and transaction info
2298 * from the message
2299 */
2300 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2301 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002302 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002303 /*
2304 * Send Reassoc failure response to host
2305 * (note session_entry may be NULL, but that's OK)
2306 */
2307 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2308 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2309 session_entry, sme_session_id,
2310 transaction_id);
2311}
2312
2313bool send_disassoc_frame = 1;
2314/**
2315 * __lim_process_sme_disassoc_req()
2316 *
2317 ***FUNCTION:
2318 * This function is called to process SME_DISASSOC_REQ message
2319 * from HDD or upper layer application.
2320 *
2321 ***LOGIC:
2322 *
2323 ***ASSUMPTIONS:
2324 *
2325 ***NOTE:
2326 *
2327 * @param pMac Pointer to Global MAC structure
2328 * @param *pMsgBuf A pointer to the SME message buffer
2329 * @return None
2330 */
2331
2332static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2333{
2334 uint16_t disassocTrigger, reasonCode;
2335 tLimMlmDisassocReq *pMlmDisassocReq;
2336 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2337 tSirSmeDisassocReq smeDisassocReq;
2338 tpPESession psessionEntry = NULL;
2339 uint8_t sessionId;
2340 uint8_t smesessionId;
2341 uint16_t smetransactionId;
2342
2343 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002344 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002345 return;
2346 }
2347
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302348 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002349 smesessionId = smeDisassocReq.sessionId;
2350 smetransactionId = smeDisassocReq.transactionId;
2351 if (!lim_is_sme_disassoc_req_valid(pMac,
2352 &smeDisassocReq,
2353 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002354 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002355 if (pMac->lim.gLimRspReqd) {
2356 pMac->lim.gLimRspReqd = false;
2357
2358 retCode = eSIR_SME_INVALID_PARAMETERS;
2359 disassocTrigger = eLIM_HOST_DISASSOC;
2360 goto sendDisassoc;
2361 }
2362
2363 return;
2364 }
2365
2366 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002367 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002368 &sessionId);
2369 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002370 pe_err("session does not exist for given bssId "
2371 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002372 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002373 retCode = eSIR_SME_INVALID_PARAMETERS;
2374 disassocTrigger = eLIM_HOST_DISASSOC;
2375 goto sendDisassoc;
2376 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002377 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2378 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002379 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2380 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002381 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002382
2383#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2384 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2385 0, smeDisassocReq.reasonCode);
2386#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2387
2388 /* Update SME session Id and SME transaction ID */
2389
2390 psessionEntry->smeSessionId = smesessionId;
2391 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002392 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002393 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002394
2395 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2396 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002397 switch (psessionEntry->limSmeState) {
2398 case eLIM_SME_ASSOCIATED_STATE:
2399 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002400 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002401 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002402 psessionEntry->limPrevSmeState =
2403 psessionEntry->limSmeState;
2404 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002405 /* Delete all TDLS peers connected before leaving BSS */
2406 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002407 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2408 psessionEntry->peSessionId,
2409 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002410 break;
2411
2412 case eLIM_SME_WT_DEAUTH_STATE:
2413 /* PE shall still process the DISASSOC_REQ and proceed with
2414 * link tear down even if it had already sent a DEAUTH_IND to
2415 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2416 * its been set when PE entered WT_DEAUTH_STATE.
2417 */
2418 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2419 MTRACE(mac_trace
2420 (pMac, TRACE_CODE_SME_STATE,
2421 psessionEntry->peSessionId,
2422 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002423 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002424 break;
2425
2426 case eLIM_SME_WT_DISASSOC_STATE:
2427 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2428 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2429 * PE can continue processing DISASSOC_REQ and send the response instead
2430 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2431 * for disassoc frame.
2432 *
2433 * It will send a disassoc, which is ok. However, we can use the global flag
2434 * sendDisassoc to not send disassoc frame.
2435 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002436 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002437 break;
2438
2439 case eLIM_SME_JOIN_FAILURE_STATE: {
2440 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002441 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002442 if (pMac->lim.gLimRspReqd) {
2443 retCode = eSIR_SME_SUCCESS;
2444 disassocTrigger = eLIM_HOST_DISASSOC;
2445 goto sendDisassoc;
2446 }
2447 }
2448 break;
2449 default:
2450 /**
2451 * STA is not currently associated.
2452 * Log error and send response to host
2453 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002454 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002455 psessionEntry->limSmeState);
2456 lim_print_sme_state(pMac, LOGE,
2457 psessionEntry->limSmeState);
2458
2459 if (pMac->lim.gLimRspReqd) {
2460 if (psessionEntry->limSmeState !=
2461 eLIM_SME_WT_ASSOC_STATE)
2462 pMac->lim.gLimRspReqd = false;
2463
2464 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2465 disassocTrigger = eLIM_HOST_DISASSOC;
2466 goto sendDisassoc;
2467 }
2468
2469 return;
2470 }
2471
2472 break;
2473
2474 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002475 /* Fall through */
2476 break;
2477
2478 case eLIM_STA_IN_IBSS_ROLE:
2479 default:
2480 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002481 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002482 GET_LIM_SYSTEM_ROLE(psessionEntry));
2483
2484 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2485 disassocTrigger = eLIM_HOST_DISASSOC;
2486 goto sendDisassoc;
2487 } /* end switch (pMac->lim.gLimSystemRole) */
2488
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302489 disassocTrigger = eLIM_HOST_DISASSOC;
2490 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002491
2492 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002493 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002494 send_disassoc_frame = 0;
2495 }
2496 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002497 pe_debug("Sending Disasscoc with disassoc Trigger"
2498 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002499 disassocTrigger, reasonCode);
2500
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302501 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002502 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002503 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002504 return;
2505 }
2506
Anurag Chouhanc5548422016-02-24 18:33:27 +05302507 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002508 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002509
2510 pMlmDisassocReq->reasonCode = reasonCode;
2511 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2512
2513 /* Update PE session ID */
2514 pMlmDisassocReq->sessionId = sessionId;
2515
2516 lim_post_mlm_message(pMac,
2517 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2518 return;
2519
2520sendDisassoc:
2521 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002522 lim_send_sme_disassoc_ntf(pMac,
2523 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002524 retCode,
2525 disassocTrigger,
2526 1, smesessionId, smetransactionId,
2527 psessionEntry);
2528 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002529 lim_send_sme_disassoc_ntf(pMac,
2530 smeDisassocReq.peer_macaddr.bytes,
2531 retCode, disassocTrigger, 1,
2532 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002533
2534} /*** end __lim_process_sme_disassoc_req() ***/
2535
2536/** -----------------------------------------------------------------
2537 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2538
2539 This function is called to process SME_DISASSOC_CNF message
2540 from HDD or upper layer application.
2541
2542 \param pMac - global mac structure
2543 \param pStaDs - station dph hash node
2544 \return none
2545 \sa
2546 ----------------------------------------------------------------- */
2547static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2548{
2549 tSirSmeDisassocCnf smeDisassocCnf;
2550 uint16_t aid;
2551 tpDphHashNode pStaDs;
2552 tpPESession psessionEntry;
2553 uint8_t sessionId;
2554
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302555 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002556 sizeof(struct sSirSmeDisassocCnf));
2557
2558 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002559 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002560 &sessionId);
2561 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002562 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002563 return;
2564 }
2565
2566 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002567 pe_err("received invalid SME_DISASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002568 return;
2569 }
2570#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2571 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2572 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2573 psessionEntry,
2574 (uint16_t) smeDisassocCnf.statusCode, 0);
2575 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2576 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2577 psessionEntry,
2578 (uint16_t) smeDisassocCnf.statusCode, 0);
2579#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2580
2581 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2582 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002583 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2584 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2585 && (psessionEntry->limSmeState !=
2586 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002587 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002588 psessionEntry->limSmeState);
2589 lim_print_sme_state(pMac, LOGE,
2590 psessionEntry->limSmeState);
2591 return;
2592 }
2593 break;
2594
2595 case eLIM_AP_ROLE:
2596 /* Fall through */
2597 break;
2598
2599 case eLIM_STA_IN_IBSS_ROLE:
2600 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002601 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002602 GET_LIM_SYSTEM_ROLE(psessionEntry));
2603
2604 return;
2605 }
2606
2607 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2608 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2609 LIM_IS_AP_ROLE(psessionEntry)) {
2610 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002611 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002612 &psessionEntry->dph.dphHashTable);
2613 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002614 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2615 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002616 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002617 return;
2618 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302619
2620 if ((pStaDs->mlmStaContext.mlmState ==
2621 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2622 (pStaDs->mlmStaContext.mlmState ==
2623 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002624 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002625 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302626 pStaDs->mlmStaContext.mlmState);
2627 return;
2628 }
2629
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002630 /* Delete FT session if there exists one */
2631 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002632 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2633
2634 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002635 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002636 }
2637
2638 return;
2639}
2640
2641/**
2642 * __lim_process_sme_deauth_req() - process sme deauth req
2643 * @mac_ctx: Pointer to Global MAC structure
2644 * @msg_buf: pointer to the SME message buffer
2645 *
2646 * This function is called to process SME_DEAUTH_REQ message
2647 * from HDD or upper layer application.
2648 *
2649 * Return: None
2650 */
2651
2652static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2653 uint32_t *msg_buf)
2654{
2655 uint16_t deauth_trigger, reason_code;
2656 tLimMlmDeauthReq *mlm_deauth_req;
2657 tSirSmeDeauthReq sme_deauth_req;
2658 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2659 tpPESession session_entry;
2660 uint8_t session_id; /* PE sessionId */
2661 uint8_t sme_session_id;
2662 uint16_t sme_transaction_id;
2663
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302664 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002665 sme_session_id = sme_deauth_req.sessionId;
2666 sme_transaction_id = sme_deauth_req.transactionId;
2667
2668 /*
2669 * We need to get a session first but we don't even know
2670 * if the message is correct.
2671 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002672 session_entry = pe_find_session_by_bssid(mac_ctx,
2673 sme_deauth_req.bssid.bytes,
2674 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002675 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002676 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002677 ret_code = eSIR_SME_INVALID_PARAMETERS;
2678 deauth_trigger = eLIM_HOST_DEAUTH;
2679 goto send_deauth;
2680 }
2681
2682 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2683 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002684 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002685 mac_ctx->lim.gLimRspReqd = false;
2686
2687 ret_code = eSIR_SME_INVALID_PARAMETERS;
2688 deauth_trigger = eLIM_HOST_DEAUTH;
2689 goto send_deauth;
2690 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002691 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2692 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002693 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2694 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002695 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002696#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2697 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2698 session_entry, 0, sme_deauth_req.reasonCode);
2699#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2700
2701 /* Update SME session ID and Transaction ID */
2702 session_entry->smeSessionId = sme_session_id;
2703 session_entry->transactionId = sme_transaction_id;
2704
2705 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2706 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002707 switch (session_entry->limSmeState) {
2708 case eLIM_SME_ASSOCIATED_STATE:
2709 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302710 /* Delete all TDLS peers connected before leaving BSS */
2711 lim_delete_tdls_peers(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002712 case eLIM_SME_WT_ASSOC_STATE:
2713 case eLIM_SME_JOIN_FAILURE_STATE:
2714 case eLIM_SME_IDLE_STATE:
2715 session_entry->limPrevSmeState =
2716 session_entry->limSmeState;
2717 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2718 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2719 session_entry->peSessionId,
2720 session_entry->limSmeState));
2721 /* Send Deauthentication request to MLM below */
2722 break;
2723 case eLIM_SME_WT_DEAUTH_STATE:
2724 case eLIM_SME_WT_DISASSOC_STATE:
2725 /*
2726 * PE Recieved a Deauth/Disassoc frame. Normally it get
2727 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2728 * Which means host is also trying to disconnect.
2729 * PE can continue processing DEAUTH_REQ and send
2730 * the response instead of failing the request.
2731 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2732 * was sent for deauth/disassoc frame.
2733 */
2734 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002735 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002736 break;
2737 default:
2738 /*
2739 * STA is not in a state to deauthenticate with
2740 * peer. Log error and send response to host.
2741 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002742 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002743 session_entry->limSmeState);
2744 lim_print_sme_state(mac_ctx, LOGE,
2745 session_entry->limSmeState);
2746
2747 if (mac_ctx->lim.gLimRspReqd) {
2748 mac_ctx->lim.gLimRspReqd = false;
2749
2750 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2751 deauth_trigger = eLIM_HOST_DEAUTH;
2752
wadesong42968e92017-06-08 14:11:21 +08002753 /*
2754 * here we received deauth request from AP so
2755 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2756 * have ISSUED delSta then mlm state should be
2757 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2758 * delBSS rsp then mlm state should be
2759 * eLIM_MLM_IDLE_STATE so the below condition
2760 * captures the state where delSta not done
2761 * and firmware still in connected state.
2762 */
2763 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002764 eLIM_SME_WT_DEAUTH_STATE &&
2765 session_entry->limMlmState !=
2766 eLIM_MLM_IDLE_STATE &&
2767 session_entry->limMlmState !=
2768 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002769 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002770 goto send_deauth;
2771 }
2772 return;
2773 }
2774 break;
2775
2776 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002777 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002778 if (mac_ctx->lim.gLimRspReqd) {
2779 mac_ctx->lim.gLimRspReqd = false;
2780 ret_code = eSIR_SME_INVALID_PARAMETERS;
2781 deauth_trigger = eLIM_HOST_DEAUTH;
2782 goto send_deauth;
2783 }
2784 return;
2785 case eLIM_AP_ROLE:
2786 break;
2787 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002788 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002789 GET_LIM_SYSTEM_ROLE(session_entry));
2790 if (mac_ctx->lim.gLimRspReqd) {
2791 mac_ctx->lim.gLimRspReqd = false;
2792 ret_code = eSIR_SME_INVALID_PARAMETERS;
2793 deauth_trigger = eLIM_HOST_DEAUTH;
2794 goto send_deauth;
2795 }
2796 return;
2797 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2798
2799 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2800 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002801 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002802 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2803 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2804 } else {
2805 deauth_trigger = eLIM_HOST_DEAUTH;
2806 reason_code = sme_deauth_req.reasonCode;
2807 }
2808
2809 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302810 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002811 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002812 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002813 if (mac_ctx->lim.gLimRspReqd) {
2814 mac_ctx->lim.gLimRspReqd = false;
2815 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2816 deauth_trigger = eLIM_HOST_DEAUTH;
2817 goto send_deauth;
2818 }
2819 return;
2820 }
2821
Anurag Chouhanc5548422016-02-24 18:33:27 +05302822 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002823 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002824
2825 mlm_deauth_req->reasonCode = reason_code;
2826 mlm_deauth_req->deauthTrigger = deauth_trigger;
2827
2828 /* Update PE session Id */
2829 mlm_deauth_req->sessionId = session_id;
2830
2831 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2832 (uint32_t *)mlm_deauth_req);
2833 return;
2834
2835send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002836 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2837 ret_code, deauth_trigger, 1,
2838 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002839}
2840
2841/**
2842 * __lim_process_sme_set_context_req()
2843 *
2844 * @mac_ctx: Pointer to Global MAC structure
2845 * @msg_buf: pointer to the SME message buffer
2846 *
2847 * This function is called to process SME_SETCONTEXT_REQ message
2848 * from HDD or upper layer application.
2849 *
2850 * Return: None
2851 */
2852
2853static void
2854__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2855{
2856 tpSirSmeSetContextReq set_context_req;
2857 tLimMlmSetKeysReq *mlm_set_key_req;
2858 tpPESession session_entry;
2859 uint8_t session_id; /* PE sessionID */
2860 uint8_t sme_session_id;
2861 uint16_t sme_transaction_id;
2862
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002863 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002864 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002865 return;
2866 }
2867
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302868 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002869 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002870 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002871 return;
2872 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302873 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002874 sizeof(struct sSirSmeSetContextReq));
2875 sme_session_id = set_context_req->sessionId;
2876 sme_transaction_id = set_context_req->transactionId;
2877
2878 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002879 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002880 goto end;
2881 }
2882
2883 if (set_context_req->keyMaterial.numKeys >
2884 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002885 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002886 set_context_req->keyMaterial.numKeys);
2887 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002888 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002889 eSIR_SME_INVALID_PARAMETERS, NULL,
2890 sme_session_id, sme_transaction_id);
2891 goto end;
2892 }
2893
2894 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002895 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002896 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002897 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002898 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002899 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002900 eSIR_SME_INVALID_PARAMETERS, NULL,
2901 sme_session_id, sme_transaction_id);
2902 goto end;
2903 }
2904#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2905 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2906 session_entry, 0, 0);
2907#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2908
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002909 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002910 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2911 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002912 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002913 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2914 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302915 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002916 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002917 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002918 goto end;
2919 }
2920 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2921 mlm_set_key_req->numKeys =
2922 set_context_req->keyMaterial.numKeys;
2923 if (mlm_set_key_req->numKeys >
2924 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002925 pe_err("no.of keys exceeded max num of default keys limit");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002926 goto end;
2927 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302928 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002929 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002930
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302931 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002932 (uint8_t *) &set_context_req->keyMaterial.key,
2933 sizeof(tSirKeys) *
2934 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2935 numKeys : 1));
2936
2937 mlm_set_key_req->sessionId = session_id;
2938 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002939 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002940 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002941
2942 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2943 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2944 LIM_IS_AP_ROLE(session_entry)) {
2945 if (set_context_req->keyMaterial.key[0].keyLength) {
2946 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002947
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002948 key_id =
2949 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302950 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002951 &session_entry->WEPKeyMaterial[key_id],
2952 (uint8_t *) &set_context_req->keyMaterial,
2953 sizeof(tSirKeyMaterial));
2954 } else {
2955 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002956
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002957 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2958 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302959 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002960 &mlm_set_key_req->key[i],
2961 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2962 sizeof(tSirKeys));
2963 }
2964 }
2965 }
2966 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2967 (uint32_t *) mlm_set_key_req);
2968 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002969 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002970 GET_LIM_SYSTEM_ROLE(session_entry),
2971 session_entry->limSmeState);
2972 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2973
2974 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002975 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002976 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2977 session_entry, sme_session_id,
2978 sme_transaction_id);
2979 }
2980end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302981 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002982 return;
2983}
2984
2985/**
2986 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2987 *
2988 * @mac_ctx: Pointer to Global MAC structure
2989 * @msg_buf: pointer to the SME message buffer
2990 *
2991 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2992 * from HDD or upper layer application.
2993 *
2994 * Return: None
2995 */
2996
Jeff Johnson801f1532016-10-07 07:54:50 -07002997static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2998 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002999{
3000 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3001 tpDphHashNode sta_ds = NULL;
3002 tpPESession session_entry = NULL;
3003 tSap_Event sap_event;
3004 tpWLAN_SAPEventCB sap_event_cb = NULL;
3005 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3006 uint8_t session_id = CSR_SESSION_ID_INVALID;
3007 uint8_t assoc_id = 0;
3008 uint8_t sta_cnt = 0;
3009
3010 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003011 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003012 return;
3013 }
3014
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303015 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003016 sizeof(struct sSirSmeGetAssocSTAsReq));
3017 /*
3018 * Get Associated stations from PE.
3019 * Find PE session Entry
3020 */
3021 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003022 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003023 &session_id);
3024 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003025 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003026 goto lim_assoc_sta_end;
3027 }
3028
3029 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003030 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003031 session_entry->limSmeState,
3032 GET_LIM_SYSTEM_ROLE(session_entry));
3033 goto lim_assoc_sta_end;
3034 }
3035 /* Retrieve values obtained in the request message */
3036 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3037 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3038
3039 if (NULL == assoc_sta_tmp)
3040 goto lim_assoc_sta_end;
3041 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3042 assoc_id++) {
3043 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3044 &session_entry->dph.dphHashTable);
3045 if (NULL == sta_ds)
3046 continue;
3047 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303048 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003049 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303050 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003051 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3052 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3053
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303054 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055 (uint8_t *)&sta_ds->supportedRates,
3056 sizeof(tSirSupportedRates));
3057 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3058 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3059 assoc_sta_tmp->Support40Mhz =
3060 sta_ds->htDsssCckRate40MHzSupport;
3061
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003062 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003063 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003064 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003065 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003066 pe_debug("Association Id: %d Station Index: %d",
3067 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003068 assoc_sta_tmp++;
3069 sta_cnt++;
3070 }
3071 }
3072lim_assoc_sta_end:
3073 /*
3074 * Call hdd callback with sap event to send the list of
3075 * associated stations from PE
3076 */
3077 if (sap_event_cb != NULL) {
3078 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3079 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303080 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003081 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3082 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3083 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3084 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3085 }
3086}
3087
3088/**
3089 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3090 *
3091 * @mac_ctx: Pointer to Global MAC structure
3092 * @msg_buf: pointer to WPS PBC overlap query message
3093 *
3094 * This function parses get WPS PBC overlap information
3095 * message and call callback to pass WPS PBC overlap
3096 * information back to hdd.
3097 *
3098 * Return: None
3099 */
Jeff Johnson801f1532016-10-07 07:54:50 -07003100static void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3101 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003102{
3103 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3104 tpPESession session_entry = NULL;
3105 tSap_Event sap_event;
3106 tpWLAN_SAPEventCB sap_event_cb = NULL;
3107 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003108 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3109
3110 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003111 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003112 return;
3113 }
3114
3115 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303116 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003117
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303118 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003119 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3120 /*
3121 * Get Associated stations from PE
3122 * Find PE session Entry
3123 */
3124 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003125 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003126 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003127 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003128 goto lim_get_wpspbc_sessions_end;
3129 }
3130
3131 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003132 pe_err("Received unexpected message in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003133 GET_LIM_SYSTEM_ROLE(session_entry));
3134 goto lim_get_wpspbc_sessions_end;
3135 }
3136 /*
3137 * Call hdd callback with sap event to send the
3138 * WPS PBC overlap information
3139 */
3140 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303141 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003142
Anurag Chouhanc5548422016-02-24 18:33:27 +05303143 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003144 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003145 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003146 sap_get_wpspbc_event->UUID_E,
3147 &sap_get_wpspbc_event->wpsPBCOverlap,
3148 session_entry);
3149 } else {
3150 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003151 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003152 session_entry);
3153 /* don't have to inform the HDD/Host */
3154 return;
3155 }
3156
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003157 pe_debug("wpsPBCOverlap %d", sap_get_wpspbc_event->wpsPBCOverlap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003158 lim_print_mac_addr(mac_ctx,
Abhishek Singh4294f802017-08-10 16:37:07 +05303159 sap_get_wpspbc_event->addr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003160
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303161 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003162
3163lim_get_wpspbc_sessions_end:
3164 sap_event_cb =
3165 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3166 if (NULL != sap_event_cb)
3167 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3168}
3169
3170/**
3171 * __lim_counter_measures()
3172 *
3173 * FUNCTION:
3174 * This function is called to "implement" MIC counter measure
3175 * and is *temporary* only
3176 *
3177 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3178 * we don't do the proper STA disassoc sequence since the
3179 * BSS will be stoped anyway
3180 *
3181 ***ASSUMPTIONS:
3182 *
3183 ***NOTE:
3184 *
3185 * @param pMac Pointer to Global MAC structure
3186 * @return None
3187 */
3188
3189static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3190{
3191 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003192
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003193 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003194 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3195 mac, psessionEntry, false);
3196};
3197
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003198static void
3199__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3200{
3201 tSirSmeStopBssReq stopBssReq;
3202 tSirRetStatus status;
3203 tLimSmeStates prevState;
3204 tpPESession psessionEntry;
3205 uint8_t smesessionId;
3206 uint8_t sessionId;
3207 uint16_t smetransactionId;
3208 uint8_t i = 0;
3209 tpDphHashNode pStaDs = NULL;
3210
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303211 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003212 smesessionId = stopBssReq.sessionId;
3213 smetransactionId = stopBssReq.transactionId;
3214
3215 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003216 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003217 /* Send Stop BSS response to host */
3218 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3219 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3220 smetransactionId);
3221 return;
3222 }
3223
3224 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003225 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226 &sessionId);
3227 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003228 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003229 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3230 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3231 smetransactionId);
3232 return;
3233 }
3234#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3235 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3236 0, 0);
3237#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3238
3239 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3240 LIM_IS_STA_ROLE(psessionEntry)) {
3241 /**
3242 * Should not have received STOP_BSS_REQ in states
3243 * other than 'normal' state or on STA in Infrastructure
3244 * mode. Log error and return response to host.
3245 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003246 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003247 psessionEntry->limSmeState,
3248 GET_LIM_SYSTEM_ROLE(psessionEntry));
3249 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3250 /* / Send Stop BSS response to host */
3251 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3252 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3253 smetransactionId);
3254 return;
3255 }
3256
3257 if (LIM_IS_AP_ROLE(psessionEntry))
3258 lim_wpspbc_close(pMac, psessionEntry);
3259
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003260 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003261 stopBssReq.reasonCode);
3262
3263 prevState = psessionEntry->limSmeState;
3264
3265 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3266 MTRACE(mac_trace
3267 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3268 psessionEntry->limSmeState));
3269
3270 /* Update SME session Id and Transaction Id */
3271 psessionEntry->smeSessionId = smesessionId;
3272 psessionEntry->transactionId = smetransactionId;
3273
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003274 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3275 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3276 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003277 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003278
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3280 /* Send disassoc all stations associated thru TKIP */
3281 __lim_counter_measures(pMac, psessionEntry);
3282 else
3283 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003284 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3285 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003286 }
3287
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003288 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3289 /* Free the buffer allocated in START_BSS_REQ */
3290 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3291 psessionEntry->addIeParams.probeRespDataLen = 0;
3292 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003293
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003294 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3295 psessionEntry->addIeParams.assocRespDataLen = 0;
3296 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003297
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003298 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3299 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3300 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003301
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003302 /*
3303 * lim_del_bss is also called as part of coalescing,
3304 * when we send DEL BSS followed by Add Bss msg.
3305 */
3306 pMac->lim.gLimIbssCoalescingHappened = false;
3307 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003308 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3309 pStaDs =
3310 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3311 if (NULL == pStaDs)
3312 continue;
3313 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3314 if (eSIR_SUCCESS == status) {
3315 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3316 pStaDs->assocId, psessionEntry);
3317 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3318 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003319 pe_err("lim_del_sta failed with Status: %d", status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303320 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321 }
3322 }
3323 /* send a delBss to HAL and wait for a response */
3324 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3325
3326 if (status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003327 pe_err("delBss failed for bss %d", psessionEntry->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003328 psessionEntry->limSmeState = prevState;
3329
3330 MTRACE(mac_trace
3331 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3332 psessionEntry->limSmeState));
3333
3334 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3335 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3336 smetransactionId);
3337 }
3338}
3339
3340/**
3341 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3342 * @pMac: Global MAC context
3343 * @pMsg: Message from SME
3344 *
3345 * Wrapper for the function __lim_handle_sme_stop_bss_request
3346 * This message will be defered until softmac come out of
3347 * scan mode. Message should be handled even if we have
3348 * detected radar in the current operating channel.
3349 *
3350 * Return: true - If we consumed the buffer
3351 * false - If have defered the message.
3352 */
3353
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003354static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3355 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003356{
3357 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3358 /**
3359 * If message defered, buffer is not consumed yet.
3360 * So return false
3361 */
3362 return false;
3363 }
3364 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3365 return true;
3366} /*** end __lim_process_sme_stop_bss_req() ***/
3367
3368void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3369 uint32_t body, tpPESession psessionEntry)
3370{
3371
3372 (void)body;
3373 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3374 lim_ibss_delete(pMac, psessionEntry);
3375 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3376 lim_delete_pre_auth_list(pMac);
3377 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3378 psessionEntry->smeSessionId,
3379 psessionEntry->transactionId);
3380 return;
3381}
3382
3383/**
3384 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3385 *
3386 * @mac_ctx: pointer to mac context
3387 * @msg_type: message type
3388 * @msg_buf: pointer to the SME message buffer
3389 *
3390 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3391 * in BTAMP AP.
3392 *
3393 * Return: None
3394 */
3395
3396void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3397 uint32_t *msg_buf)
3398{
3399 tSirSmeAssocCnf assoc_cnf;
3400 tpDphHashNode sta_ds = NULL;
3401 tpPESession session_entry = NULL;
3402 uint8_t session_id;
3403 tpSirAssocReq assoc_req;
3404
3405 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003406 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003407 goto end;
3408 }
3409
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303410 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003411 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003412 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003413 goto end;
3414 }
3415
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003416 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003417 &session_id);
3418 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003419 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003420 goto end;
3421 }
3422
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003423 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003424 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3425 (session_entry->limSmeState !=
3426 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003427 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003428 msg_type, session_entry->limSmeState,
3429 GET_LIM_SYSTEM_ROLE(session_entry));
3430 goto end;
3431 }
3432 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3433 &session_entry->dph.dphHashTable);
3434 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003435 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303437 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003438
3439 /*
3440 * send a DISASSOC_IND message to WSM to make sure
3441 * the state in WSM and LIM is the same
3442 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003443 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003444 eSIR_SME_STA_NOT_ASSOCIATED,
3445 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3446 session_entry->smeSessionId,
3447 session_entry->transactionId,
3448 session_entry);
3449 goto end;
3450 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303451 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003452 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303453 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003454 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003455 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303456 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003457 goto end;
3458 }
3459
3460 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3461 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3462 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3463 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3464 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003465 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3466 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003467 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303468 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003469 goto end;
3470 }
3471 /*
3472 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3473 * has been received
3474 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003475 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003476 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3477 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3478
3479 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3480 /*
3481 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3482 * when it had received Assoc Request frame. Now, PE just needs
3483 * to send association rsp frame to the requesting BTAMP-STA.
3484 */
3485 sta_ds->mlmStaContext.mlmState =
3486 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003487 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003488 sta_ds->assocId);
3489 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3490 sta_ds->assocId, sta_ds->staAddr,
3491 sta_ds->mlmStaContext.subType, sta_ds,
3492 session_entry);
3493 goto end;
3494 } else {
3495 /*
3496 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3497 * to be associated since the HAL sta entry is created for
3498 * denied STA we need to remove this HAL entry.
3499 * So to do that set updateContext to 1
3500 */
3501 if (!sta_ds->mlmStaContext.updateContext)
3502 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003503 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003504 assoc_cnf.statusCode, sta_ds->assocId);
3505 lim_reject_association(mac_ctx, sta_ds->staAddr,
3506 sta_ds->mlmStaContext.subType,
3507 true, sta_ds->mlmStaContext.authType,
3508 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003509 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003510 session_entry);
3511 }
3512end:
3513 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3514 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3515 assoc_req = (tpSirAssocReq)
3516 session_entry->parsedAssocReq[sta_ds->assocId];
3517 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303518 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003519 assoc_req->assocReqFrame = NULL;
3520 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303521 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003522 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3523 }
3524}
3525
3526static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3527{
3528 tpDphHashNode pStaDs;
3529 tSirMacAddr peerMac;
3530 tpSirAddtsReq pSirAddts;
3531 uint32_t timeout;
3532 tpPESession psessionEntry;
3533 uint8_t sessionId; /* PE sessionId */
3534 uint8_t smesessionId;
3535 uint16_t smetransactionId;
3536
3537 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003538 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003539 return;
3540 }
3541
3542 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3543 &smetransactionId);
3544
3545 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3546
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003547 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3548 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003549 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003550 pe_err("Session Does not exist for given bssId");
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303551 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3552 NULL, pSirAddts->req.tspec,
3553 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003554 return;
3555 }
3556#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3557 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3558 0);
3559#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3560
3561 /* if sta
3562 * - verify assoc state
3563 * - send addts request to ap
3564 * - wait for addts response from ap
3565 * if ap, just ignore with error log
3566 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003567 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3568 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3569 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003570
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003571 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003572 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303573 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003574 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003575
3576 pStaDs =
3577 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3578 &psessionEntry->dph.dphHashTable);
3579
3580 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003581 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303582 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003583 }
3584
3585 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3586 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003587 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303588 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003589 }
3590
3591 pSirAddts->req.wsmTspecPresent = 0;
3592 pSirAddts->req.wmeTspecPresent = 0;
3593 pSirAddts->req.lleTspecPresent = 0;
3594
3595 if ((pStaDs->wsmEnabled) &&
3596 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3597 SIR_MAC_ACCESSPOLICY_EDCA))
3598 pSirAddts->req.wsmTspecPresent = 1;
3599 else if (pStaDs->wmeEnabled)
3600 pSirAddts->req.wmeTspecPresent = 1;
3601 else if (pStaDs->lleEnabled)
3602 pSirAddts->req.lleTspecPresent = 1;
3603 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003604 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303605 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003606 }
3607
3608 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3609 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003610 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003611 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303612 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003613 }
3614
3615 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003616 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003617 pMac->lim.gLimAddtsReq.req.dialogToken,
3618 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3619 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3620 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303621 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003622 }
3623
3624 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3625
3626 /* save the addts request */
3627 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303628 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003629 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3630
3631 /* ship out the message now */
3632 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3633 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303634 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003635 /* start a timer to wait for the response */
3636 if (pSirAddts->timeout)
3637 timeout = pSirAddts->timeout;
3638 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3639 eSIR_SUCCESS) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303640 pe_debug("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003641 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303642 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003643 }
3644
3645 timeout = SYS_MS_TO_TICKS(timeout);
3646 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3647 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003648 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303649 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003650 }
3651 pMac->lim.gLimAddtsRspTimerCount++;
3652 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3653 pMac->lim.gLimAddtsRspTimerCount) !=
3654 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003655 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303656 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003657 }
3658 MTRACE(mac_trace
3659 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3660 eLIM_ADDTS_RSP_TIMER));
3661
3662 /* add the sessionId to the timer object */
3663 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3664 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3665 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003666 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303667 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003668 }
3669 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303670
3671send_failure_addts_rsp:
3672 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3673 psessionEntry, pSirAddts->req.tspec,
3674 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003675}
3676
3677static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3678{
3679 tSirMacAddr peerMacAddr;
3680 uint8_t ac;
3681 tSirMacTSInfo *pTsinfo;
3682 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3683 tpDphHashNode pStaDs = NULL;
3684 tpPESession psessionEntry;
3685 uint8_t sessionId;
3686 uint32_t status = eSIR_SUCCESS;
3687 uint8_t smesessionId;
3688 uint16_t smetransactionId;
3689
3690 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3691 &smetransactionId);
3692
3693 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003694 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003695 &sessionId);
3696 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003697 pe_err("Session Does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003698 status = eSIR_FAILURE;
3699 goto end;
3700 }
3701#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3702 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3703 0);
3704#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3705
3706 if (eSIR_SUCCESS !=
3707 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003708 pe_err("lim_validate_delts_req failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003709 status = eSIR_FAILURE;
3710 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3711 smesessionId, smetransactionId);
3712 return;
3713 }
3714
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003715 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3716 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003717 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3718
3719 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3720 pDeltsReq->req.wmeTspecPresent,
3721 &pDeltsReq->req.tsinfo,
3722 &pDeltsReq->req.tspec, psessionEntry);
3723
3724 pTsinfo =
3725 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3726 tsinfo : &pDeltsReq->req.tsinfo;
3727
3728 /* We've successfully send DELTS frame to AP. Update the
3729 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3730 * is no longer trigger enabled or delivery enabled
3731 */
3732 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3733 pTsinfo, CLEAR_UAPSD_MASK);
3734
3735 /* We're deleting the TSPEC, so this particular AC is no longer
3736 * admitted. PE needs to downgrade the EDCA
3737 * parameters(for the AC for which TS is being deleted) to the
3738 * next best AC for which ACM is not enabled, and send the
3739 * updated values to HAL.
3740 */
3741 ac = upToAc(pTsinfo->traffic.userPrio);
3742
3743 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3744 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3745 ~(1 << ac);
3746 } else if (pTsinfo->traffic.direction ==
3747 SIR_MAC_DIRECTION_DNLINK) {
3748 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3749 ~(1 << ac);
3750 } else if (pTsinfo->traffic.direction ==
3751 SIR_MAC_DIRECTION_BIDIR) {
3752 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3753 ~(1 << ac);
3754 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3755 ~(1 << ac);
3756 }
3757
3758 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3759 psessionEntry);
3760
3761 pStaDs =
3762 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3763 &psessionEntry->dph.dphHashTable);
3764 if (pStaDs != NULL) {
3765 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3766 pStaDs->bssId);
3767 status = eSIR_SUCCESS;
3768 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003769 pe_err("Self entry missing in Hash Table");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003770 status = eSIR_FAILURE;
3771 }
3772#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003773 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003774#endif
3775
3776 /* send an sme response back */
3777end:
3778 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3779 smesessionId, smetransactionId);
3780}
3781
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303782void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003783{
3784 /* fetch the sessionEntry based on the sessionId */
3785 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003786
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003787 psessionEntry = pe_find_session_by_session_id(pMac,
3788 pMac->lim.limTimers.gLimAddtsRspTimer.
3789 sessionId);
3790 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003791 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003792 return;
3793 }
3794
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003795 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003796 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003797 GET_LIM_SYSTEM_ROLE(psessionEntry));
3798 pMac->lim.gLimAddtsSent = false;
3799 return;
3800 }
3801
3802 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003803 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003804 return;
3805 }
3806
3807 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003808 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003809 pMac->lim.gLimAddtsRspTimerCount);
3810 return;
3811 }
3812 /* this a real response timeout */
3813 pMac->lim.gLimAddtsSent = false;
3814 pMac->lim.gLimAddtsRspTimerCount++;
3815
3816 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3817 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3818 psessionEntry->smeSessionId,
3819 psessionEntry->transactionId);
3820}
3821
3822/**
3823 * __lim_process_sme_get_statistics_request()
3824 *
3825 ***FUNCTION:
3826 *
3827 *
3828 ***NOTE:
3829 *
3830 * @param pMac Pointer to Global MAC structure
3831 * @param *pMsgBuf A pointer to the SME message buffer
3832 * @return None
3833 */
3834static void
3835__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3836{
3837 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003838 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003839
3840 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3841
3842 msgQ.type = WMA_GET_STATISTICS_REQ;
3843
3844 msgQ.reserved = 0;
3845 msgQ.bodyptr = pMsgBuf;
3846 msgQ.bodyval = 0;
3847 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3848
3849 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303850 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003851 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003852 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003853 return;
3854 }
3855
3856 return;
3857}
3858
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003859#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003860/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003861 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003862 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003863 * @pMac: Pointer to Global MAC structure
3864 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003865 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003866 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003867 */
3868static void
3869__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3870{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003871 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003872
3873 msgQ.type = WMA_TSM_STATS_REQ;
3874 msgQ.reserved = 0;
3875 msgQ.bodyptr = pMsgBuf;
3876 msgQ.bodyval = 0;
3877 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3878
3879 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303880 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003881 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003882 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003883 return;
3884 }
3885}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003886#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003887
Naveen Rawat8029a402017-06-01 10:54:19 -07003888static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3889 struct update_config *msg)
3890{
3891 tpPESession pe_session;
3892
3893 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3894 if (msg == NULL) {
3895 pe_err("Buffer is Pointing to NULL");
3896 return;
3897 }
3898
3899 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3900 msg->sme_session_id);
3901 if (pe_session == NULL) {
3902 pe_warn("Session does not exist for given BSSID");
3903 return;
3904 }
3905
3906 switch (msg->capab) {
3907 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3908 pe_session->htConfig.ht_rx_ldpc = msg->value;
3909 break;
3910 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3911 pe_session->htConfig.ht_tx_stbc = msg->value;
3912 break;
3913 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3914 pe_session->htConfig.ht_rx_stbc = msg->value;
3915 break;
3916 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3917 pe_session->htConfig.ht_sgi20 = msg->value;
3918 break;
3919 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3920 pe_session->htConfig.ht_sgi40 = msg->value;
3921 break;
3922 }
3923
3924 if (LIM_IS_AP_ROLE(pe_session)) {
3925 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3926 lim_send_beacon_ind(mac_ctx, pe_session);
3927 }
3928}
3929
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003930void
3931lim_send_vdev_restart(tpAniSirGlobal pMac,
3932 tpPESession psessionEntry, uint8_t sessionId)
3933{
3934 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003935 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003936 tSirRetStatus retCode = eSIR_SUCCESS;
3937
3938 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003939 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003940 return;
3941 }
3942
3943 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303944 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003945 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003946 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003947 return;
3948 }
3949
3950 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3951 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003952 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003953
3954 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3955 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3956 msgQ.bodyval = 0;
3957
3958 retCode = wma_post_ctrl_msg(pMac, &msgQ);
3959 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003960 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303961 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003962 }
3963}
3964
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303965/**
3966 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3967 * @mac_ctx: Pointer to Global MAC structure
3968 * @msg_buf: Pointer to SME message buffer
3969 *
3970 * Return: None
3971 */
3972static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3973 uint32_t *msg_buf)
3974{
3975 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003976 struct scheduler_msg wma_msg = {0};
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303977 tSirRetStatus status;
3978 tSirRoamOffloadScanReq *req_buffer;
3979 uint16_t local_ie_len;
3980 uint8_t *local_ie_buf;
3981
3982 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3983 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3984 req_buffer->sessionId);
3985
3986 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3987 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003988 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303989 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303990 return;
3991 }
3992
3993 local_ie_len = req_buffer->assoc_ie.length;
3994 /* Update ext cap IE if present */
3995 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003996 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3997 local_ie_buf, &local_ie_len)) {
3998 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003999 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
4000 req_buffer->assoc_ie.length = local_ie_len;
4001 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
4002 local_ie_buf, local_ie_len);
4003 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304004 }
4005 qdf_mem_free(local_ie_buf);
4006
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05304007 if (pe_session)
4008 lim_update_fils_rik(pe_session, req_buffer);
4009
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304010 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
4011 wma_msg.bodyptr = req_buffer;
4012
4013 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
4014 if (eSIR_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004015 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304016 qdf_mem_free(req_buffer);
4017 }
4018}
4019
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304020/*
4021 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
4022 * @mac_ctx: Pointer to global mac context
4023 * @session: Pointer to PE session
4024 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
4025 * 1 - Disable broadcast SSID
4026 *
4027 * Return: None
4028 */
4029static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
4030 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004031{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004032 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004033 session->ssidHidden, ssid_hidden);
4034
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004035 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304036 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004037 } else {
4038 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05304039 return;
4040 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004041
4042 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304043 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004044
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004045 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304046}
4047
4048/**
4049 * __lim_process_sme_session_update - process SME session update msg
4050 *
4051 * @mac_ctx: Pointer to global mac context
4052 * @msg_buf: Pointer to the received message buffer
4053 *
4054 * Return: None
4055 */
4056static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
4057 uint32_t *msg_buf)
4058{
4059 struct sir_update_session_param *msg;
4060 tpPESession session;
4061
4062 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004063 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304064 return;
4065 }
4066
4067 msg = (struct sir_update_session_param *) msg_buf;
4068
4069 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
4070 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004071 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304072 msg->session_id);
4073 return;
4074 }
4075
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004076 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304077 msg->param_type, msg->param_val);
4078 switch (msg->param_type) {
4079 case SIR_PARAM_SSID_HIDDEN:
4080 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
4081 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05304082 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
4083 session->ignore_assoc_disallowed = msg->param_val;
4084 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304085 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004086 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304087 break;
4088 }
4089}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004090
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004091/*
4092 Update the beacon Interval dynamically if beaconInterval is different in MCC
4093 */
4094static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4095{
4096 tpSirChangeBIParams pChangeBIParams;
4097 tpPESession psessionEntry;
4098 uint8_t sessionId = 0;
4099 tUpdateBeaconParams beaconParams;
4100
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004101 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004102
4103 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004104 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004105 return;
4106 }
4107
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304108 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004109 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4110
4111 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004112 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004113 &sessionId);
4114 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004115 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004116 return;
4117 }
4118
4119 /*Update sessionEntry Beacon Interval */
4120 if (psessionEntry->beaconParams.beaconInterval !=
4121 pChangeBIParams->beaconInterval) {
4122 psessionEntry->beaconParams.beaconInterval =
4123 pChangeBIParams->beaconInterval;
4124 }
4125
4126 /*Update sch beaconInterval */
4127 if (pMac->sch.schObject.gSchBeaconInterval !=
4128 pChangeBIParams->beaconInterval) {
4129 pMac->sch.schObject.gSchBeaconInterval =
4130 pChangeBIParams->beaconInterval;
4131
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004132 pe_debug("LIM send update BeaconInterval Indication: %d",
4133 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004134
4135 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4136 /* Update beacon */
4137 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4138
4139 beaconParams.bssIdx = psessionEntry->bssIdx;
4140 /* Set change in beacon Interval */
4141 beaconParams.beaconInterval =
4142 pChangeBIParams->beaconInterval;
4143 beaconParams.paramChangeBitmap =
4144 PARAM_BCN_INTERVAL_CHANGED;
4145 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4146 }
4147 }
4148
4149 return;
4150} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4151
4152#ifdef QCA_HT_2040_COEX
4153static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4154 uint32_t *pMsgBuf)
4155{
4156 tpSirSetHT2040Mode pSetHT2040Mode;
4157 tpPESession psessionEntry;
4158 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004159 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004160 tUpdateVHTOpMode *pHtOpMode = NULL;
4161 uint16_t staId = 0;
4162 tpDphHashNode pStaDs = NULL;
4163
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004164 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004165 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004166 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004167 return;
4168 }
4169
4170 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4171
4172 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004173 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004174 &sessionId);
4175 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004176 pe_debug("Session does not exist for given BSSID");
4177 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004178 return;
4179 }
4180
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004181 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004182 pSetHT2040Mode->cbMode);
4183 /*Update sessionEntry HT related fields */
4184 switch (pSetHT2040Mode->cbMode) {
4185 case PHY_SINGLE_CHANNEL_CENTERED:
4186 psessionEntry->htSecondaryChannelOffset =
4187 PHY_SINGLE_CHANNEL_CENTERED;
4188 psessionEntry->htRecommendedTxWidthSet = 0;
4189 if (pSetHT2040Mode->obssEnabled)
4190 psessionEntry->htSupportedChannelWidthSet
4191 = eHT_CHANNEL_WIDTH_40MHZ;
4192 else
4193 psessionEntry->htSupportedChannelWidthSet
4194 = eHT_CHANNEL_WIDTH_20MHZ;
4195 break;
4196 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4197 psessionEntry->htSecondaryChannelOffset =
4198 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4199 psessionEntry->htRecommendedTxWidthSet = 1;
4200 break;
4201 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4202 psessionEntry->htSecondaryChannelOffset =
4203 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4204 psessionEntry->htRecommendedTxWidthSet = 1;
4205 break;
4206 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004207 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004208 return;
4209 }
4210
4211 /* Update beacon */
4212 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4213 lim_send_beacon_ind(pMac, psessionEntry);
4214
4215 /* update OP Mode for each associated peer */
4216 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4217 pStaDs = dph_get_hash_entry(pMac, staId,
4218 &psessionEntry->dph.dphHashTable);
4219 if (NULL == pStaDs)
4220 continue;
4221
4222 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304223 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004224 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004225 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004226 return;
4227 }
4228 pHtOpMode->opMode =
4229 (psessionEntry->htSecondaryChannelOffset ==
4230 PHY_SINGLE_CHANNEL_CENTERED) ?
4231 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4232 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304233 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004234 sizeof(tSirMacAddr));
4235 pHtOpMode->smesessionId = sessionId;
4236
4237 msg.type = WMA_UPDATE_OP_MODE;
4238 msg.reserved = 0;
4239 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004240 if (!QDF_IS_STATUS_SUCCESS
4241 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
4242 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304243 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004244 return;
4245 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004246 pe_debug("Notifed FW about OP mode: %d for staId=%d",
4247 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004248
4249 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004250 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004251 }
4252
4253 return;
4254}
4255#endif
4256
4257/* -------------------------------------------------------------------- */
4258/**
4259 * __lim_process_report_message
4260 *
4261 * FUNCTION: Processes the next received Radio Resource Management message
4262 *
4263 * LOGIC:
4264 *
4265 * ASSUMPTIONS:
4266 *
4267 * NOTE:
4268 *
4269 * @param None
4270 * @return None
4271 */
4272
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004273static void __lim_process_report_message(tpAniSirGlobal pMac,
4274 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004275{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004276 switch (pMsg->type) {
4277 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4278 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4279 break;
4280 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004281 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004282 break;
4283 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004284 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004285 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004286}
4287
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004288/* -------------------------------------------------------------------- */
4289/**
4290 * lim_send_set_max_tx_power_req
4291 *
4292 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4293 *
4294 * LOGIC:
4295 *
4296 * ASSUMPTIONS:
4297 *
4298 * NOTE:
4299 *
4300 * @param txPower txPower to be set.
4301 * @param pSessionEntry session entry.
4302 * @return None
4303 */
4304tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004305lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004306 tpPESession pSessionEntry)
4307{
4308 tpMaxTxPowerParams pMaxTxParams = NULL;
4309 tSirRetStatus retCode = eSIR_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004310 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004311
4312 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004313 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004314 return eSIR_FAILURE;
4315 }
4316
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304317 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004318 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004319 pe_err("Unable to allocate memory for pMaxTxParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004320 return eSIR_MEM_ALLOC_FAILED;
4321
4322 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004323 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304324 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304325 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304326 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004327 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304328 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004329
4330 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4331 msgQ.bodyptr = pMaxTxParams;
4332 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004333 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004334 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4335 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4336 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004337 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304338 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004339 }
4340 return retCode;
4341}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004342
4343/**
4344 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4345 *
4346 * @mac_ctx: Pointer to Global MAC structure
4347 * @msg_buf: pointer to the SME message buffer
4348 *
4349 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4350 * from SME. It Register this information within PE.
4351 *
4352 * Return: None
4353 */
4354static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4355 uint32_t *msg_buf)
4356{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304357 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004358 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4359 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4360 struct mgmt_frm_reg_info *next = NULL;
4361 bool match = false;
4362
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004363 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004364 sme_req->registerFrame, sme_req->frameType,
4365 sme_req->matchLen);
4366 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304367 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304368 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4369 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304370 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004371
4372 while (lim_mgmt_regn != NULL) {
4373 if (lim_mgmt_regn->frameType != sme_req->frameType)
4374 goto skip_match;
4375 if (sme_req->matchLen) {
4376 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304377 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004378 sme_req->matchData,
4379 lim_mgmt_regn->matchLen))) {
4380 /* found match! */
4381 match = true;
4382 break;
4383 }
4384 } else {
4385 /* found match! */
4386 match = true;
4387 break;
4388 }
4389skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304390 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304391 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004392 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304393 (qdf_list_node_t *)lim_mgmt_regn,
4394 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304395 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004396 lim_mgmt_regn = next;
4397 next = NULL;
4398 }
4399 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304400 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004401 if (QDF_STATUS_SUCCESS ==
4402 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004403 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004404 (qdf_list_node_t *)lim_mgmt_regn))
4405 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304406 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004407 }
4408
4409 if (sme_req->registerFrame) {
4410 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304411 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004412 sme_req->matchLen);
4413 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004414 lim_mgmt_regn->frameType = sme_req->frameType;
4415 lim_mgmt_regn->matchLen = sme_req->matchLen;
4416 lim_mgmt_regn->sessionId = sme_req->sessionId;
4417 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304418 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004419 sme_req->matchData,
4420 sme_req->matchLen);
4421 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304422 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004423 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304424 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004425 gLimMgmtFrameRegistratinQueue,
4426 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304427 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004428 &mac_ctx->lim.lim_frame_register_lock);
4429 }
4430 }
4431 return;
4432}
4433
4434static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4435{
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004436 pe_debug("Dereg msgType %d", pMac->lim.gDeferMsgTypeForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004437 pMac->lim.gDeferMsgTypeForNOA = 0;
4438 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4439 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304440 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004441 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4442 }
4443}
4444
4445/**
4446 * lim_process_regd_defd_sme_req_after_noa_start()
4447 *
4448 * mac_ctx: Pointer to Global MAC structure
4449 *
4450 * This function is called to process deferred sme req message
4451 * after noa start.
4452 *
4453 * Return: None
4454 */
4455void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4456{
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004457 pe_debug("Process defd sme req %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004458 mac_ctx->lim.gDeferMsgTypeForNOA);
4459
4460 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4461 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004462 pe_warn("start rcvd from FW when no sme deferred msg pending. Do nothing");
4463 pe_warn("It may happen when NOA start ind and timeout happen at the same time");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004464 return;
4465 }
4466 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4467 case eWNI_SME_SCAN_REQ:
4468 __lim_process_sme_scan_req(mac_ctx,
4469 mac_ctx->lim.gpDefdSmeMsgForNOA);
4470 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004471 case eWNI_SME_JOIN_REQ:
4472 __lim_process_sme_join_req(mac_ctx,
4473 mac_ctx->lim.gpDefdSmeMsgForNOA);
4474 break;
4475 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004476 pe_err("Unknown deferred msg type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004477 mac_ctx->lim.gDeferMsgTypeForNOA);
4478 break;
4479 }
4480 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4481}
4482
4483static void
4484__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4485{
4486 tpSirResetAPCapsChange pResetCapsChange;
4487 tpPESession psessionEntry;
4488 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004489
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004490 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004491 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004492 return;
4493 }
4494
4495 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4496 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004497 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4498 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004499 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004500 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004501 return;
4502 }
4503
4504 psessionEntry->limSentCapsChangeNtf = false;
4505 return;
4506}
4507
4508/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304509 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4510 * indication callback in PE.
4511 * @mac_ptr: Mac pointer
4512 * @msg_buf: Msg pointer containing the callback
4513 *
4514 * This function is used save the Management frame
4515 * indication callback in PE.
4516 *
4517 * Return: None
4518 */
4519static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4520 uint32_t *msg_buf)
4521{
4522 struct sir_sme_mgmt_frame_cb_req *sme_req =
4523 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4524
4525 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004526 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304527 return;
4528 }
4529 if (sme_req->callback)
4530 mac_ctx->mgmt_frame_ind_cb =
4531 (sir_mgmt_frame_ind_callback)sme_req->callback;
4532 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004533 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304534}
4535
4536/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304537 *__lim_process_send_disassoc_frame: function processes disassoc frame
4538 * @mac_ctx: pointer to mac context
4539 * @msg_buf: message buffer
4540 *
4541 * function processes disassoc request received from SME
4542 *
4543 * return: none
4544 */
4545static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4546 uint32_t *msg_buf)
4547{
4548 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4549 tSirRetStatus status;
4550 tpPESession session_entry = NULL;
4551 uint8_t sme_session_id;
4552 uint16_t sme_trans_id;
4553
4554 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004555 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304556 return;
4557 }
4558
4559 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4560 &sme_trans_id);
4561
4562 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4563 &sme_send_disassoc_frame_req,
4564 (uint8_t *)msg_buf);
4565
4566 if ((eSIR_FAILURE == status) ||
4567 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4568 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004569 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304570 return;
4571 }
4572
4573 session_entry = pe_find_session_by_sme_session_id(
4574 mac_ctx, sme_session_id);
4575 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004576 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304577 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4578 return;
4579 }
4580
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004581 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 +05304582 sme_send_disassoc_frame_req.msg_type,
4583 sme_send_disassoc_frame_req.length,
4584 sme_send_disassoc_frame_req.session_id,
4585 sme_send_disassoc_frame_req.trans_id,
4586 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4587 sme_send_disassoc_frame_req.reason,
4588 sme_send_disassoc_frame_req.wait_for_ack);
4589
4590 lim_send_disassoc_mgmt_frame(mac_ctx,
4591 sme_send_disassoc_frame_req.reason,
4592 sme_send_disassoc_frame_req.peer_mac,
4593 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4594}
4595
4596/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004597 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4598 * @mac_ctx: Pointer to Global MAC structure
4599 * @pdev_id: pdev id to set the IE.
4600 * @nss: Nss values to prepare the HT IE.
4601 *
4602 * Prepares the HT IE with self capabilities for different
4603 * Nss values and sends the set HT IE req to FW.
4604 *
4605 * Return: None
4606 */
4607static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4608 uint8_t nss)
4609{
4610 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004611 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004612 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004613 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004614 tHtCaps *p_ht_cap;
4615 int i;
4616
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004617 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004618 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4619 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004620 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004621 return;
4622 }
4623 ie_params->nss = i;
4624 ie_params->pdev_id = pdev_id;
4625 ie_params->ie_type = DOT11_HT_IE;
4626 /* 2 for IE len and EID */
4627 ie_params->ie_len = 2 + sizeof(tHtCaps);
4628 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4629 if (NULL == ie_params->ie_ptr) {
4630 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004631 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004632 return;
4633 }
4634 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4635 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4636 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4637 ie_params->ie_len);
4638
4639 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004640 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4641 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004642 if (NULL == p_ie) {
4643 qdf_mem_free(ie_params->ie_ptr);
4644 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004645 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004646 return;
4647 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004648 p_ht_cap = (tHtCaps *)&p_ie[2];
4649 p_ht_cap->supportedMCSSet[1] = 0;
4650 p_ht_cap->txSTBC = 0;
4651 }
4652
4653 msg.type = WMA_SET_PDEV_IE_REQ;
4654 msg.bodyptr = ie_params;
4655 msg.bodyval = 0;
4656
4657 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4658 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004659 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004660 qdf_mem_free(ie_params->ie_ptr);
4661 qdf_mem_free(ie_params);
4662 return;
4663 }
4664 }
4665}
4666
4667/**
4668 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4669 * @mac_ctx: Pointer to Global MAC structure
4670 * @pdev_id: pdev id to set the IE.
4671 * @nss: Nss values to prepare the VHT IE.
4672 *
4673 * Prepares the VHT IE with self capabilities for different
4674 * Nss values and sends the set VHT IE req to FW.
4675 *
4676 * Return: None
4677 */
4678static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4679 uint8_t nss)
4680{
4681 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004682 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004683 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004684 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004685 tSirMacVHTCapabilityInfo *vht_cap;
4686 int i;
4687 tSirVhtMcsInfo *vht_mcs;
4688
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004689 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004690 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4691 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004692 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004693 return;
4694 }
4695 ie_params->nss = i;
4696 ie_params->pdev_id = pdev_id;
4697 ie_params->ie_type = DOT11_VHT_IE;
4698 /* 2 for IE len and EID */
4699 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4700 sizeof(tSirVhtMcsInfo);
4701 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4702 if (NULL == ie_params->ie_ptr) {
4703 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004704 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004705 return;
4706 }
4707 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4708 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4709 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4710 ie_params->ie_len);
4711
4712 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004713 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4714 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004715 if (NULL == p_ie) {
4716 qdf_mem_free(ie_params->ie_ptr);
4717 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004718 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004719 return;
4720 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004721 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4722 vht_cap->txSTBC = 0;
4723 vht_mcs =
4724 (tSirVhtMcsInfo *)&p_ie[2 +
4725 sizeof(tSirMacVHTCapabilityInfo)];
4726 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4727 vht_mcs->rxHighest =
4728 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4729 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4730 vht_mcs->txHighest =
4731 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4732 }
4733 msg.type = WMA_SET_PDEV_IE_REQ;
4734 msg.bodyptr = ie_params;
4735 msg.bodyval = 0;
4736
4737 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4738 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004739 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004740 qdf_mem_free(ie_params->ie_ptr);
4741 qdf_mem_free(ie_params);
4742 return;
4743 }
4744 }
4745}
4746
4747/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004748 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4749 * @mac_ctx: Pointer to Global MAC structure
4750 * @msg_buf: Pointer to the SME message buffer
4751 *
4752 * This function is called by limProcessMessageQueue(). This function sets the
4753 * VDEV IEs to the FW.
4754 *
4755 * Return: None
4756 */
4757static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4758 uint32_t *msg_buf)
4759{
4760 struct sir_set_vdev_ies_per_band *p_msg =
4761 (struct sir_set_vdev_ies_per_band *)msg_buf;
4762
4763 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004764 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004765 return;
4766 }
4767
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004768 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004769 p_msg->vdev_id);
4770 /* intentionally using NULL here so that self capabilty are sent */
4771 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4772 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004773 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004774}
4775
4776/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004777 * lim_process_set_pdev_IEs() - process the set pdev IE req
4778 * @mac_ctx: Pointer to Global MAC structure
4779 * @msg_buf: Pointer to the SME message buffer
4780 *
4781 * This function is called by limProcessMessageQueue(). This
4782 * function sets the PDEV IEs to the FW.
4783 *
4784 * Return: None
4785 */
4786static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4787{
4788 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4789
4790 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4791
4792 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004793 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004794 return;
4795 }
4796
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004797 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004798 ht_vht_cfg->nss);
4799 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4800
4801 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4802 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4803 ht_vht_cfg->nss);
4804}
4805
4806/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304807 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4808 *
4809 * access policy
4810 * @mac_ctx: pointer to mac context
4811 * @msg: message buffer
4812 *
4813 * function processes vendor IE and access policy from SME and updates PE
4814 *
4815 * session entry
4816 *
4817 * return: none
4818*/
4819static void lim_process_sme_update_access_policy_vendor_ie(
4820 tpAniSirGlobal mac_ctx,
4821 uint32_t *msg)
4822{
4823 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4824 struct sPESession *pe_session_entry;
4825 uint8_t num_bytes;
4826
4827 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004828 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304829 return;
4830 }
4831 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4832 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4833 update_vendor_ie->sme_session_id);
4834
4835 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004836 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304837 update_vendor_ie->sme_session_id);
4838 return;
4839 }
4840 if (pe_session_entry->access_policy_vendor_ie)
4841 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4842
4843 num_bytes = update_vendor_ie->ie[1] + 2;
4844 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4845
4846 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004847 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304848 return;
4849 }
4850 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4851 &update_vendor_ie->ie[0], num_bytes);
4852
4853 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4854}
4855
4856/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004857 * lim_process_sme_req_messages()
4858 *
4859 ***FUNCTION:
4860 * This function is called by limProcessMessageQueue(). This
4861 * function processes SME request messages from HDD or upper layer
4862 * application.
4863 *
4864 ***LOGIC:
4865 *
4866 ***ASSUMPTIONS:
4867 *
4868 ***NOTE:
4869 *
4870 * @param pMac Pointer to Global MAC structure
4871 * @param msgType Indicates the SME message type
4872 * @param *pMsgBuf A pointer to the SME message buffer
4873 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4874 * false - if pMsgBuf is not to be freed.
4875 */
4876
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004877bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4878 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004879{
4880 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
4881 uint32_t *pMsgBuf = pMsg->bodyptr;
4882 tpSirSmeScanReq pScanReq;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004883
4884 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004885 lim_msg_str(pMsg->type), pMsg->type,
4886 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4887 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004888
4889 pScanReq = (tpSirSmeScanReq) pMsgBuf;
4890 /* If no insert NOA required then execute the code below */
4891
4892 switch (pMsg->type) {
4893 case eWNI_SME_SYS_READY_IND:
4894 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4895 break;
4896
4897 case eWNI_SME_START_BSS_REQ:
4898 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4899 break;
4900
4901 case eWNI_SME_SCAN_REQ:
4902 __lim_process_sme_scan_req(pMac, pMsgBuf);
4903 break;
4904
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004905 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4906 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4907 break;
4908 case eWNI_SME_JOIN_REQ:
4909 __lim_process_sme_join_req(pMac, pMsgBuf);
4910 break;
4911
4912 case eWNI_SME_REASSOC_REQ:
4913 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4914 break;
4915
4916 case eWNI_SME_DISASSOC_REQ:
4917 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4918 break;
4919
4920 case eWNI_SME_DISASSOC_CNF:
4921 case eWNI_SME_DEAUTH_CNF:
4922 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4923 break;
4924
4925 case eWNI_SME_DEAUTH_REQ:
4926 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4927 break;
4928
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304929 case eWNI_SME_SEND_DISASSOC_FRAME:
4930 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4931 break;
4932
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004933 case eWNI_SME_SETCONTEXT_REQ:
4934 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4935 break;
4936
4937 case eWNI_SME_STOP_BSS_REQ:
4938 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4939 break;
4940
4941 case eWNI_SME_ASSOC_CNF:
4942 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004943 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004944 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4945 pMsgBuf);
4946 break;
4947
4948 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004949 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004950 __lim_process_sme_addts_req(pMac, pMsgBuf);
4951 break;
4952
4953 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004954 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004955 __lim_process_sme_delts_req(pMac, pMsgBuf);
4956 break;
4957
4958 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004959 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004960 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4961 break;
4962
4963 case eWNI_SME_GET_STATISTICS_REQ:
4964 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4965 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4966 bufConsumed = false;
4967 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004968#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004969 case eWNI_SME_GET_TSM_STATS_REQ:
4970 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4971 bufConsumed = false;
4972 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004973#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004974 case eWNI_SME_GET_ASSOC_STAS_REQ:
4975 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4976 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304977 case eWNI_SME_SESSION_UPDATE_PARAM:
4978 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004979 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304980 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4981 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4982 bufConsumed = false;
4983 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004984 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
4985 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
4986 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004987 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4988 /* Update the beaconInterval */
4989 __lim_process_sme_change_bi(pMac, pMsgBuf);
4990 break;
4991
4992#ifdef QCA_HT_2040_COEX
4993 case eWNI_SME_SET_HT_2040_MODE:
4994 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4995 break;
4996#endif
4997
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004998 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4999 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5000 __lim_process_report_message(pMac, pMsg);
5001 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005002
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005003 case eWNI_SME_FT_PRE_AUTH_REQ:
5004 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5005 break;
5006 case eWNI_SME_FT_UPDATE_KEY:
5007 lim_process_ft_update_key(pMac, pMsgBuf);
5008 break;
5009
5010 case eWNI_SME_FT_AGGR_QOS_REQ:
5011 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5012 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005013
5014 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5015 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5016 break;
5017#ifdef FEATURE_WLAN_TDLS
5018 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5019 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5020 break;
5021 case eWNI_SME_TDLS_ADD_STA_REQ:
5022 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5023 break;
5024 case eWNI_SME_TDLS_DEL_STA_REQ:
5025 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5026 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005027#endif
5028 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5029 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5030 break;
5031
5032 case eWNI_SME_CHANNEL_CHANGE_REQ:
5033 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5034 break;
5035
5036 case eWNI_SME_START_BEACON_REQ:
5037 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5038 break;
5039
5040 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5041 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5042 break;
5043
5044 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5045 lim_process_update_add_ies(pMac, pMsgBuf);
5046 break;
5047
5048 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5049 lim_process_modify_add_ies(pMac, pMsgBuf);
5050 break;
5051 case eWNI_SME_SET_HW_MODE_REQ:
5052 lim_process_set_hw_mode(pMac, pMsgBuf);
5053 break;
5054 case eWNI_SME_NSS_UPDATE_REQ:
5055 lim_process_nss_update_request(pMac, pMsgBuf);
5056 break;
5057 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5058 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5059 break;
5060 case eWNI_SME_SET_IE_REQ:
5061 lim_process_set_ie_req(pMac, pMsgBuf);
5062 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305063 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5064 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5065 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305066 case eWNI_SME_EXT_CHANGE_CHANNEL:
5067 lim_process_ext_change_channel(pMac, pMsgBuf);
5068 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005069 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5070 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5071 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005072 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5073 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005074 break;
5075 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5076 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5077 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07005078 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005079 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005080 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005081 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005082 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305083 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5084 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5085 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07005086 case eWNI_SME_UPDATE_CONFIG:
5087 lim_process_sme_update_config(pMac,
5088 (struct update_config *)pMsgBuf);
5089 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005090 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305091 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005092 pMsg->bodyptr = NULL;
5093 break;
5094 } /* switch (msgType) */
5095
5096 return bufConsumed;
5097} /*** end lim_process_sme_req_messages() ***/
5098
5099/**
5100 * lim_process_sme_start_beacon_req()
5101 *
5102 ***FUNCTION:
5103 * This function is called by limProcessMessageQueue(). This
5104 * function processes SME request messages from HDD or upper layer
5105 * application.
5106 *
5107 ***LOGIC:
5108 *
5109 ***ASSUMPTIONS:
5110 *
5111 ***NOTE:
5112 *
5113 * @param pMac Pointer to Global MAC structure
5114 * @param msgType Indicates the SME message type
5115 * @param *pMsgBuf A pointer to the SME message buffer
5116 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5117 * false - if pMsgBuf is not to be freed.
5118 */
5119static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5120{
5121 tpSirStartBeaconIndication pBeaconStartInd;
5122 tpPESession psessionEntry;
5123 uint8_t sessionId; /* PE sessionID */
5124
5125 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005126 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005127 return;
5128 }
5129
5130 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5131 psessionEntry = pe_find_session_by_bssid(pMac,
5132 pBeaconStartInd->bssid,
5133 &sessionId);
5134 if (psessionEntry == NULL) {
5135 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005136 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005137 return;
5138 }
5139
5140 if (pBeaconStartInd->beaconStartStatus == true) {
5141 /*
5142 * Currently this Indication comes from SAP
5143 * to start Beacon Tx on a DFS channel
5144 * since beaconing has to be done on DFS
5145 * channel only after CAC WAIT is completed.
5146 * On a DFS Channel LIM does not start beacon
5147 * Tx right after the WMA_ADD_BSS_RSP.
5148 */
5149 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05305150 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005151 FL("Start Beacon with ssid %s Ch %d"),
5152 psessionEntry->ssId.ssId,
5153 psessionEntry->currentOperChannel);
5154 lim_send_beacon_ind(pMac, psessionEntry);
5155 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005156 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005157 return;
5158 }
5159}
5160
5161/**
5162 * lim_process_sme_channel_change_request() - process sme ch change req
5163 *
5164 * @mac_ctx: Pointer to Global MAC structure
5165 * @msg_buf: pointer to the SME message buffer
5166 *
5167 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5168 *
5169 * Return: None
5170 */
5171static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5172 uint32_t *msg_buf)
5173{
5174 tpSirChanChangeRequest ch_change_req;
5175 tpPESession session_entry;
5176 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005177 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005178 uint32_t val = 0;
5179
5180 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005181 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005182 return;
5183 }
5184 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5185
5186 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5187 ch_change_req->targetChannel);
5188
5189 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5190 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005191 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005192 return;
5193 }
5194
5195 session_entry = pe_find_session_by_bssid(mac_ctx,
5196 ch_change_req->bssid, &session_id);
5197 if (session_entry == NULL) {
5198 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005199 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005200 return;
5201 }
5202
5203 if (session_entry->currentOperChannel ==
5204 ch_change_req->targetChannel) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005205 pe_err("target CH is same as current CH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005206 return;
5207 }
5208
5209 if (LIM_IS_AP_ROLE(session_entry))
5210 session_entry->channelChangeReasonCode =
5211 LIM_SWITCH_CHANNEL_SAP_DFS;
5212 else
5213 session_entry->channelChangeReasonCode =
5214 LIM_SWITCH_CHANNEL_OPERATION;
5215
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005216 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005217 session_entry->currentOperChannel,
5218 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005219 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005220
5221 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005222 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005223 session_entry->ch_center_freq_seg0 =
5224 ch_change_req->center_freq_seg_0;
5225 session_entry->ch_center_freq_seg1 =
5226 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005227 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005228 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005229 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005230 session_entry->htRecommendedTxWidthSet =
5231 session_entry->htSupportedChannelWidthSet;
5232 session_entry->currentOperChannel =
5233 ch_change_req->targetChannel;
5234 session_entry->limRFBand =
5235 lim_get_rf_band(session_entry->currentOperChannel);
5236 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08005237 if (CHAN_HOP_ALL_BANDS_ENABLE ||
5238 SIR_BAND_5_GHZ == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005239 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5240 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005241 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005242 }
5243
5244 session_entry->lim11hEnable = val;
5245 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305246 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005247 &ch_change_req->operational_rateset,
5248 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305249 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005250 &ch_change_req->extended_rateset,
5251 sizeof(session_entry->extRateSet));
5252 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5253 session_entry->ch_center_freq_seg0,
5254 session_entry->ch_center_freq_seg1,
5255 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07005256 max_tx_pwr, session_entry->peSessionId,
5257 ch_change_req->cac_duration_ms,
5258 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005259}
5260
5261/******************************************************************************
5262* lim_start_bss_update_add_ie_buffer()
5263*
5264***FUNCTION:
5265* This function checks the src buffer and its length and then malloc for
5266* dst buffer update the same
5267*
5268***LOGIC:
5269*
5270***ASSUMPTIONS:
5271*
5272***NOTE:
5273*
5274* @param pMac Pointer to Global MAC structure
5275* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5276* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5277* @param *pSrcData_buff A pointer of uint8_t src buffer
5278* @param srcDataLen src buffer length
5279******************************************************************************/
5280
5281static void
5282lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5283 uint8_t **pDstData_buff,
5284 uint16_t *pDstDataLen,
5285 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5286{
5287
5288 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5289 *pDstDataLen = srcDataLen;
5290
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305291 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005292
5293 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005294 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005295 return;
5296 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305297 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005298 } else {
5299 *pDstData_buff = NULL;
5300 *pDstDataLen = 0;
5301 }
5302}
5303
5304/******************************************************************************
5305* lim_update_add_ie_buffer()
5306*
5307***FUNCTION:
5308* This function checks the src buffer and length if src buffer length more
5309* than dst buffer length then free the dst buffer and malloc for the new src
5310* length, and update the dst buffer and length. But if dst buffer is bigger
5311* than src buffer length then it just update the dst buffer and length
5312*
5313***LOGIC:
5314*
5315***ASSUMPTIONS:
5316*
5317***NOTE:
5318*
5319* @param pMac Pointer to Global MAC structure
5320* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5321* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5322* @param *pSrcData_buff A pointer of uint8_t src buffer
5323* @param srcDataLen src buffer length
5324******************************************************************************/
5325
5326static void
5327lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5328 uint8_t **pDstData_buff,
5329 uint16_t *pDstDataLen,
5330 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5331{
5332
5333 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005334 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005335 return;
5336 }
5337
5338 if (srcDataLen > *pDstDataLen) {
5339 *pDstDataLen = srcDataLen;
5340 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305341 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005342 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305343 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005344
5345 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005346 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005347 *pDstDataLen = 0;
5348 return;
5349 }
5350 }
5351
5352 /* copy the content of buffer into dst buffer
5353 */
5354 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305355 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005356
5357}
5358
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005359/**
5360 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5361 * @pMac : Pointer to Global MAC structure
5362 * @pDstData_buff : A pointer to pointer of dst buffer
5363 * @pDstDataLen : A pointer to pointer of dst buffer length
5364 * @pModifyIE : A pointer to tSirModifyIE
5365 *
5366 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5367 *
5368 * Return:
5369 * True or false depending upon whether IE is updated or not
5370 */
5371static bool
5372lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5373 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5374{
Hong Shi1553d692016-09-28 12:16:19 +08005375 int32_t oui_length;
5376 uint8_t *ibss_ie = NULL;
5377 uint8_t *vendor_ie;
5378#define MAC_VENDOR_OUI "\x00\x16\x32"
5379#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005380
5381 ibss_ie = pModifyIE->pIEBuffer;
5382 oui_length = pModifyIE->oui_length;
5383
5384 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005385 pe_err("Invalid set IBSS vendor IE command length %d",
5386 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005387 return false;
5388 }
5389
Hong Shi1553d692016-09-28 12:16:19 +08005390 /*
5391 * Why replace only beacon OUI data here:
5392 * 1. other ie (such as wpa) shall not be overwritten here.
5393 * 2. per spec, beacon oui ie might be set twice and original one
5394 * shall be updated.
5395 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005396 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005397 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5398 if (vendor_ie) {
5399 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5400 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5401 pModifyIE->ieBufferlength);
5402 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005403 uint16_t new_length;
5404 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005405
Naveen Rawat668dee32017-09-29 14:39:40 -07005406 /*
5407 * check for uint16 overflow before using sum of two numbers as
5408 * length of size to malloc
5409 */
5410 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5411 pe_err("U16 overflow due to %d + %d",
5412 pModifyIE->ieBufferlength, *pDstDataLen);
5413 return false;
5414 }
5415
5416 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5417 new_ptr = qdf_mem_malloc(new_length);
Hong Shi1553d692016-09-28 12:16:19 +08005418 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005419 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005420 return false;
5421 }
5422 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5423 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5424 pModifyIE->ieBufferlength);
5425 qdf_mem_free(*pDstData_buff);
5426 *pDstDataLen = new_length;
5427 *pDstData_buff = new_ptr;
5428 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005429 return true;
5430}
5431
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005432/*
5433* lim_process_modify_add_ies() - process modify additional IE req.
5434*
5435* @mac_ctx: Pointer to Global MAC structure
5436* @msg_buf: pointer to the SME message buffer
5437*
5438* This function update the PE buffers for additional IEs.
5439*
5440* Return: None
5441*/
5442static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5443 uint32_t *msg_buf)
5444{
5445 tpSirModifyIEsInd modify_add_ies;
5446 tpPESession session_entry;
5447 uint8_t session_id;
5448 bool ret = false;
5449 tSirAddIeParams *add_ie_params;
5450
5451 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005452 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005453 return;
5454 }
5455
5456 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5457 /* Incoming message has smeSession, use BSSID to find PE session */
5458 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005459 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005460
5461 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005462 pe_err("Session not found for given bssid"
5463 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005464 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005465 goto end;
5466 }
5467 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5468 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5469 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005470 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005471 modify_add_ies->modifyIE.pIEBuffer,
5472 modify_add_ies->modifyIE.ieBufferlength,
5473 modify_add_ies->modifyIE.ieID,
5474 modify_add_ies->modifyIE.ieIDLen,
5475 modify_add_ies->updateType);
5476 goto end;
5477 }
5478 add_ie_params = &session_entry->addIeParams;
5479 switch (modify_add_ies->updateType) {
5480 case eUPDATE_IE_PROBE_RESP:
5481 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005482 if (LIM_IS_IBSS_ROLE(session_entry)) {
5483 lim_update_ibss_prop_add_ies(mac_ctx,
5484 &add_ie_params->probeRespData_buff,
5485 &add_ie_params->probeRespDataLen,
5486 &modify_add_ies->modifyIE);
5487 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005488 break;
5489 case eUPDATE_IE_ASSOC_RESP:
5490 /* assoc resp IE */
5491 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305492 QDF_TRACE(QDF_MODULE_ID_PE,
5493 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005494 "assoc resp add ie not present %d"),
5495 add_ie_params->assocRespDataLen);
5496 }
5497 /* search through the buffer and modify the IE */
5498 break;
5499 case eUPDATE_IE_PROBE_BCN:
5500 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005501 if (LIM_IS_IBSS_ROLE(session_entry)) {
5502 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5503 &add_ie_params->probeRespBCNData_buff,
5504 &add_ie_params->probeRespBCNDataLen,
5505 &modify_add_ies->modifyIE);
5506 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005507 if (ret == true && modify_add_ies->modifyIE.notify) {
5508 lim_handle_param_update(mac_ctx,
5509 modify_add_ies->updateType);
5510 }
5511 break;
5512 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005513 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005514 modify_add_ies->updateType);
5515 break;
5516 }
5517end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305518 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005519 modify_add_ies->modifyIE.pIEBuffer = NULL;
5520}
5521
5522/*
5523* lim_process_update_add_ies() - process additional IE update req
5524*
5525* @mac_ctx: Pointer to Global MAC structure
5526* @msg_buf: pointer to the SME message buffer
5527*
5528* This function update the PE buffers for additional IEs.
5529*
5530* Return: None
5531*/
5532static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5533 uint32_t *msg_buf)
5534{
5535 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5536 uint8_t session_id;
5537 tpPESession session_entry;
5538 tSirAddIeParams *addn_ie;
5539 uint16_t new_length = 0;
5540 uint8_t *new_ptr = NULL;
5541 tSirUpdateIE *update_ie;
5542
5543 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005544 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005545 return;
5546 }
5547 update_ie = &update_add_ies->updateIE;
5548 /* incoming message has smeSession, use BSSID to find PE session */
5549 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005550 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005551
5552 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005553 pe_err("Session not found for given bssid"
5554 MAC_ADDRESS_STR,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005555 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005556 goto end;
5557 }
5558 addn_ie = &session_entry->addIeParams;
5559 /* if len is 0, upper layer requested freeing of buffer */
5560 if (0 == update_ie->ieBufferlength) {
5561 switch (update_add_ies->updateType) {
5562 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305563 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005564 addn_ie->probeRespData_buff = NULL;
5565 addn_ie->probeRespDataLen = 0;
5566 break;
5567 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305568 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005569 addn_ie->assocRespData_buff = NULL;
5570 addn_ie->assocRespDataLen = 0;
5571 break;
5572 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305573 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005574 addn_ie->probeRespBCNData_buff = NULL;
5575 addn_ie->probeRespBCNDataLen = 0;
5576
5577 if (update_ie->notify)
5578 lim_handle_param_update(mac_ctx,
5579 update_add_ies->updateType);
5580 break;
5581 default:
5582 break;
5583 }
5584 return;
5585 }
5586 switch (update_add_ies->updateType) {
5587 case eUPDATE_IE_PROBE_RESP:
5588 if (update_ie->append) {
5589 /*
5590 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005591 * with combined length.
5592 * Multiple back to back append commands
5593 * can lead to a huge length.So, check
5594 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005595 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005596 if (addn_ie->probeRespDataLen >
5597 (USHRT_MAX - update_ie->ieBufferlength)) {
5598 pe_err("IE Length overflow, curr:%d, new:%d",
5599 addn_ie->probeRespDataLen,
5600 update_ie->ieBufferlength);
5601 goto end;
5602 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005603 new_length = update_ie->ieBufferlength +
5604 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305605 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005606 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005607 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005608 goto end;
5609 }
5610 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305611 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005612 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305613 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005614 update_ie->pAdditionIEBuffer,
5615 update_ie->ieBufferlength);
5616 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305617 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005618 /* adjust length accordingly */
5619 addn_ie->probeRespDataLen = new_length;
5620 /* save refernece of local buffer in PE session */
5621 addn_ie->probeRespData_buff = new_ptr;
5622 goto end;
5623 }
5624 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5625 &addn_ie->probeRespDataLen,
5626 update_ie->pAdditionIEBuffer,
5627 update_ie->ieBufferlength);
5628 break;
5629 case eUPDATE_IE_ASSOC_RESP:
5630 /* assoc resp IE */
5631 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5632 &addn_ie->assocRespDataLen,
5633 update_ie->pAdditionIEBuffer,
5634 update_ie->ieBufferlength);
5635 break;
5636 case eUPDATE_IE_PROBE_BCN:
5637 /* probe resp Bcn IE */
5638 lim_update_add_ie_buffer(mac_ctx,
5639 &addn_ie->probeRespBCNData_buff,
5640 &addn_ie->probeRespBCNDataLen,
5641 update_ie->pAdditionIEBuffer,
5642 update_ie->ieBufferlength);
5643 if (update_ie->notify)
5644 lim_handle_param_update(mac_ctx,
5645 update_add_ies->updateType);
5646 break;
5647 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005648 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005649 break;
5650 }
5651end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305652 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005653 update_ie->pAdditionIEBuffer = NULL;
5654}
5655
5656/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305657 * send_extended_chan_switch_action_frame()- function to send ECSA
5658 * action frame for each sta connected to SAP/GO and AP in case of
5659 * STA .
5660 * @mac_ctx: pointer to global mac structure
5661 * @new_channel: new channel to switch to.
5662 * @ch_bandwidth: BW of channel to calculate op_class
5663 * @session_entry: pe session
5664 *
5665 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5666 *
5667 * Return: void
5668 */
5669
5670static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5671 uint16_t new_channel, uint8_t ch_bandwidth,
5672 tpPESession session_entry)
5673{
5674 uint16_t op_class;
5675 uint8_t switch_mode = 0, i;
5676 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005677 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305678
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005679 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305680 mac_ctx->scan.countryCodeCurrent,
5681 new_channel,
5682 ch_bandwidth);
5683
5684 if (LIM_IS_AP_ROLE(session_entry) &&
5685 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005686 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305687
gaoleze2920bd2017-03-21 17:38:42 +08005688 switch_count = session_entry->gLimChannelSwitch.switchCount;
5689
Abhishek Singh518323d2015-10-19 17:42:01 +05305690 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005691 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305692 psta =
5693 session_entry->dph.dphHashTable.pDphNodeArray + i;
5694 if (psta && psta->added)
5695 lim_send_extended_chan_switch_action_frame(
5696 mac_ctx,
5697 psta->staAddr,
5698 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005699 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305700 }
5701 } else if (LIM_IS_STA_ROLE(session_entry)) {
5702 lim_send_extended_chan_switch_action_frame(mac_ctx,
5703 session_entry->bssId,
5704 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005705 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305706 }
5707
5708}
5709
5710/**
gaolez76d2a162017-03-21 19:23:58 +08005711 * lim_send_chan_switch_action_frame()- Send an action frame
5712 * containing CSA IE or ECSA IE depending on the connected
5713 * sta capability.
5714 *
5715 * @mac_ctx: pointer to global mac structure
5716 * @new_channel: new channel to switch to.
5717 * @ch_bandwidth: BW of channel to calculate op_class
5718 * @session_entry: pe session
5719 *
5720 * Return: void
5721 */
5722static
5723void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5724 uint16_t new_channel,
5725 uint8_t ch_bandwidth,
5726 tpPESession session_entry)
5727{
5728 uint16_t op_class;
5729 uint8_t switch_mode = 0, i;
5730 uint8_t switch_count;
5731 tpDphHashNode psta;
5732 tpDphHashNode dph_node_array_ptr;
5733
5734 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5735
5736 op_class = wlan_reg_dmn_get_opclass_from_channel(
5737 mac_ctx->scan.countryCodeCurrent,
5738 new_channel, ch_bandwidth);
5739
5740 if (LIM_IS_AP_ROLE(session_entry) &&
5741 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5742 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5743
5744 switch_count = session_entry->gLimChannelSwitch.switchCount;
5745
5746 if (LIM_IS_AP_ROLE(session_entry)) {
5747 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5748 psta = dph_node_array_ptr + i;
5749 if (!(psta && psta->added))
5750 continue;
5751 if (session_entry->lim_non_ecsa_cap_num == 0)
5752 lim_send_extended_chan_switch_action_frame
5753 (mac_ctx, psta->staAddr, switch_mode,
5754 op_class, new_channel, switch_count,
5755 session_entry);
5756 else
5757 lim_send_channel_switch_mgmt_frame
5758 (mac_ctx, psta->staAddr, switch_mode,
5759 new_channel, switch_count,
5760 session_entry);
5761 }
5762 } else if (LIM_IS_STA_ROLE(session_entry)) {
5763 lim_send_extended_chan_switch_action_frame
5764 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5765 new_channel, switch_count, session_entry);
5766 }
5767}
5768
5769/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005770 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5771 *
5772 * @mac_ctx: Pointer to Global MAC structure
5773 * @msg_buf: pointer to the SME message buffer
5774 *
5775 * This function processes SME request messages from HDD or upper layer
5776 * application.
5777 *
5778 * Return: None
5779 */
5780static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5781 uint32_t *msg_buf)
5782{
5783 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5784 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005785 uint8_t session_id;
5786 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005787 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005788
5789 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005790 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005791 return;
5792 }
5793
5794 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5795 session_entry = pe_find_session_by_bssid(mac_ctx,
5796 dfs_csa_ie_req->bssid, &session_id);
5797 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005798 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005799 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5800 return;
5801 }
5802
5803 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005804 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005805 GET_LIM_SYSTEM_ROLE(session_entry));
5806 return;
5807 }
5808
5809 /* target channel */
5810 session_entry->gLimChannelSwitch.primaryChannel =
5811 dfs_csa_ie_req->targetChannel;
5812
5813 /* Channel switch announcement needs to be included in beacon */
5814 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005815 session_entry->gLimChannelSwitch.switchCount =
5816 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005817 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005818 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305819 session_entry->gLimChannelSwitch.sec_ch_offset =
5820 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005821 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005822 session_entry->gLimChannelSwitch.switchMode =
5823 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005824
5825 /*
5826 * Validate if SAP is operating HT or VHT mode and set the Channel
5827 * Switch Wrapper element with the Wide Band Switch subelement.
5828 */
5829 if (true != session_entry->vhtCapability)
5830 goto skip_vht;
5831
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005832 /* Now encode the Wider Ch BW element depending on the ch width */
5833 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005834 switch (dfs_csa_ie_req->ch_params.ch_width) {
5835 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005836 /*
5837 * Wide channel BW sublement in channel wrapper element is not
5838 * required in case of 20 Mhz operation. Currently It is set
5839 * only set in case of 40/80 Mhz Operation.
5840 */
5841 session_entry->dfsIncludeChanWrapperIe = false;
5842 wider_bw_ch_switch->newChanWidth =
5843 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5844 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005845 case CH_WIDTH_40MHZ:
5846 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005847 wider_bw_ch_switch->newChanWidth =
5848 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5849 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005850 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005851 session_entry->dfsIncludeChanWrapperIe = true;
5852 wider_bw_ch_switch->newChanWidth =
5853 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5854 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005855 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005856 session_entry->dfsIncludeChanWrapperIe = true;
5857 wider_bw_ch_switch->newChanWidth =
5858 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5859 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005860 case CH_WIDTH_80P80MHZ:
5861 session_entry->dfsIncludeChanWrapperIe = true;
5862 wider_bw_ch_switch->newChanWidth =
5863 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005864 /*
5865 * This is not applicable for 20/40/80 Mhz.
5866 * Only used when we support 80+80 Mhz operation.
5867 * In case of 80+80 Mhz, this parameter indicates
5868 * center channel frequency index of 80 Mhz channel of
5869 * frequency segment 1.
5870 */
5871 wider_bw_ch_switch->newCenterChanFreq1 =
5872 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005873 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005874 default:
5875 session_entry->dfsIncludeChanWrapperIe = false;
5876 /*
5877 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5878 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5879 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005880 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005881 break;
5882 }
5883 /* Fetch the center channel based on the channel width */
5884 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005885 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005886skip_vht:
5887 /* Send CSA IE request from here */
5888 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5889 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005890 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005891 return;
5892 }
5893
5894 /*
5895 * First beacon update request is sent here, the remaining updates are
5896 * done when the FW responds back after sending the first beacon after
5897 * the template update
5898 */
5899 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305900
5901 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5902 ch_offset = BW80;
5903 else
5904 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5905
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005906 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305907 session_entry->gLimChannelSwitch.switchCount,
5908 session_entry->gLimChannelSwitch.primaryChannel,
5909 session_entry->gLimChannelSwitch.ch_width,
5910 session_entry->dfsIncludeChanWrapperIe,
5911 ch_offset);
5912
gaolez76d2a162017-03-21 19:23:58 +08005913 /* Send ECSA/CSA Action frame after updating the beacon */
5914 if (CHAN_HOP_ALL_BANDS_ENABLE)
5915 lim_send_chan_switch_action_frame(mac_ctx,
5916 session_entry->gLimChannelSwitch.primaryChannel,
5917 ch_offset, session_entry);
5918 else
5919 send_extended_chan_switch_action_frame(mac_ctx,
5920 session_entry->gLimChannelSwitch.primaryChannel,
5921 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005922 session_entry->gLimChannelSwitch.switchCount--;
5923}
5924
5925/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305926 * lim_process_ext_change_channel()- function to send ECSA
5927 * action frame for STA/CLI .
5928 * @mac_ctx: pointer to global mac structure
5929 * @msg: params from sme for new channel.
5930 *
5931 * This function is called to send ECSA frame for STA/CLI.
5932 *
5933 * Return: void
5934 */
5935
5936static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5937 uint32_t *msg)
5938{
5939 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5940 (struct sir_sme_ext_cng_chan_req *) msg;
5941 tpPESession session_entry = NULL;
5942
5943 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005944 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305945 return;
5946 }
5947 session_entry =
5948 pe_find_session_by_sme_session_id(mac_ctx,
5949 ext_chng_channel->session_id);
5950 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005951 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305952 ext_chng_channel->session_id);
5953 return;
5954 }
5955 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005956 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305957 return;
5958 }
5959 send_extended_chan_switch_action_frame(mac_ctx,
5960 ext_chng_channel->new_channel,
5961 0, session_entry);
5962}
5963
5964/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005965 * lim_process_nss_update_request() - process sme nss update req
5966 *
5967 * @mac_ctx: Pointer to Global MAC structure
5968 * @msg_buf: pointer to the SME message buffer
5969 *
5970 * This function processes SME request messages from HDD or upper layer
5971 * application.
5972 *
5973 * Return: None
5974 */
5975static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5976 uint32_t *msg_buf)
5977{
5978 struct sir_nss_update_request *nss_update_req_ptr;
5979 tpPESession session_entry = NULL;
5980
5981 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005982 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005983 return;
5984 }
5985
5986 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305987 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005988 nss_update_req_ptr->vdev_id);
5989 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005990 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005991 nss_update_req_ptr->vdev_id);
5992 return;
5993 }
5994
5995 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005996 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005997 GET_LIM_SYSTEM_ROLE(session_entry));
5998 return;
5999 }
6000
6001 /* populate nss field in the beacon */
6002 session_entry->gLimOperatingMode.present = 1;
6003 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05306004 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
6005
6006 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
6007 (session_entry->ch_width > CH_WIDTH_80MHZ))
6008 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
6009
6010 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
6011
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006012 /* Send nss update request from here */
6013 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6014 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006015 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006016 return;
6017 }
6018
6019 lim_send_beacon_ind(mac_ctx, session_entry);
6020}
6021
6022/**
6023 * lim_process_set_ie_req() - process sme set IE request
6024 *
6025 * @mac_ctx: Pointer to Global MAC structure
6026 * @msg_buf: pointer to the SME message buffer
6027 *
6028 * This function processes SME request messages from HDD or upper layer
6029 * application.
6030 *
6031 * Return: None
6032 */
6033static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6034{
6035 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306036 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006037
6038 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006039 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006040 return;
6041 }
6042
6043 msg = (struct send_extcap_ie *)msg_buf;
6044 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306045 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006046 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006047
6048}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006049
6050#ifdef WLAN_FEATURE_11AX_BSS_COLOR
6051void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6052{
6053 struct sir_set_he_bss_color *bss_color;
6054 tpPESession session_entry = NULL;
6055 tUpdateBeaconParams beacon_params;
6056
6057 if (!msg_buf) {
6058 pe_err("Buffer is Pointing to NULL");
6059 return;
6060 }
6061
6062 bss_color = (struct sir_set_he_bss_color *)msg_buf;
6063 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
6064 bss_color->session_id);
6065 if (!session_entry) {
6066 pe_err("Session not found for given session_id %d",
6067 bss_color->session_id);
6068 return;
6069 }
6070
6071 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6072 pe_err("Invalid SystemRole %d",
6073 GET_LIM_SYSTEM_ROLE(session_entry));
6074 return;
6075 }
6076
6077 if (bss_color->bss_color == session_entry->he_op.bss_color) {
6078 pe_err("No change in BSS color, current BSS color %d",
6079 bss_color->bss_color);
6080 return;
6081 }
6082 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
6083 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
6084 session_entry->he_op.bss_col_disabled = 1;
6085 session_entry->he_bss_color_change.countdown =
6086 BSS_COLOR_SWITCH_COUNTDOWN;
6087 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
6088 session_entry->he_op.bss_color =
6089 session_entry->he_bss_color_change.new_color;
6090 WMI_HEOPS_COLOR_SET(beacon_params.he_ops,
6091 session_entry->he_op.bss_color);
6092 WMI_HEOPS_BSSCOLORDISABLE_SET(beacon_params.he_ops,
6093 session_entry->he_op.bss_col_disabled);
6094 session_entry->bss_color_changing = 1;
6095
6096 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6097 eSIR_SUCCESS) {
6098 pe_err("Unable to set op mode IE in beacon");
6099 return;
6100 }
6101
6102 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
6103}
6104#endif