blob: 3614e37460b725b3f7213a79c245fe8961b105a3 [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
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001729 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301730 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001731 session->vht_config.su_beam_formee,
1732 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001733 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001734 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001735 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001736 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301737 session->force_24ghz_in_ht20 =
1738 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001739 /* cbMode is already merged value of peer and self -
1740 * done by csr in csr_get_cb_mode_from_ies */
1741 session->htSupportedChannelWidthSet =
1742 (sme_join_req->cbMode) ? 1 : 0;
1743 session->htRecommendedTxWidthSet =
1744 session->htSupportedChannelWidthSet;
1745 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1746
1747 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1748 session->ch_center_freq_seg0 =
1749 session->currentOperChannel - 2;
1750 session->ch_width = CH_WIDTH_40MHZ;
1751 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1752 sme_join_req->cbMode) {
1753 session->ch_center_freq_seg0 =
1754 session->currentOperChannel + 2;
1755 session->ch_width = CH_WIDTH_40MHZ;
1756 } else {
1757 session->ch_center_freq_seg0 = 0;
1758 session->ch_width = CH_WIDTH_20MHZ;
1759 }
1760
Naveen Rawataeca1b92017-10-16 16:55:31 -07001761 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1762 lim_update_session_he_capable(mac_ctx, session);
1763 lim_copy_join_req_he_cap(session, sme_join_req);
1764 }
1765
1766
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001767 /* Record if management frames need to be protected */
1768#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001769 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001770 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001771 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001772 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001773#endif
1774
1775#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001776 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001777#endif
1778
1779 /* Copy the SSID from smejoinreq to session entry */
1780 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301781 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001782 session->ssId.length);
1783
1784 /*
1785 * Determin 11r or ESE connection based on input from SME
1786 * which inturn is dependent on the profile the user wants
1787 * to connect to, So input is coming from supplicant
1788 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001789 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001790#ifdef FEATURE_WLAN_ESE
1791 session->isESEconnection = sme_join_req->isESEconnection;
1792#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001793 session->isFastTransitionEnabled =
1794 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001795
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796 session->isFastRoamIniFeatureEnabled =
1797 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001798 session->txLdpcIniFeatureEnabled =
1799 sme_join_req->txLdpcIniFeatureEnabled;
1800
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301801 lim_update_fils_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001802 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1803 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001804 } else {
1805 /*
1806 * Throw an error and return and make
1807 * sure to delete the session.
1808 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001809 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001810 session->bssType);
1811 ret_code = eSIR_SME_INVALID_PARAMETERS;
1812 goto end;
1813 }
1814
1815 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301816 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817 &sme_join_req->addIEScan, sizeof(tSirAddie));
1818
1819 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301820 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001821 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1822
1823 val = sizeof(tLimMlmJoinReq) +
1824 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301825 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826 if (NULL == mlm_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001827 pe_err("AllocateMemory failed for mlmJoinReq");
Nitesh Shah0102cac2016-07-13 14:38:30 +05301828 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1829 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001830 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001831
1832 /* PE SessionId is stored as a part of JoinReq */
1833 mlm_join_req->sessionId = session->peSessionId;
1834
1835 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1836 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1837 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001838 pe_err("couldn't retrieve JoinFailureTimer value"
1839 " setting to default value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001840 mlm_join_req->joinFailureTimeout =
1841 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1842 }
1843
1844 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301845 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001846 (void *)&sme_join_req->operationalRateSet,
1847 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301848 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001849 (void *)&sme_join_req->extendedRateSet,
1850 sizeof(tSirMacRateSet));
1851 /*
1852 * this may not be needed anymore now, as rateSet is now
1853 * included in the session entry and MLM has session context.
1854 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301855 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001856 (void *)&session->rateSet,
1857 sizeof(tSirMacRateSet));
1858
1859 session->encryptType = sme_join_req->UCEncryptionType;
1860
1861 mlm_join_req->bssDescription.length =
1862 session->pLimJoinReq->bssDescription.length;
1863
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301864 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001865 (uint8_t *)
1866 &session->pLimJoinReq->bssDescription.bssId,
1867 session->pLimJoinReq->bssDescription.length + 2);
1868
1869 session->limCurrentBssCaps =
1870 session->pLimJoinReq->bssDescription.capabilityInfo;
1871
1872 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1873 session->currentOperChannel);
1874 local_power_constraint = reg_max;
1875
1876 lim_extract_ap_capability(mac_ctx,
1877 (uint8_t *)
1878 session->pLimJoinReq->bssDescription.ieFields,
1879 lim_get_ielen_from_bss_description(
1880 &session->pLimJoinReq->bssDescription),
1881 &session->limCurrentBssQosCaps,
1882 &session->limCurrentBssPropCap,
1883 &session->gLimCurrentBssUapsd,
1884 &local_power_constraint, session);
1885
Krunal Soni53993f72016-07-08 18:20:03 -07001886 /*
1887 * Once the AP capabilities are available then set the
1888 * beam forming capabilities accordingly.
1889 */
1890 if (session->nss == 1) {
1891 session->vht_config.su_beam_former = 0;
1892 session->vht_config.tx_stbc = 0;
1893 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301894 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001895 }
1896
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001897 session->maxTxPower = lim_get_max_tx_power(reg_max,
1898 local_power_constraint,
1899 mac_ctx->roam.configParam.nTxPowerCap);
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301900
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001901 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301902 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001903
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301904 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1905 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1906 pe_debug("Update MaxTxPower in join Req to %d",
1907 sme_join_req->powerCap.maxTxPower);
1908 }
1909
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001910 if (session->gLimCurrentBssUapsd) {
1911 session->gUapsdPerAcBitmask =
1912 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001913 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001914 session->gUapsdPerAcBitmask);
1915
1916 /* resetting the dynamic uapsd mask */
1917 session->gUapsdPerAcDeliveryEnableMask = 0;
1918 session->gUapsdPerAcTriggerEnableMask = 0;
1919 }
1920
1921 session->limRFBand =
1922 lim_get_rf_band(session->currentOperChannel);
1923
1924 /* Initialize 11h Enable Flag */
1925 if (SIR_BAND_5_GHZ == session->limRFBand) {
1926 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1927 &val) != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001928 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001929 session->lim11hEnable =
1930 WNI_CFG_11H_ENABLED_STADEF;
1931 } else {
1932 session->lim11hEnable = val;
1933 }
1934 } else {
1935 session->lim11hEnable = 0;
1936 }
1937
1938 /*
1939 * To care of the scenario when STA transitions from
1940 * IBSS to Infrastructure mode.
1941 */
1942 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1943
1944 session->limPrevSmeState = session->limSmeState;
1945 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1946 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1947 session->peSessionId,
1948 session->limSmeState));
1949
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001950 /* Indicate whether spectrum management is enabled */
1951 session->spectrumMgtEnabled =
1952 sme_join_req->spectrumMgtIndicator;
1953
1954 /* Enable the spectrum management if this is a DFS channel */
1955 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001956 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001957 session->currentOperChannel))
1958 session->spectrumMgtEnabled = true;
1959
1960 session->isOSENConnection = sme_join_req->isOSENConnection;
1961
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001962 /* Issue LIM_MLM_JOIN_REQ to MLM */
1963 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1964 (uint32_t *) mlm_join_req);
1965 return;
1966
1967 } else {
1968 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001969 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970 mac_ctx->lim.gLimSmeState);
1971 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1972 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1973 session = NULL;
1974 goto end;
1975 }
1976
1977end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301978 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1979 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001980
1981 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301982 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983 sme_join_req = NULL;
1984 if (NULL != session)
1985 session->pLimJoinReq = NULL;
1986 }
1987 if (ret_code != eSIR_SME_SUCCESS) {
1988 if (NULL != session) {
1989 pe_delete_session(mac_ctx, session);
1990 session = NULL;
1991 }
1992 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001993 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001994 sme_session_id, ret_code);
1995 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1996 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1997 sme_transaction_id);
1998}
1999
Amar Singhala297bfa2015-10-15 15:07:29 -07002000uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002001 uint8_t iniTxPower)
2002{
2003 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302004 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002005
Anurag Chouhan6d760662016-02-20 16:05:43 +05302006 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002007 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2008 maxTxPower = txPower;
2009 else if (txPower < MIN_TX_PWR_CAP)
2010 maxTxPower = MIN_TX_PWR_CAP;
2011 else
2012 maxTxPower = MAX_TX_PWR_CAP;
2013
2014 return maxTxPower;
2015}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002016
2017/**
2018 * __lim_process_sme_reassoc_req() - process reassoc req
2019 *
2020 * @mac_ctx: Pointer to Global MAC structure
2021 * @msg_buf: pointer to the SME message buffer
2022 *
2023 * This function is called to process SME_REASSOC_REQ message
2024 * from HDD or upper layer application.
2025 *
2026 * Return: None
2027 */
2028
2029static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2030 uint32_t *msg_buf)
2031{
2032 uint16_t caps;
2033 uint32_t val;
2034 tpSirSmeJoinReq reassoc_req = NULL;
2035 tLimMlmReassocReq *mlm_reassoc_req;
2036 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2037 tpPESession session_entry = NULL;
2038 uint8_t session_id;
2039 uint8_t sme_session_id;
2040 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002041 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002042 uint32_t tele_bcn_en = 0;
2043 uint16_t size;
2044
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002045 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302046 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002047 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002048 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002049
2050 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2051 goto end;
2052 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302053 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002054
2055 if (!lim_is_sme_join_req_valid(mac_ctx,
2056 (tpSirSmeJoinReq)reassoc_req)) {
2057 /*
2058 * Received invalid eWNI_SME_REASSOC_REQ
2059 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002060 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002061
2062 ret_code = eSIR_SME_INVALID_PARAMETERS;
2063 goto end;
2064 }
2065
2066 session_entry = pe_find_session_by_bssid(mac_ctx,
2067 reassoc_req->bssDescription.bssId,
2068 &session_id);
2069 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002070 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002071 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2072 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002073 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002074 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
2075 &sme_session_id, &transaction_id);
2076 session_entry =
2077 pe_find_session_by_sme_session_id(mac_ctx,
2078 sme_session_id);
2079 if (session_entry != NULL)
2080 lim_handle_sme_join_result(mac_ctx,
2081 eSIR_SME_INVALID_PARAMETERS,
2082 eSIR_MAC_UNSPEC_FAILURE_STATUS,
2083 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002084 goto end;
2085 }
2086#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2087 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2088 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2089#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2090 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2091
2092 /* Store the reassoc handle in the session Table */
2093 session_entry->pLimReAssocReq = reassoc_req;
2094
2095 session_entry->dot11mode = reassoc_req->dot11mode;
2096 session_entry->vhtCapability =
2097 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002098
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302099 if (session_entry->vhtCapability) {
2100 if (session_entry->pePersona == QDF_STA_MODE) {
2101 session_entry->vht_config.su_beam_formee =
2102 reassoc_req->vht_config.su_beam_formee;
2103 } else {
2104 reassoc_req->vht_config.su_beam_formee = 0;
2105 }
2106 session_entry->enableVhtpAid =
2107 reassoc_req->enableVhtpAid;
2108 session_entry->enableVhtGid =
2109 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002110 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302111 }
2112
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002113 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302114 session_entry->vhtCapability,
2115 session_entry->vht_config.su_beam_formee,
2116 session_entry->vht_config.su_beam_former);
2117
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002118 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2119 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002120 session_entry->send_smps_action =
2121 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002122 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002123 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002124 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002125 session_entry->send_smps_action,
2126 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002127 /*
2128 * Reassociate request is expected
2129 * in link established state only.
2130 */
2131
2132 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002133 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2134 /*
2135 * May be from 11r FT pre-auth. So lets check it
2136 * before we bail out
2137 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002138 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002139 session_entry->peSessionId);
2140
2141 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302142 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002143 session_entry->limReAssocbssId,
2144 6)) {
2145 lim_print_mac_addr(mac_ctx,
2146 reassoc_req->bssDescription.
2147 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002148 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149 ret_code = eSIR_SME_INVALID_PARAMETERS;
2150 goto end;
2151 }
2152
2153 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2154 session_entry);
2155 return;
2156 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002157 /*
2158 * Should not have received eWNI_SME_REASSOC_REQ
2159 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002160 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002161 session_entry->limSmeState);
2162 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2163
2164 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2165 goto end;
2166 }
2167
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302168 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002169 session_entry->pLimReAssocReq->bssDescription.bssId,
2170 sizeof(tSirMacAddr));
2171
2172 session_entry->limReassocChannelId =
2173 session_entry->pLimReAssocReq->bssDescription.channelId;
2174
2175 session_entry->reAssocHtSupportedChannelWidthSet =
2176 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2177 session_entry->reAssocHtRecommendedTxWidthSet =
2178 session_entry->reAssocHtSupportedChannelWidthSet;
2179 session_entry->reAssocHtSecondaryChannelOffset =
2180 session_entry->pLimReAssocReq->cbMode;
2181
2182 session_entry->limReassocBssCaps =
2183 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2184 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2185 session_entry->currentOperChannel);
2186 local_pwr_constraint = reg_max;
2187
2188 lim_extract_ap_capability(mac_ctx,
2189 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2190 lim_get_ielen_from_bss_description(
2191 &session_entry->pLimReAssocReq->bssDescription),
2192 &session_entry->limReassocBssQosCaps,
2193 &session_entry->limReassocBssPropCap,
2194 &session_entry->gLimCurrentBssUapsd,
2195 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302196 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002197 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302198 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002199 /* Copy the SSID from session entry to local variable */
2200 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302201 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002202 reassoc_req->ssId.ssId,
2203 session_entry->limReassocSSID.length);
2204 if (session_entry->gLimCurrentBssUapsd) {
2205 session_entry->gUapsdPerAcBitmask =
2206 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002207 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002208 session_entry->gUapsdPerAcBitmask);
2209 }
2210
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302211 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002212 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002213 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002214
2215 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2216 goto end;
2217 }
2218
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302219 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002220 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2221
2222 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2223 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002224 eSIR_SUCCESS)
2225 pe_err("could not retrieve ReassocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002226
2227 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002228 eSIR_SUCCESS)
2229 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302230
2231 lim_update_caps_info_for_bss(mac_ctx, &caps,
2232 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002233 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302234
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002235 mlm_reassoc_req->capabilityInfo = caps;
2236
2237 /* Update PE session_id */
2238 mlm_reassoc_req->sessionId = session_id;
2239
2240 /*
2241 * If telescopic beaconing is enabled, set listen interval to
2242 * WNI_CFG_TELE_BCN_MAX_LI
2243 */
2244 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2245 &tele_bcn_en) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002246 pe_err("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002247
2248 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2249
2250 if (tele_bcn_en) {
2251 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2252 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002253 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002254 } else {
2255 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2256 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002257 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002258 }
2259
2260 mlm_reassoc_req->listenInterval = (uint16_t) val;
2261
2262 /* Indicate whether spectrum management is enabled */
2263 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2264
2265 /* Enable the spectrum management if this is a DFS channel */
2266 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002267 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002268 session_entry->currentOperChannel))
2269 session_entry->spectrumMgtEnabled = true;
2270
2271 session_entry->limPrevSmeState = session_entry->limSmeState;
2272 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2273
2274 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2275 session_entry->peSessionId,
2276 session_entry->limSmeState));
2277
2278 lim_post_mlm_message(mac_ctx,
2279 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2280 return;
2281end:
2282 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302283 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002284 if (session_entry)
2285 session_entry->pLimReAssocReq = NULL;
2286 }
2287
2288 if (session_entry) {
2289 /*
2290 * error occurred after we determined the session so extract
2291 * session and transaction info from there
2292 */
2293 sme_session_id = session_entry->smeSessionId;
2294 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002295 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002296 /*
2297 * error occurred before or during the time we determined
2298 * the session so extract the session and transaction info
2299 * from the message
2300 */
2301 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2302 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002303 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002304 /*
2305 * Send Reassoc failure response to host
2306 * (note session_entry may be NULL, but that's OK)
2307 */
2308 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2309 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2310 session_entry, sme_session_id,
2311 transaction_id);
2312}
2313
2314bool send_disassoc_frame = 1;
2315/**
2316 * __lim_process_sme_disassoc_req()
2317 *
2318 ***FUNCTION:
2319 * This function is called to process SME_DISASSOC_REQ message
2320 * from HDD or upper layer application.
2321 *
2322 ***LOGIC:
2323 *
2324 ***ASSUMPTIONS:
2325 *
2326 ***NOTE:
2327 *
2328 * @param pMac Pointer to Global MAC structure
2329 * @param *pMsgBuf A pointer to the SME message buffer
2330 * @return None
2331 */
2332
2333static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2334{
2335 uint16_t disassocTrigger, reasonCode;
2336 tLimMlmDisassocReq *pMlmDisassocReq;
2337 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2338 tSirSmeDisassocReq smeDisassocReq;
2339 tpPESession psessionEntry = NULL;
2340 uint8_t sessionId;
2341 uint8_t smesessionId;
2342 uint16_t smetransactionId;
2343
2344 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002345 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002346 return;
2347 }
2348
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302349 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002350 smesessionId = smeDisassocReq.sessionId;
2351 smetransactionId = smeDisassocReq.transactionId;
2352 if (!lim_is_sme_disassoc_req_valid(pMac,
2353 &smeDisassocReq,
2354 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002355 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002356 if (pMac->lim.gLimRspReqd) {
2357 pMac->lim.gLimRspReqd = false;
2358
2359 retCode = eSIR_SME_INVALID_PARAMETERS;
2360 disassocTrigger = eLIM_HOST_DISASSOC;
2361 goto sendDisassoc;
2362 }
2363
2364 return;
2365 }
2366
2367 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002368 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002369 &sessionId);
2370 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002371 pe_err("session does not exist for given bssId "
2372 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002373 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002374 retCode = eSIR_SME_INVALID_PARAMETERS;
2375 disassocTrigger = eLIM_HOST_DISASSOC;
2376 goto sendDisassoc;
2377 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002378 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2379 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002380 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2381 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002382 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002383
2384#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2385 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2386 0, smeDisassocReq.reasonCode);
2387#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2388
2389 /* Update SME session Id and SME transaction ID */
2390
2391 psessionEntry->smeSessionId = smesessionId;
2392 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002393 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002394 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002395
2396 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2397 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002398 switch (psessionEntry->limSmeState) {
2399 case eLIM_SME_ASSOCIATED_STATE:
2400 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002401 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002402 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002403 psessionEntry->limPrevSmeState =
2404 psessionEntry->limSmeState;
2405 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002406 /* Delete all TDLS peers connected before leaving BSS */
2407 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002408 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2409 psessionEntry->peSessionId,
2410 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002411 break;
2412
2413 case eLIM_SME_WT_DEAUTH_STATE:
2414 /* PE shall still process the DISASSOC_REQ and proceed with
2415 * link tear down even if it had already sent a DEAUTH_IND to
2416 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2417 * its been set when PE entered WT_DEAUTH_STATE.
2418 */
2419 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2420 MTRACE(mac_trace
2421 (pMac, TRACE_CODE_SME_STATE,
2422 psessionEntry->peSessionId,
2423 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002424 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002425 break;
2426
2427 case eLIM_SME_WT_DISASSOC_STATE:
2428 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2429 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2430 * PE can continue processing DISASSOC_REQ and send the response instead
2431 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2432 * for disassoc frame.
2433 *
2434 * It will send a disassoc, which is ok. However, we can use the global flag
2435 * sendDisassoc to not send disassoc frame.
2436 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002437 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002438 break;
2439
2440 case eLIM_SME_JOIN_FAILURE_STATE: {
2441 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002442 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002443 if (pMac->lim.gLimRspReqd) {
2444 retCode = eSIR_SME_SUCCESS;
2445 disassocTrigger = eLIM_HOST_DISASSOC;
2446 goto sendDisassoc;
2447 }
2448 }
2449 break;
2450 default:
2451 /**
2452 * STA is not currently associated.
2453 * Log error and send response to host
2454 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002455 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002456 psessionEntry->limSmeState);
2457 lim_print_sme_state(pMac, LOGE,
2458 psessionEntry->limSmeState);
2459
2460 if (pMac->lim.gLimRspReqd) {
2461 if (psessionEntry->limSmeState !=
2462 eLIM_SME_WT_ASSOC_STATE)
2463 pMac->lim.gLimRspReqd = false;
2464
2465 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2466 disassocTrigger = eLIM_HOST_DISASSOC;
2467 goto sendDisassoc;
2468 }
2469
2470 return;
2471 }
2472
2473 break;
2474
2475 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002476 /* Fall through */
2477 break;
2478
2479 case eLIM_STA_IN_IBSS_ROLE:
2480 default:
2481 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002482 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002483 GET_LIM_SYSTEM_ROLE(psessionEntry));
2484
2485 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2486 disassocTrigger = eLIM_HOST_DISASSOC;
2487 goto sendDisassoc;
2488 } /* end switch (pMac->lim.gLimSystemRole) */
2489
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302490 disassocTrigger = eLIM_HOST_DISASSOC;
2491 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002492
2493 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002494 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002495 send_disassoc_frame = 0;
2496 }
2497 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002498 pe_debug("Sending Disasscoc with disassoc Trigger"
2499 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002500 disassocTrigger, reasonCode);
2501
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302502 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002503 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002504 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002505 return;
2506 }
2507
Anurag Chouhanc5548422016-02-24 18:33:27 +05302508 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002509 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002510
2511 pMlmDisassocReq->reasonCode = reasonCode;
2512 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2513
2514 /* Update PE session ID */
2515 pMlmDisassocReq->sessionId = sessionId;
2516
2517 lim_post_mlm_message(pMac,
2518 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2519 return;
2520
2521sendDisassoc:
2522 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002523 lim_send_sme_disassoc_ntf(pMac,
2524 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002525 retCode,
2526 disassocTrigger,
2527 1, smesessionId, smetransactionId,
2528 psessionEntry);
2529 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002530 lim_send_sme_disassoc_ntf(pMac,
2531 smeDisassocReq.peer_macaddr.bytes,
2532 retCode, disassocTrigger, 1,
2533 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002534
2535} /*** end __lim_process_sme_disassoc_req() ***/
2536
2537/** -----------------------------------------------------------------
2538 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2539
2540 This function is called to process SME_DISASSOC_CNF message
2541 from HDD or upper layer application.
2542
2543 \param pMac - global mac structure
2544 \param pStaDs - station dph hash node
2545 \return none
2546 \sa
2547 ----------------------------------------------------------------- */
2548static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2549{
2550 tSirSmeDisassocCnf smeDisassocCnf;
2551 uint16_t aid;
2552 tpDphHashNode pStaDs;
2553 tpPESession psessionEntry;
2554 uint8_t sessionId;
2555
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302556 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002557 sizeof(struct sSirSmeDisassocCnf));
2558
2559 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002560 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002561 &sessionId);
2562 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002563 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002564 return;
2565 }
2566
2567 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002568 pe_err("received invalid SME_DISASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002569 return;
2570 }
2571#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2572 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2573 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2574 psessionEntry,
2575 (uint16_t) smeDisassocCnf.statusCode, 0);
2576 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2577 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2578 psessionEntry,
2579 (uint16_t) smeDisassocCnf.statusCode, 0);
2580#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2581
2582 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2583 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002584 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2585 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2586 && (psessionEntry->limSmeState !=
2587 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002588 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002589 psessionEntry->limSmeState);
2590 lim_print_sme_state(pMac, LOGE,
2591 psessionEntry->limSmeState);
2592 return;
2593 }
2594 break;
2595
2596 case eLIM_AP_ROLE:
2597 /* Fall through */
2598 break;
2599
2600 case eLIM_STA_IN_IBSS_ROLE:
2601 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002602 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002603 GET_LIM_SYSTEM_ROLE(psessionEntry));
2604
2605 return;
2606 }
2607
2608 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2609 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2610 LIM_IS_AP_ROLE(psessionEntry)) {
2611 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002612 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002613 &psessionEntry->dph.dphHashTable);
2614 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002615 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2616 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002617 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002618 return;
2619 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302620
2621 if ((pStaDs->mlmStaContext.mlmState ==
2622 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2623 (pStaDs->mlmStaContext.mlmState ==
2624 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002625 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002626 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302627 pStaDs->mlmStaContext.mlmState);
2628 return;
2629 }
2630
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002631 /* Delete FT session if there exists one */
2632 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002633 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2634
2635 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002636 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002637 }
2638
2639 return;
2640}
2641
2642/**
2643 * __lim_process_sme_deauth_req() - process sme deauth req
2644 * @mac_ctx: Pointer to Global MAC structure
2645 * @msg_buf: pointer to the SME message buffer
2646 *
2647 * This function is called to process SME_DEAUTH_REQ message
2648 * from HDD or upper layer application.
2649 *
2650 * Return: None
2651 */
2652
2653static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2654 uint32_t *msg_buf)
2655{
2656 uint16_t deauth_trigger, reason_code;
2657 tLimMlmDeauthReq *mlm_deauth_req;
2658 tSirSmeDeauthReq sme_deauth_req;
2659 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2660 tpPESession session_entry;
2661 uint8_t session_id; /* PE sessionId */
2662 uint8_t sme_session_id;
2663 uint16_t sme_transaction_id;
2664
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302665 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002666 sme_session_id = sme_deauth_req.sessionId;
2667 sme_transaction_id = sme_deauth_req.transactionId;
2668
2669 /*
2670 * We need to get a session first but we don't even know
2671 * if the message is correct.
2672 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002673 session_entry = pe_find_session_by_bssid(mac_ctx,
2674 sme_deauth_req.bssid.bytes,
2675 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002676 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002677 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002678 ret_code = eSIR_SME_INVALID_PARAMETERS;
2679 deauth_trigger = eLIM_HOST_DEAUTH;
2680 goto send_deauth;
2681 }
2682
2683 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2684 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002685 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002686 mac_ctx->lim.gLimRspReqd = false;
2687
2688 ret_code = eSIR_SME_INVALID_PARAMETERS;
2689 deauth_trigger = eLIM_HOST_DEAUTH;
2690 goto send_deauth;
2691 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002692 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2693 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002694 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2695 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002696 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002697#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2698 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2699 session_entry, 0, sme_deauth_req.reasonCode);
2700#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2701
2702 /* Update SME session ID and Transaction ID */
2703 session_entry->smeSessionId = sme_session_id;
2704 session_entry->transactionId = sme_transaction_id;
2705
2706 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2707 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002708 switch (session_entry->limSmeState) {
2709 case eLIM_SME_ASSOCIATED_STATE:
2710 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302711 /* Delete all TDLS peers connected before leaving BSS */
2712 lim_delete_tdls_peers(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002713 case eLIM_SME_WT_ASSOC_STATE:
2714 case eLIM_SME_JOIN_FAILURE_STATE:
2715 case eLIM_SME_IDLE_STATE:
2716 session_entry->limPrevSmeState =
2717 session_entry->limSmeState;
2718 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2719 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2720 session_entry->peSessionId,
2721 session_entry->limSmeState));
2722 /* Send Deauthentication request to MLM below */
2723 break;
2724 case eLIM_SME_WT_DEAUTH_STATE:
2725 case eLIM_SME_WT_DISASSOC_STATE:
2726 /*
2727 * PE Recieved a Deauth/Disassoc frame. Normally it get
2728 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2729 * Which means host is also trying to disconnect.
2730 * PE can continue processing DEAUTH_REQ and send
2731 * the response instead of failing the request.
2732 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2733 * was sent for deauth/disassoc frame.
2734 */
2735 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002736 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002737 break;
2738 default:
2739 /*
2740 * STA is not in a state to deauthenticate with
2741 * peer. Log error and send response to host.
2742 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002743 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002744 session_entry->limSmeState);
2745 lim_print_sme_state(mac_ctx, LOGE,
2746 session_entry->limSmeState);
2747
2748 if (mac_ctx->lim.gLimRspReqd) {
2749 mac_ctx->lim.gLimRspReqd = false;
2750
2751 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2752 deauth_trigger = eLIM_HOST_DEAUTH;
2753
wadesong42968e92017-06-08 14:11:21 +08002754 /*
2755 * here we received deauth request from AP so
2756 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2757 * have ISSUED delSta then mlm state should be
2758 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2759 * delBSS rsp then mlm state should be
2760 * eLIM_MLM_IDLE_STATE so the below condition
2761 * captures the state where delSta not done
2762 * and firmware still in connected state.
2763 */
2764 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002765 eLIM_SME_WT_DEAUTH_STATE &&
2766 session_entry->limMlmState !=
2767 eLIM_MLM_IDLE_STATE &&
2768 session_entry->limMlmState !=
2769 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002770 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002771 goto send_deauth;
2772 }
2773 return;
2774 }
2775 break;
2776
2777 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002778 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002779 if (mac_ctx->lim.gLimRspReqd) {
2780 mac_ctx->lim.gLimRspReqd = false;
2781 ret_code = eSIR_SME_INVALID_PARAMETERS;
2782 deauth_trigger = eLIM_HOST_DEAUTH;
2783 goto send_deauth;
2784 }
2785 return;
2786 case eLIM_AP_ROLE:
2787 break;
2788 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002789 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002790 GET_LIM_SYSTEM_ROLE(session_entry));
2791 if (mac_ctx->lim.gLimRspReqd) {
2792 mac_ctx->lim.gLimRspReqd = false;
2793 ret_code = eSIR_SME_INVALID_PARAMETERS;
2794 deauth_trigger = eLIM_HOST_DEAUTH;
2795 goto send_deauth;
2796 }
2797 return;
2798 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2799
2800 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2801 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002802 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002803 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2804 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2805 } else {
2806 deauth_trigger = eLIM_HOST_DEAUTH;
2807 reason_code = sme_deauth_req.reasonCode;
2808 }
2809
2810 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302811 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002812 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002813 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002814 if (mac_ctx->lim.gLimRspReqd) {
2815 mac_ctx->lim.gLimRspReqd = false;
2816 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2817 deauth_trigger = eLIM_HOST_DEAUTH;
2818 goto send_deauth;
2819 }
2820 return;
2821 }
2822
Anurag Chouhanc5548422016-02-24 18:33:27 +05302823 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002824 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002825
2826 mlm_deauth_req->reasonCode = reason_code;
2827 mlm_deauth_req->deauthTrigger = deauth_trigger;
2828
2829 /* Update PE session Id */
2830 mlm_deauth_req->sessionId = session_id;
2831
2832 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2833 (uint32_t *)mlm_deauth_req);
2834 return;
2835
2836send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002837 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2838 ret_code, deauth_trigger, 1,
2839 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002840}
2841
2842/**
2843 * __lim_process_sme_set_context_req()
2844 *
2845 * @mac_ctx: Pointer to Global MAC structure
2846 * @msg_buf: pointer to the SME message buffer
2847 *
2848 * This function is called to process SME_SETCONTEXT_REQ message
2849 * from HDD or upper layer application.
2850 *
2851 * Return: None
2852 */
2853
2854static void
2855__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2856{
2857 tpSirSmeSetContextReq set_context_req;
2858 tLimMlmSetKeysReq *mlm_set_key_req;
2859 tpPESession session_entry;
2860 uint8_t session_id; /* PE sessionID */
2861 uint8_t sme_session_id;
2862 uint16_t sme_transaction_id;
2863
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002864 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002865 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002866 return;
2867 }
2868
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302869 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002870 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002871 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002872 return;
2873 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302874 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002875 sizeof(struct sSirSmeSetContextReq));
2876 sme_session_id = set_context_req->sessionId;
2877 sme_transaction_id = set_context_req->transactionId;
2878
2879 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002880 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002881 goto end;
2882 }
2883
2884 if (set_context_req->keyMaterial.numKeys >
2885 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002886 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002887 set_context_req->keyMaterial.numKeys);
2888 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002889 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002890 eSIR_SME_INVALID_PARAMETERS, NULL,
2891 sme_session_id, sme_transaction_id);
2892 goto end;
2893 }
2894
2895 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002896 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002897 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002898 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002899 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002900 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002901 eSIR_SME_INVALID_PARAMETERS, NULL,
2902 sme_session_id, sme_transaction_id);
2903 goto end;
2904 }
2905#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2906 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2907 session_entry, 0, 0);
2908#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2909
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002910 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002911 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2912 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002913 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002914 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2915 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302916 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002917 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002918 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002919 goto end;
2920 }
2921 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2922 mlm_set_key_req->numKeys =
2923 set_context_req->keyMaterial.numKeys;
2924 if (mlm_set_key_req->numKeys >
2925 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002926 pe_err("no.of keys exceeded max num of default keys limit");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002927 goto end;
2928 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302929 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002930 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002931
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302932 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002933 (uint8_t *) &set_context_req->keyMaterial.key,
2934 sizeof(tSirKeys) *
2935 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2936 numKeys : 1));
2937
2938 mlm_set_key_req->sessionId = session_id;
2939 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002940 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002941 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002942
2943 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2944 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2945 LIM_IS_AP_ROLE(session_entry)) {
2946 if (set_context_req->keyMaterial.key[0].keyLength) {
2947 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002948
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002949 key_id =
2950 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302951 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002952 &session_entry->WEPKeyMaterial[key_id],
2953 (uint8_t *) &set_context_req->keyMaterial,
2954 sizeof(tSirKeyMaterial));
2955 } else {
2956 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002957
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002958 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2959 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302960 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002961 &mlm_set_key_req->key[i],
2962 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2963 sizeof(tSirKeys));
2964 }
2965 }
2966 }
2967 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2968 (uint32_t *) mlm_set_key_req);
2969 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002970 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002971 GET_LIM_SYSTEM_ROLE(session_entry),
2972 session_entry->limSmeState);
2973 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2974
2975 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002976 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002977 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2978 session_entry, sme_session_id,
2979 sme_transaction_id);
2980 }
2981end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302982 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002983 return;
2984}
2985
2986/**
2987 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2988 *
2989 * @mac_ctx: Pointer to Global MAC structure
2990 * @msg_buf: pointer to the SME message buffer
2991 *
2992 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2993 * from HDD or upper layer application.
2994 *
2995 * Return: None
2996 */
2997
Jeff Johnson801f1532016-10-07 07:54:50 -07002998static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2999 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003000{
3001 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3002 tpDphHashNode sta_ds = NULL;
3003 tpPESession session_entry = NULL;
3004 tSap_Event sap_event;
3005 tpWLAN_SAPEventCB sap_event_cb = NULL;
3006 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3007 uint8_t session_id = CSR_SESSION_ID_INVALID;
3008 uint8_t assoc_id = 0;
3009 uint8_t sta_cnt = 0;
3010
3011 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003012 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003013 return;
3014 }
3015
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303016 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003017 sizeof(struct sSirSmeGetAssocSTAsReq));
3018 /*
3019 * Get Associated stations from PE.
3020 * Find PE session Entry
3021 */
3022 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003023 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003024 &session_id);
3025 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003026 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003027 goto lim_assoc_sta_end;
3028 }
3029
3030 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003031 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003032 session_entry->limSmeState,
3033 GET_LIM_SYSTEM_ROLE(session_entry));
3034 goto lim_assoc_sta_end;
3035 }
3036 /* Retrieve values obtained in the request message */
3037 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3038 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3039
3040 if (NULL == assoc_sta_tmp)
3041 goto lim_assoc_sta_end;
3042 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3043 assoc_id++) {
3044 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3045 &session_entry->dph.dphHashTable);
3046 if (NULL == sta_ds)
3047 continue;
3048 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303049 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003050 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303051 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003052 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3053 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3054
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303055 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003056 (uint8_t *)&sta_ds->supportedRates,
3057 sizeof(tSirSupportedRates));
3058 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3059 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3060 assoc_sta_tmp->Support40Mhz =
3061 sta_ds->htDsssCckRate40MHzSupport;
3062
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003063 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003064 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003065 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003066 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003067 pe_debug("Association Id: %d Station Index: %d",
3068 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003069 assoc_sta_tmp++;
3070 sta_cnt++;
3071 }
3072 }
3073lim_assoc_sta_end:
3074 /*
3075 * Call hdd callback with sap event to send the list of
3076 * associated stations from PE
3077 */
3078 if (sap_event_cb != NULL) {
3079 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3080 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303081 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003082 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3083 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3084 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3085 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3086 }
3087}
3088
3089/**
3090 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3091 *
3092 * @mac_ctx: Pointer to Global MAC structure
3093 * @msg_buf: pointer to WPS PBC overlap query message
3094 *
3095 * This function parses get WPS PBC overlap information
3096 * message and call callback to pass WPS PBC overlap
3097 * information back to hdd.
3098 *
3099 * Return: None
3100 */
Jeff Johnson801f1532016-10-07 07:54:50 -07003101static void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3102 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003103{
3104 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3105 tpPESession session_entry = NULL;
3106 tSap_Event sap_event;
3107 tpWLAN_SAPEventCB sap_event_cb = NULL;
3108 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003109 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3110
3111 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003112 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003113 return;
3114 }
3115
3116 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303117 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003118
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303119 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003120 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3121 /*
3122 * Get Associated stations from PE
3123 * Find PE session Entry
3124 */
3125 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003126 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003127 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003128 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003129 goto lim_get_wpspbc_sessions_end;
3130 }
3131
3132 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003133 pe_err("Received unexpected message in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003134 GET_LIM_SYSTEM_ROLE(session_entry));
3135 goto lim_get_wpspbc_sessions_end;
3136 }
3137 /*
3138 * Call hdd callback with sap event to send the
3139 * WPS PBC overlap information
3140 */
3141 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303142 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003143
Anurag Chouhanc5548422016-02-24 18:33:27 +05303144 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003145 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003146 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147 sap_get_wpspbc_event->UUID_E,
3148 &sap_get_wpspbc_event->wpsPBCOverlap,
3149 session_entry);
3150 } else {
3151 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003152 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003153 session_entry);
3154 /* don't have to inform the HDD/Host */
3155 return;
3156 }
3157
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003158 pe_debug("wpsPBCOverlap %d", sap_get_wpspbc_event->wpsPBCOverlap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003159 lim_print_mac_addr(mac_ctx,
Abhishek Singh4294f802017-08-10 16:37:07 +05303160 sap_get_wpspbc_event->addr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003161
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303162 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003163
3164lim_get_wpspbc_sessions_end:
3165 sap_event_cb =
3166 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3167 if (NULL != sap_event_cb)
3168 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3169}
3170
3171/**
3172 * __lim_counter_measures()
3173 *
3174 * FUNCTION:
3175 * This function is called to "implement" MIC counter measure
3176 * and is *temporary* only
3177 *
3178 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3179 * we don't do the proper STA disassoc sequence since the
3180 * BSS will be stoped anyway
3181 *
3182 ***ASSUMPTIONS:
3183 *
3184 ***NOTE:
3185 *
3186 * @param pMac Pointer to Global MAC structure
3187 * @return None
3188 */
3189
3190static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3191{
3192 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003193
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003194 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003195 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3196 mac, psessionEntry, false);
3197};
3198
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003199static void
3200__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3201{
3202 tSirSmeStopBssReq stopBssReq;
3203 tSirRetStatus status;
3204 tLimSmeStates prevState;
3205 tpPESession psessionEntry;
3206 uint8_t smesessionId;
3207 uint8_t sessionId;
3208 uint16_t smetransactionId;
3209 uint8_t i = 0;
3210 tpDphHashNode pStaDs = NULL;
3211
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303212 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003213 smesessionId = stopBssReq.sessionId;
3214 smetransactionId = stopBssReq.transactionId;
3215
3216 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003217 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218 /* Send Stop BSS response to host */
3219 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3220 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3221 smetransactionId);
3222 return;
3223 }
3224
3225 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003226 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003227 &sessionId);
3228 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003229 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003230 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3231 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3232 smetransactionId);
3233 return;
3234 }
3235#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3236 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3237 0, 0);
3238#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3239
3240 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3241 LIM_IS_STA_ROLE(psessionEntry)) {
3242 /**
3243 * Should not have received STOP_BSS_REQ in states
3244 * other than 'normal' state or on STA in Infrastructure
3245 * mode. Log error and return response to host.
3246 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003247 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003248 psessionEntry->limSmeState,
3249 GET_LIM_SYSTEM_ROLE(psessionEntry));
3250 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3251 /* / Send Stop BSS response to host */
3252 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3253 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3254 smetransactionId);
3255 return;
3256 }
3257
3258 if (LIM_IS_AP_ROLE(psessionEntry))
3259 lim_wpspbc_close(pMac, psessionEntry);
3260
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003261 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003262 stopBssReq.reasonCode);
3263
3264 prevState = psessionEntry->limSmeState;
3265
3266 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3267 MTRACE(mac_trace
3268 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3269 psessionEntry->limSmeState));
3270
3271 /* Update SME session Id and Transaction Id */
3272 psessionEntry->smeSessionId = smesessionId;
3273 psessionEntry->transactionId = smetransactionId;
3274
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003275 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3276 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3277 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003278 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003279
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003280 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3281 /* Send disassoc all stations associated thru TKIP */
3282 __lim_counter_measures(pMac, psessionEntry);
3283 else
3284 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003285 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3286 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003287 }
3288
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003289 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3290 /* Free the buffer allocated in START_BSS_REQ */
3291 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3292 psessionEntry->addIeParams.probeRespDataLen = 0;
3293 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003294
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003295 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3296 psessionEntry->addIeParams.assocRespDataLen = 0;
3297 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003298
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003299 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3300 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3301 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003302
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003303 /*
3304 * lim_del_bss is also called as part of coalescing,
3305 * when we send DEL BSS followed by Add Bss msg.
3306 */
3307 pMac->lim.gLimIbssCoalescingHappened = false;
3308 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003309 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3310 pStaDs =
3311 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3312 if (NULL == pStaDs)
3313 continue;
3314 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3315 if (eSIR_SUCCESS == status) {
3316 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3317 pStaDs->assocId, psessionEntry);
3318 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3319 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003320 pe_err("lim_del_sta failed with Status: %d", status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303321 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003322 }
3323 }
3324 /* send a delBss to HAL and wait for a response */
3325 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3326
3327 if (status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003328 pe_err("delBss failed for bss %d", psessionEntry->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003329 psessionEntry->limSmeState = prevState;
3330
3331 MTRACE(mac_trace
3332 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3333 psessionEntry->limSmeState));
3334
3335 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3336 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3337 smetransactionId);
3338 }
3339}
3340
3341/**
3342 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3343 * @pMac: Global MAC context
3344 * @pMsg: Message from SME
3345 *
3346 * Wrapper for the function __lim_handle_sme_stop_bss_request
3347 * This message will be defered until softmac come out of
3348 * scan mode. Message should be handled even if we have
3349 * detected radar in the current operating channel.
3350 *
3351 * Return: true - If we consumed the buffer
3352 * false - If have defered the message.
3353 */
3354
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003355static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3356 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003357{
3358 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3359 /**
3360 * If message defered, buffer is not consumed yet.
3361 * So return false
3362 */
3363 return false;
3364 }
3365 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3366 return true;
3367} /*** end __lim_process_sme_stop_bss_req() ***/
3368
3369void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3370 uint32_t body, tpPESession psessionEntry)
3371{
3372
3373 (void)body;
3374 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3375 lim_ibss_delete(pMac, psessionEntry);
3376 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3377 lim_delete_pre_auth_list(pMac);
3378 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3379 psessionEntry->smeSessionId,
3380 psessionEntry->transactionId);
3381 return;
3382}
3383
3384/**
3385 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3386 *
3387 * @mac_ctx: pointer to mac context
3388 * @msg_type: message type
3389 * @msg_buf: pointer to the SME message buffer
3390 *
3391 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3392 * in BTAMP AP.
3393 *
3394 * Return: None
3395 */
3396
3397void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3398 uint32_t *msg_buf)
3399{
3400 tSirSmeAssocCnf assoc_cnf;
3401 tpDphHashNode sta_ds = NULL;
3402 tpPESession session_entry = NULL;
3403 uint8_t session_id;
3404 tpSirAssocReq assoc_req;
3405
3406 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003407 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003408 goto end;
3409 }
3410
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303411 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003412 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003413 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003414 goto end;
3415 }
3416
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003417 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003418 &session_id);
3419 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003420 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003421 goto end;
3422 }
3423
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003424 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003425 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3426 (session_entry->limSmeState !=
3427 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003428 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003429 msg_type, session_entry->limSmeState,
3430 GET_LIM_SYSTEM_ROLE(session_entry));
3431 goto end;
3432 }
3433 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3434 &session_entry->dph.dphHashTable);
3435 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003436 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003437 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303438 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003439
3440 /*
3441 * send a DISASSOC_IND message to WSM to make sure
3442 * the state in WSM and LIM is the same
3443 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003444 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003445 eSIR_SME_STA_NOT_ASSOCIATED,
3446 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3447 session_entry->smeSessionId,
3448 session_entry->transactionId,
3449 session_entry);
3450 goto end;
3451 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303452 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003453 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303454 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003455 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003456 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303457 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003458 goto end;
3459 }
3460
3461 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3462 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3463 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3464 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3465 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003466 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3467 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003468 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303469 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003470 goto end;
3471 }
3472 /*
3473 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3474 * has been received
3475 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003476 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003477 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3478 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3479
3480 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3481 /*
3482 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3483 * when it had received Assoc Request frame. Now, PE just needs
3484 * to send association rsp frame to the requesting BTAMP-STA.
3485 */
3486 sta_ds->mlmStaContext.mlmState =
3487 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003488 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003489 sta_ds->assocId);
3490 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3491 sta_ds->assocId, sta_ds->staAddr,
3492 sta_ds->mlmStaContext.subType, sta_ds,
3493 session_entry);
3494 goto end;
3495 } else {
3496 /*
3497 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3498 * to be associated since the HAL sta entry is created for
3499 * denied STA we need to remove this HAL entry.
3500 * So to do that set updateContext to 1
3501 */
3502 if (!sta_ds->mlmStaContext.updateContext)
3503 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003504 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003505 assoc_cnf.statusCode, sta_ds->assocId);
3506 lim_reject_association(mac_ctx, sta_ds->staAddr,
3507 sta_ds->mlmStaContext.subType,
3508 true, sta_ds->mlmStaContext.authType,
3509 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003510 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003511 session_entry);
3512 }
3513end:
3514 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3515 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3516 assoc_req = (tpSirAssocReq)
3517 session_entry->parsedAssocReq[sta_ds->assocId];
3518 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303519 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003520 assoc_req->assocReqFrame = NULL;
3521 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303522 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003523 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3524 }
3525}
3526
3527static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3528{
3529 tpDphHashNode pStaDs;
3530 tSirMacAddr peerMac;
3531 tpSirAddtsReq pSirAddts;
3532 uint32_t timeout;
3533 tpPESession psessionEntry;
3534 uint8_t sessionId; /* PE sessionId */
3535 uint8_t smesessionId;
3536 uint16_t smetransactionId;
3537
3538 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003539 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003540 return;
3541 }
3542
3543 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3544 &smetransactionId);
3545
3546 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3547
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003548 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3549 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003550 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003551 pe_err("Session Does not exist for given bssId");
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303552 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3553 NULL, pSirAddts->req.tspec,
3554 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003555 return;
3556 }
3557#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3558 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3559 0);
3560#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3561
3562 /* if sta
3563 * - verify assoc state
3564 * - send addts request to ap
3565 * - wait for addts response from ap
3566 * if ap, just ignore with error log
3567 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003568 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3569 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3570 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003571
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003572 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003573 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303574 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003575 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003576
3577 pStaDs =
3578 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3579 &psessionEntry->dph.dphHashTable);
3580
3581 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003582 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303583 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003584 }
3585
3586 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3587 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003588 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303589 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003590 }
3591
3592 pSirAddts->req.wsmTspecPresent = 0;
3593 pSirAddts->req.wmeTspecPresent = 0;
3594 pSirAddts->req.lleTspecPresent = 0;
3595
3596 if ((pStaDs->wsmEnabled) &&
3597 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3598 SIR_MAC_ACCESSPOLICY_EDCA))
3599 pSirAddts->req.wsmTspecPresent = 1;
3600 else if (pStaDs->wmeEnabled)
3601 pSirAddts->req.wmeTspecPresent = 1;
3602 else if (pStaDs->lleEnabled)
3603 pSirAddts->req.lleTspecPresent = 1;
3604 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003605 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303606 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003607 }
3608
3609 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3610 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003611 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003612 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303613 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003614 }
3615
3616 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003617 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618 pMac->lim.gLimAddtsReq.req.dialogToken,
3619 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3620 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3621 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303622 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003623 }
3624
3625 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3626
3627 /* save the addts request */
3628 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303629 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003630 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3631
3632 /* ship out the message now */
3633 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3634 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303635 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003636 /* start a timer to wait for the response */
3637 if (pSirAddts->timeout)
3638 timeout = pSirAddts->timeout;
3639 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3640 eSIR_SUCCESS) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303641 pe_debug("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003642 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303643 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003644 }
3645
3646 timeout = SYS_MS_TO_TICKS(timeout);
3647 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3648 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003649 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303650 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003651 }
3652 pMac->lim.gLimAddtsRspTimerCount++;
3653 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3654 pMac->lim.gLimAddtsRspTimerCount) !=
3655 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003656 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303657 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003658 }
3659 MTRACE(mac_trace
3660 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3661 eLIM_ADDTS_RSP_TIMER));
3662
3663 /* add the sessionId to the timer object */
3664 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3665 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3666 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003667 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303668 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003669 }
3670 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303671
3672send_failure_addts_rsp:
3673 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3674 psessionEntry, pSirAddts->req.tspec,
3675 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003676}
3677
3678static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3679{
3680 tSirMacAddr peerMacAddr;
3681 uint8_t ac;
3682 tSirMacTSInfo *pTsinfo;
3683 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3684 tpDphHashNode pStaDs = NULL;
3685 tpPESession psessionEntry;
3686 uint8_t sessionId;
3687 uint32_t status = eSIR_SUCCESS;
3688 uint8_t smesessionId;
3689 uint16_t smetransactionId;
3690
3691 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3692 &smetransactionId);
3693
3694 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003695 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003696 &sessionId);
3697 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003698 pe_err("Session Does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003699 status = eSIR_FAILURE;
3700 goto end;
3701 }
3702#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3703 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3704 0);
3705#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3706
3707 if (eSIR_SUCCESS !=
3708 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003709 pe_err("lim_validate_delts_req failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003710 status = eSIR_FAILURE;
3711 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3712 smesessionId, smetransactionId);
3713 return;
3714 }
3715
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003716 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3717 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003718 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3719
3720 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3721 pDeltsReq->req.wmeTspecPresent,
3722 &pDeltsReq->req.tsinfo,
3723 &pDeltsReq->req.tspec, psessionEntry);
3724
3725 pTsinfo =
3726 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3727 tsinfo : &pDeltsReq->req.tsinfo;
3728
3729 /* We've successfully send DELTS frame to AP. Update the
3730 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3731 * is no longer trigger enabled or delivery enabled
3732 */
3733 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3734 pTsinfo, CLEAR_UAPSD_MASK);
3735
3736 /* We're deleting the TSPEC, so this particular AC is no longer
3737 * admitted. PE needs to downgrade the EDCA
3738 * parameters(for the AC for which TS is being deleted) to the
3739 * next best AC for which ACM is not enabled, and send the
3740 * updated values to HAL.
3741 */
3742 ac = upToAc(pTsinfo->traffic.userPrio);
3743
3744 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3745 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3746 ~(1 << ac);
3747 } else if (pTsinfo->traffic.direction ==
3748 SIR_MAC_DIRECTION_DNLINK) {
3749 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3750 ~(1 << ac);
3751 } else if (pTsinfo->traffic.direction ==
3752 SIR_MAC_DIRECTION_BIDIR) {
3753 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3754 ~(1 << ac);
3755 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3756 ~(1 << ac);
3757 }
3758
3759 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3760 psessionEntry);
3761
3762 pStaDs =
3763 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3764 &psessionEntry->dph.dphHashTable);
3765 if (pStaDs != NULL) {
3766 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3767 pStaDs->bssId);
3768 status = eSIR_SUCCESS;
3769 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003770 pe_err("Self entry missing in Hash Table");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003771 status = eSIR_FAILURE;
3772 }
3773#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003774 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003775#endif
3776
3777 /* send an sme response back */
3778end:
3779 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3780 smesessionId, smetransactionId);
3781}
3782
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303783void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003784{
3785 /* fetch the sessionEntry based on the sessionId */
3786 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003787
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003788 psessionEntry = pe_find_session_by_session_id(pMac,
3789 pMac->lim.limTimers.gLimAddtsRspTimer.
3790 sessionId);
3791 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003792 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003793 return;
3794 }
3795
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003796 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003797 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003798 GET_LIM_SYSTEM_ROLE(psessionEntry));
3799 pMac->lim.gLimAddtsSent = false;
3800 return;
3801 }
3802
3803 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003804 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003805 return;
3806 }
3807
3808 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003809 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003810 pMac->lim.gLimAddtsRspTimerCount);
3811 return;
3812 }
3813 /* this a real response timeout */
3814 pMac->lim.gLimAddtsSent = false;
3815 pMac->lim.gLimAddtsRspTimerCount++;
3816
3817 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3818 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3819 psessionEntry->smeSessionId,
3820 psessionEntry->transactionId);
3821}
3822
3823/**
3824 * __lim_process_sme_get_statistics_request()
3825 *
3826 ***FUNCTION:
3827 *
3828 *
3829 ***NOTE:
3830 *
3831 * @param pMac Pointer to Global MAC structure
3832 * @param *pMsgBuf A pointer to the SME message buffer
3833 * @return None
3834 */
3835static void
3836__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3837{
3838 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003839 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003840
3841 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3842
3843 msgQ.type = WMA_GET_STATISTICS_REQ;
3844
3845 msgQ.reserved = 0;
3846 msgQ.bodyptr = pMsgBuf;
3847 msgQ.bodyval = 0;
3848 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3849
3850 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303851 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003852 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003853 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003854 return;
3855 }
3856
3857 return;
3858}
3859
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003860#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003861/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003862 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003863 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003864 * @pMac: Pointer to Global MAC structure
3865 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003866 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003867 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003868 */
3869static void
3870__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3871{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003872 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003873
3874 msgQ.type = WMA_TSM_STATS_REQ;
3875 msgQ.reserved = 0;
3876 msgQ.bodyptr = pMsgBuf;
3877 msgQ.bodyval = 0;
3878 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3879
3880 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303881 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003882 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003883 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003884 return;
3885 }
3886}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003887#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003888
Naveen Rawat8029a402017-06-01 10:54:19 -07003889static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3890 struct update_config *msg)
3891{
3892 tpPESession pe_session;
3893
3894 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3895 if (msg == NULL) {
3896 pe_err("Buffer is Pointing to NULL");
3897 return;
3898 }
3899
3900 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3901 msg->sme_session_id);
3902 if (pe_session == NULL) {
3903 pe_warn("Session does not exist for given BSSID");
3904 return;
3905 }
3906
3907 switch (msg->capab) {
3908 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3909 pe_session->htConfig.ht_rx_ldpc = msg->value;
3910 break;
3911 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3912 pe_session->htConfig.ht_tx_stbc = msg->value;
3913 break;
3914 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3915 pe_session->htConfig.ht_rx_stbc = msg->value;
3916 break;
3917 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3918 pe_session->htConfig.ht_sgi20 = msg->value;
3919 break;
3920 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3921 pe_session->htConfig.ht_sgi40 = msg->value;
3922 break;
3923 }
3924
3925 if (LIM_IS_AP_ROLE(pe_session)) {
3926 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3927 lim_send_beacon_ind(mac_ctx, pe_session);
3928 }
3929}
3930
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003931void
3932lim_send_vdev_restart(tpAniSirGlobal pMac,
3933 tpPESession psessionEntry, uint8_t sessionId)
3934{
3935 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003936 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003937 tSirRetStatus retCode = eSIR_SUCCESS;
3938
3939 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003940 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003941 return;
3942 }
3943
3944 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303945 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003946 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003947 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003948 return;
3949 }
3950
3951 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3952 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003953 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003954
3955 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3956 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3957 msgQ.bodyval = 0;
3958
3959 retCode = wma_post_ctrl_msg(pMac, &msgQ);
3960 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003961 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303962 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003963 }
3964}
3965
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303966/**
3967 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3968 * @mac_ctx: Pointer to Global MAC structure
3969 * @msg_buf: Pointer to SME message buffer
3970 *
3971 * Return: None
3972 */
3973static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3974 uint32_t *msg_buf)
3975{
3976 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003977 struct scheduler_msg wma_msg = {0};
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303978 tSirRetStatus status;
3979 tSirRoamOffloadScanReq *req_buffer;
3980 uint16_t local_ie_len;
3981 uint8_t *local_ie_buf;
3982
3983 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3984 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3985 req_buffer->sessionId);
3986
3987 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3988 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003989 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303990 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303991 return;
3992 }
3993
3994 local_ie_len = req_buffer->assoc_ie.length;
3995 /* Update ext cap IE if present */
3996 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003997 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3998 local_ie_buf, &local_ie_len)) {
3999 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07004000 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
4001 req_buffer->assoc_ie.length = local_ie_len;
4002 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
4003 local_ie_buf, local_ie_len);
4004 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304005 }
4006 qdf_mem_free(local_ie_buf);
4007
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05304008 if (pe_session)
4009 lim_update_fils_rik(pe_session, req_buffer);
4010
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304011 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
4012 wma_msg.bodyptr = req_buffer;
4013
4014 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
4015 if (eSIR_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004016 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304017 qdf_mem_free(req_buffer);
4018 }
4019}
4020
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304021/*
4022 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
4023 * @mac_ctx: Pointer to global mac context
4024 * @session: Pointer to PE session
4025 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
4026 * 1 - Disable broadcast SSID
4027 *
4028 * Return: None
4029 */
4030static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
4031 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004032{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004033 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004034 session->ssidHidden, ssid_hidden);
4035
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004036 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304037 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004038 } else {
4039 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05304040 return;
4041 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004042
4043 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304044 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004045
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004046 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304047}
4048
4049/**
4050 * __lim_process_sme_session_update - process SME session update msg
4051 *
4052 * @mac_ctx: Pointer to global mac context
4053 * @msg_buf: Pointer to the received message buffer
4054 *
4055 * Return: None
4056 */
4057static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
4058 uint32_t *msg_buf)
4059{
4060 struct sir_update_session_param *msg;
4061 tpPESession session;
4062
4063 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004064 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304065 return;
4066 }
4067
4068 msg = (struct sir_update_session_param *) msg_buf;
4069
4070 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
4071 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004072 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304073 msg->session_id);
4074 return;
4075 }
4076
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004077 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304078 msg->param_type, msg->param_val);
4079 switch (msg->param_type) {
4080 case SIR_PARAM_SSID_HIDDEN:
4081 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
4082 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05304083 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
4084 session->ignore_assoc_disallowed = msg->param_val;
4085 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304086 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004087 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304088 break;
4089 }
4090}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004091
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004092/*
4093 Update the beacon Interval dynamically if beaconInterval is different in MCC
4094 */
4095static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4096{
4097 tpSirChangeBIParams pChangeBIParams;
4098 tpPESession psessionEntry;
4099 uint8_t sessionId = 0;
4100 tUpdateBeaconParams beaconParams;
4101
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004102 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004103
4104 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004105 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004106 return;
4107 }
4108
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304109 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004110 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4111
4112 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004113 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004114 &sessionId);
4115 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004116 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004117 return;
4118 }
4119
4120 /*Update sessionEntry Beacon Interval */
4121 if (psessionEntry->beaconParams.beaconInterval !=
4122 pChangeBIParams->beaconInterval) {
4123 psessionEntry->beaconParams.beaconInterval =
4124 pChangeBIParams->beaconInterval;
4125 }
4126
4127 /*Update sch beaconInterval */
4128 if (pMac->sch.schObject.gSchBeaconInterval !=
4129 pChangeBIParams->beaconInterval) {
4130 pMac->sch.schObject.gSchBeaconInterval =
4131 pChangeBIParams->beaconInterval;
4132
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004133 pe_debug("LIM send update BeaconInterval Indication: %d",
4134 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004135
4136 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4137 /* Update beacon */
4138 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4139
4140 beaconParams.bssIdx = psessionEntry->bssIdx;
4141 /* Set change in beacon Interval */
4142 beaconParams.beaconInterval =
4143 pChangeBIParams->beaconInterval;
4144 beaconParams.paramChangeBitmap =
4145 PARAM_BCN_INTERVAL_CHANGED;
4146 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4147 }
4148 }
4149
4150 return;
4151} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4152
4153#ifdef QCA_HT_2040_COEX
4154static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4155 uint32_t *pMsgBuf)
4156{
4157 tpSirSetHT2040Mode pSetHT2040Mode;
4158 tpPESession psessionEntry;
4159 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004160 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004161 tUpdateVHTOpMode *pHtOpMode = NULL;
4162 uint16_t staId = 0;
4163 tpDphHashNode pStaDs = NULL;
4164
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004165 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004166 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004167 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004168 return;
4169 }
4170
4171 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4172
4173 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004174 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004175 &sessionId);
4176 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004177 pe_debug("Session does not exist for given BSSID");
4178 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004179 return;
4180 }
4181
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004182 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004183 pSetHT2040Mode->cbMode);
4184 /*Update sessionEntry HT related fields */
4185 switch (pSetHT2040Mode->cbMode) {
4186 case PHY_SINGLE_CHANNEL_CENTERED:
4187 psessionEntry->htSecondaryChannelOffset =
4188 PHY_SINGLE_CHANNEL_CENTERED;
4189 psessionEntry->htRecommendedTxWidthSet = 0;
4190 if (pSetHT2040Mode->obssEnabled)
4191 psessionEntry->htSupportedChannelWidthSet
4192 = eHT_CHANNEL_WIDTH_40MHZ;
4193 else
4194 psessionEntry->htSupportedChannelWidthSet
4195 = eHT_CHANNEL_WIDTH_20MHZ;
4196 break;
4197 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4198 psessionEntry->htSecondaryChannelOffset =
4199 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4200 psessionEntry->htRecommendedTxWidthSet = 1;
4201 break;
4202 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4203 psessionEntry->htSecondaryChannelOffset =
4204 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4205 psessionEntry->htRecommendedTxWidthSet = 1;
4206 break;
4207 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004208 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004209 return;
4210 }
4211
4212 /* Update beacon */
4213 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4214 lim_send_beacon_ind(pMac, psessionEntry);
4215
4216 /* update OP Mode for each associated peer */
4217 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4218 pStaDs = dph_get_hash_entry(pMac, staId,
4219 &psessionEntry->dph.dphHashTable);
4220 if (NULL == pStaDs)
4221 continue;
4222
4223 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304224 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004225 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004226 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004227 return;
4228 }
4229 pHtOpMode->opMode =
4230 (psessionEntry->htSecondaryChannelOffset ==
4231 PHY_SINGLE_CHANNEL_CENTERED) ?
4232 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4233 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304234 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004235 sizeof(tSirMacAddr));
4236 pHtOpMode->smesessionId = sessionId;
4237
4238 msg.type = WMA_UPDATE_OP_MODE;
4239 msg.reserved = 0;
4240 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004241 if (!QDF_IS_STATUS_SUCCESS
4242 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
4243 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304244 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004245 return;
4246 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004247 pe_debug("Notifed FW about OP mode: %d for staId=%d",
4248 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004249
4250 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004251 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004252 }
4253
4254 return;
4255}
4256#endif
4257
4258/* -------------------------------------------------------------------- */
4259/**
4260 * __lim_process_report_message
4261 *
4262 * FUNCTION: Processes the next received Radio Resource Management message
4263 *
4264 * LOGIC:
4265 *
4266 * ASSUMPTIONS:
4267 *
4268 * NOTE:
4269 *
4270 * @param None
4271 * @return None
4272 */
4273
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004274static void __lim_process_report_message(tpAniSirGlobal pMac,
4275 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004276{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004277 switch (pMsg->type) {
4278 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4279 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4280 break;
4281 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004282 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004283 break;
4284 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004285 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004286 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004287}
4288
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004289/* -------------------------------------------------------------------- */
4290/**
4291 * lim_send_set_max_tx_power_req
4292 *
4293 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4294 *
4295 * LOGIC:
4296 *
4297 * ASSUMPTIONS:
4298 *
4299 * NOTE:
4300 *
4301 * @param txPower txPower to be set.
4302 * @param pSessionEntry session entry.
4303 * @return None
4304 */
4305tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004306lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004307 tpPESession pSessionEntry)
4308{
4309 tpMaxTxPowerParams pMaxTxParams = NULL;
4310 tSirRetStatus retCode = eSIR_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004311 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004312
4313 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004314 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004315 return eSIR_FAILURE;
4316 }
4317
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304318 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004319 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004320 pe_err("Unable to allocate memory for pMaxTxParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004321 return eSIR_MEM_ALLOC_FAILED;
4322
4323 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004324 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304325 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304326 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304327 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004328 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304329 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004330
4331 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4332 msgQ.bodyptr = pMaxTxParams;
4333 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004334 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004335 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4336 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4337 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004338 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304339 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004340 }
4341 return retCode;
4342}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004343
4344/**
4345 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4346 *
4347 * @mac_ctx: Pointer to Global MAC structure
4348 * @msg_buf: pointer to the SME message buffer
4349 *
4350 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4351 * from SME. It Register this information within PE.
4352 *
4353 * Return: None
4354 */
4355static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4356 uint32_t *msg_buf)
4357{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304358 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004359 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4360 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4361 struct mgmt_frm_reg_info *next = NULL;
4362 bool match = false;
4363
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004364 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004365 sme_req->registerFrame, sme_req->frameType,
4366 sme_req->matchLen);
4367 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304368 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304369 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4370 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304371 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004372
4373 while (lim_mgmt_regn != NULL) {
4374 if (lim_mgmt_regn->frameType != sme_req->frameType)
4375 goto skip_match;
4376 if (sme_req->matchLen) {
4377 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304378 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004379 sme_req->matchData,
4380 lim_mgmt_regn->matchLen))) {
4381 /* found match! */
4382 match = true;
4383 break;
4384 }
4385 } else {
4386 /* found match! */
4387 match = true;
4388 break;
4389 }
4390skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304391 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304392 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004393 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304394 (qdf_list_node_t *)lim_mgmt_regn,
4395 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304396 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004397 lim_mgmt_regn = next;
4398 next = NULL;
4399 }
4400 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304401 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004402 if (QDF_STATUS_SUCCESS ==
4403 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004404 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004405 (qdf_list_node_t *)lim_mgmt_regn))
4406 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304407 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004408 }
4409
4410 if (sme_req->registerFrame) {
4411 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304412 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004413 sme_req->matchLen);
4414 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004415 lim_mgmt_regn->frameType = sme_req->frameType;
4416 lim_mgmt_regn->matchLen = sme_req->matchLen;
4417 lim_mgmt_regn->sessionId = sme_req->sessionId;
4418 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304419 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004420 sme_req->matchData,
4421 sme_req->matchLen);
4422 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304423 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004424 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304425 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004426 gLimMgmtFrameRegistratinQueue,
4427 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304428 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004429 &mac_ctx->lim.lim_frame_register_lock);
4430 }
4431 }
4432 return;
4433}
4434
4435static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4436{
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004437 pe_debug("Dereg msgType %d", pMac->lim.gDeferMsgTypeForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004438 pMac->lim.gDeferMsgTypeForNOA = 0;
4439 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4440 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304441 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004442 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4443 }
4444}
4445
4446/**
4447 * lim_process_regd_defd_sme_req_after_noa_start()
4448 *
4449 * mac_ctx: Pointer to Global MAC structure
4450 *
4451 * This function is called to process deferred sme req message
4452 * after noa start.
4453 *
4454 * Return: None
4455 */
4456void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4457{
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004458 pe_debug("Process defd sme req %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004459 mac_ctx->lim.gDeferMsgTypeForNOA);
4460
4461 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4462 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004463 pe_warn("start rcvd from FW when no sme deferred msg pending. Do nothing");
4464 pe_warn("It may happen when NOA start ind and timeout happen at the same time");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004465 return;
4466 }
4467 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4468 case eWNI_SME_SCAN_REQ:
4469 __lim_process_sme_scan_req(mac_ctx,
4470 mac_ctx->lim.gpDefdSmeMsgForNOA);
4471 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004472 case eWNI_SME_JOIN_REQ:
4473 __lim_process_sme_join_req(mac_ctx,
4474 mac_ctx->lim.gpDefdSmeMsgForNOA);
4475 break;
4476 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004477 pe_err("Unknown deferred msg type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004478 mac_ctx->lim.gDeferMsgTypeForNOA);
4479 break;
4480 }
4481 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4482}
4483
4484static void
4485__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4486{
4487 tpSirResetAPCapsChange pResetCapsChange;
4488 tpPESession psessionEntry;
4489 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004490
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004491 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004492 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004493 return;
4494 }
4495
4496 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4497 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004498 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4499 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004500 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004501 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004502 return;
4503 }
4504
4505 psessionEntry->limSentCapsChangeNtf = false;
4506 return;
4507}
4508
4509/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304510 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4511 * indication callback in PE.
4512 * @mac_ptr: Mac pointer
4513 * @msg_buf: Msg pointer containing the callback
4514 *
4515 * This function is used save the Management frame
4516 * indication callback in PE.
4517 *
4518 * Return: None
4519 */
4520static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4521 uint32_t *msg_buf)
4522{
4523 struct sir_sme_mgmt_frame_cb_req *sme_req =
4524 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4525
4526 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004527 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304528 return;
4529 }
4530 if (sme_req->callback)
4531 mac_ctx->mgmt_frame_ind_cb =
4532 (sir_mgmt_frame_ind_callback)sme_req->callback;
4533 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004534 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304535}
4536
4537/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304538 *__lim_process_send_disassoc_frame: function processes disassoc frame
4539 * @mac_ctx: pointer to mac context
4540 * @msg_buf: message buffer
4541 *
4542 * function processes disassoc request received from SME
4543 *
4544 * return: none
4545 */
4546static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4547 uint32_t *msg_buf)
4548{
4549 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4550 tSirRetStatus status;
4551 tpPESession session_entry = NULL;
4552 uint8_t sme_session_id;
4553 uint16_t sme_trans_id;
4554
4555 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004556 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304557 return;
4558 }
4559
4560 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4561 &sme_trans_id);
4562
4563 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4564 &sme_send_disassoc_frame_req,
4565 (uint8_t *)msg_buf);
4566
4567 if ((eSIR_FAILURE == status) ||
4568 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4569 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004570 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304571 return;
4572 }
4573
4574 session_entry = pe_find_session_by_sme_session_id(
4575 mac_ctx, sme_session_id);
4576 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004577 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304578 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4579 return;
4580 }
4581
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004582 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 +05304583 sme_send_disassoc_frame_req.msg_type,
4584 sme_send_disassoc_frame_req.length,
4585 sme_send_disassoc_frame_req.session_id,
4586 sme_send_disassoc_frame_req.trans_id,
4587 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4588 sme_send_disassoc_frame_req.reason,
4589 sme_send_disassoc_frame_req.wait_for_ack);
4590
4591 lim_send_disassoc_mgmt_frame(mac_ctx,
4592 sme_send_disassoc_frame_req.reason,
4593 sme_send_disassoc_frame_req.peer_mac,
4594 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4595}
4596
4597/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004598 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4599 * @mac_ctx: Pointer to Global MAC structure
4600 * @pdev_id: pdev id to set the IE.
4601 * @nss: Nss values to prepare the HT IE.
4602 *
4603 * Prepares the HT IE with self capabilities for different
4604 * Nss values and sends the set HT IE req to FW.
4605 *
4606 * Return: None
4607 */
4608static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4609 uint8_t nss)
4610{
4611 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004612 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004613 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004614 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004615 tHtCaps *p_ht_cap;
4616 int i;
4617
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004618 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004619 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4620 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004621 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004622 return;
4623 }
4624 ie_params->nss = i;
4625 ie_params->pdev_id = pdev_id;
4626 ie_params->ie_type = DOT11_HT_IE;
4627 /* 2 for IE len and EID */
4628 ie_params->ie_len = 2 + sizeof(tHtCaps);
4629 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4630 if (NULL == ie_params->ie_ptr) {
4631 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004632 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004633 return;
4634 }
4635 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4636 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4637 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4638 ie_params->ie_len);
4639
4640 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004641 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4642 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004643 if (NULL == p_ie) {
4644 qdf_mem_free(ie_params->ie_ptr);
4645 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004646 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004647 return;
4648 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004649 p_ht_cap = (tHtCaps *)&p_ie[2];
4650 p_ht_cap->supportedMCSSet[1] = 0;
4651 p_ht_cap->txSTBC = 0;
4652 }
4653
4654 msg.type = WMA_SET_PDEV_IE_REQ;
4655 msg.bodyptr = ie_params;
4656 msg.bodyval = 0;
4657
4658 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4659 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004660 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004661 qdf_mem_free(ie_params->ie_ptr);
4662 qdf_mem_free(ie_params);
4663 return;
4664 }
4665 }
4666}
4667
4668/**
4669 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4670 * @mac_ctx: Pointer to Global MAC structure
4671 * @pdev_id: pdev id to set the IE.
4672 * @nss: Nss values to prepare the VHT IE.
4673 *
4674 * Prepares the VHT IE with self capabilities for different
4675 * Nss values and sends the set VHT IE req to FW.
4676 *
4677 * Return: None
4678 */
4679static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4680 uint8_t nss)
4681{
4682 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004683 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004684 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004685 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004686 tSirMacVHTCapabilityInfo *vht_cap;
4687 int i;
4688 tSirVhtMcsInfo *vht_mcs;
4689
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004690 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004691 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4692 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004693 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004694 return;
4695 }
4696 ie_params->nss = i;
4697 ie_params->pdev_id = pdev_id;
4698 ie_params->ie_type = DOT11_VHT_IE;
4699 /* 2 for IE len and EID */
4700 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4701 sizeof(tSirVhtMcsInfo);
4702 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4703 if (NULL == ie_params->ie_ptr) {
4704 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004705 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004706 return;
4707 }
4708 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4709 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4710 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4711 ie_params->ie_len);
4712
4713 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004714 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4715 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004716 if (NULL == p_ie) {
4717 qdf_mem_free(ie_params->ie_ptr);
4718 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004719 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004720 return;
4721 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004722 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4723 vht_cap->txSTBC = 0;
4724 vht_mcs =
4725 (tSirVhtMcsInfo *)&p_ie[2 +
4726 sizeof(tSirMacVHTCapabilityInfo)];
4727 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4728 vht_mcs->rxHighest =
4729 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4730 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4731 vht_mcs->txHighest =
4732 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4733 }
4734 msg.type = WMA_SET_PDEV_IE_REQ;
4735 msg.bodyptr = ie_params;
4736 msg.bodyval = 0;
4737
4738 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4739 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004740 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004741 qdf_mem_free(ie_params->ie_ptr);
4742 qdf_mem_free(ie_params);
4743 return;
4744 }
4745 }
4746}
4747
4748/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004749 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4750 * @mac_ctx: Pointer to Global MAC structure
4751 * @msg_buf: Pointer to the SME message buffer
4752 *
4753 * This function is called by limProcessMessageQueue(). This function sets the
4754 * VDEV IEs to the FW.
4755 *
4756 * Return: None
4757 */
4758static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4759 uint32_t *msg_buf)
4760{
4761 struct sir_set_vdev_ies_per_band *p_msg =
4762 (struct sir_set_vdev_ies_per_band *)msg_buf;
4763
4764 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004765 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004766 return;
4767 }
4768
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004769 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004770 p_msg->vdev_id);
4771 /* intentionally using NULL here so that self capabilty are sent */
4772 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4773 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004774 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004775}
4776
4777/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004778 * lim_process_set_pdev_IEs() - process the set pdev IE req
4779 * @mac_ctx: Pointer to Global MAC structure
4780 * @msg_buf: Pointer to the SME message buffer
4781 *
4782 * This function is called by limProcessMessageQueue(). This
4783 * function sets the PDEV IEs to the FW.
4784 *
4785 * Return: None
4786 */
4787static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4788{
4789 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4790
4791 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4792
4793 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004794 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004795 return;
4796 }
4797
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004798 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004799 ht_vht_cfg->nss);
4800 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4801
4802 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4803 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4804 ht_vht_cfg->nss);
4805}
4806
4807/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304808 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4809 *
4810 * access policy
4811 * @mac_ctx: pointer to mac context
4812 * @msg: message buffer
4813 *
4814 * function processes vendor IE and access policy from SME and updates PE
4815 *
4816 * session entry
4817 *
4818 * return: none
4819*/
4820static void lim_process_sme_update_access_policy_vendor_ie(
4821 tpAniSirGlobal mac_ctx,
4822 uint32_t *msg)
4823{
4824 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4825 struct sPESession *pe_session_entry;
4826 uint8_t num_bytes;
4827
4828 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004829 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304830 return;
4831 }
4832 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4833 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4834 update_vendor_ie->sme_session_id);
4835
4836 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004837 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304838 update_vendor_ie->sme_session_id);
4839 return;
4840 }
4841 if (pe_session_entry->access_policy_vendor_ie)
4842 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4843
4844 num_bytes = update_vendor_ie->ie[1] + 2;
4845 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4846
4847 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004848 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304849 return;
4850 }
4851 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4852 &update_vendor_ie->ie[0], num_bytes);
4853
4854 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4855}
4856
4857/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004858 * lim_process_sme_req_messages()
4859 *
4860 ***FUNCTION:
4861 * This function is called by limProcessMessageQueue(). This
4862 * function processes SME request messages from HDD or upper layer
4863 * application.
4864 *
4865 ***LOGIC:
4866 *
4867 ***ASSUMPTIONS:
4868 *
4869 ***NOTE:
4870 *
4871 * @param pMac Pointer to Global MAC structure
4872 * @param msgType Indicates the SME message type
4873 * @param *pMsgBuf A pointer to the SME message buffer
4874 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4875 * false - if pMsgBuf is not to be freed.
4876 */
4877
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004878bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4879 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004880{
4881 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
4882 uint32_t *pMsgBuf = pMsg->bodyptr;
4883 tpSirSmeScanReq pScanReq;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004884
4885 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004886 lim_msg_str(pMsg->type), pMsg->type,
4887 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4888 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004889
4890 pScanReq = (tpSirSmeScanReq) pMsgBuf;
4891 /* If no insert NOA required then execute the code below */
4892
4893 switch (pMsg->type) {
4894 case eWNI_SME_SYS_READY_IND:
4895 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4896 break;
4897
4898 case eWNI_SME_START_BSS_REQ:
4899 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4900 break;
4901
4902 case eWNI_SME_SCAN_REQ:
4903 __lim_process_sme_scan_req(pMac, pMsgBuf);
4904 break;
4905
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004906 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4907 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4908 break;
4909 case eWNI_SME_JOIN_REQ:
4910 __lim_process_sme_join_req(pMac, pMsgBuf);
4911 break;
4912
4913 case eWNI_SME_REASSOC_REQ:
4914 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4915 break;
4916
4917 case eWNI_SME_DISASSOC_REQ:
4918 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4919 break;
4920
4921 case eWNI_SME_DISASSOC_CNF:
4922 case eWNI_SME_DEAUTH_CNF:
4923 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4924 break;
4925
4926 case eWNI_SME_DEAUTH_REQ:
4927 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4928 break;
4929
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304930 case eWNI_SME_SEND_DISASSOC_FRAME:
4931 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4932 break;
4933
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004934 case eWNI_SME_SETCONTEXT_REQ:
4935 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4936 break;
4937
4938 case eWNI_SME_STOP_BSS_REQ:
4939 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4940 break;
4941
4942 case eWNI_SME_ASSOC_CNF:
4943 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004944 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004945 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4946 pMsgBuf);
4947 break;
4948
4949 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004950 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004951 __lim_process_sme_addts_req(pMac, pMsgBuf);
4952 break;
4953
4954 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004955 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004956 __lim_process_sme_delts_req(pMac, pMsgBuf);
4957 break;
4958
4959 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004960 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004961 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4962 break;
4963
4964 case eWNI_SME_GET_STATISTICS_REQ:
4965 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4966 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4967 bufConsumed = false;
4968 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004969#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004970 case eWNI_SME_GET_TSM_STATS_REQ:
4971 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4972 bufConsumed = false;
4973 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004974#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004975 case eWNI_SME_GET_ASSOC_STAS_REQ:
4976 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4977 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304978 case eWNI_SME_SESSION_UPDATE_PARAM:
4979 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004980 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304981 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4982 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4983 bufConsumed = false;
4984 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004985 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
4986 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
4987 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004988 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4989 /* Update the beaconInterval */
4990 __lim_process_sme_change_bi(pMac, pMsgBuf);
4991 break;
4992
4993#ifdef QCA_HT_2040_COEX
4994 case eWNI_SME_SET_HT_2040_MODE:
4995 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4996 break;
4997#endif
4998
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004999 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5000 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5001 __lim_process_report_message(pMac, pMsg);
5002 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005003
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005004 case eWNI_SME_FT_PRE_AUTH_REQ:
5005 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5006 break;
5007 case eWNI_SME_FT_UPDATE_KEY:
5008 lim_process_ft_update_key(pMac, pMsgBuf);
5009 break;
5010
5011 case eWNI_SME_FT_AGGR_QOS_REQ:
5012 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5013 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005014
5015 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5016 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5017 break;
5018#ifdef FEATURE_WLAN_TDLS
5019 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5020 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5021 break;
5022 case eWNI_SME_TDLS_ADD_STA_REQ:
5023 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5024 break;
5025 case eWNI_SME_TDLS_DEL_STA_REQ:
5026 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5027 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005028#endif
5029 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5030 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5031 break;
5032
5033 case eWNI_SME_CHANNEL_CHANGE_REQ:
5034 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5035 break;
5036
5037 case eWNI_SME_START_BEACON_REQ:
5038 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5039 break;
5040
5041 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5042 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5043 break;
5044
5045 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5046 lim_process_update_add_ies(pMac, pMsgBuf);
5047 break;
5048
5049 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5050 lim_process_modify_add_ies(pMac, pMsgBuf);
5051 break;
5052 case eWNI_SME_SET_HW_MODE_REQ:
5053 lim_process_set_hw_mode(pMac, pMsgBuf);
5054 break;
5055 case eWNI_SME_NSS_UPDATE_REQ:
5056 lim_process_nss_update_request(pMac, pMsgBuf);
5057 break;
5058 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5059 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5060 break;
5061 case eWNI_SME_SET_IE_REQ:
5062 lim_process_set_ie_req(pMac, pMsgBuf);
5063 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305064 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5065 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5066 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305067 case eWNI_SME_EXT_CHANGE_CHANNEL:
5068 lim_process_ext_change_channel(pMac, pMsgBuf);
5069 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005070 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5071 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5072 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005073 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5074 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005075 break;
5076 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5077 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5078 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07005079 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005080 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005081 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005082 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005083 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305084 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5085 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5086 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07005087 case eWNI_SME_UPDATE_CONFIG:
5088 lim_process_sme_update_config(pMac,
5089 (struct update_config *)pMsgBuf);
5090 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005091 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305092 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005093 pMsg->bodyptr = NULL;
5094 break;
5095 } /* switch (msgType) */
5096
5097 return bufConsumed;
5098} /*** end lim_process_sme_req_messages() ***/
5099
5100/**
5101 * lim_process_sme_start_beacon_req()
5102 *
5103 ***FUNCTION:
5104 * This function is called by limProcessMessageQueue(). This
5105 * function processes SME request messages from HDD or upper layer
5106 * application.
5107 *
5108 ***LOGIC:
5109 *
5110 ***ASSUMPTIONS:
5111 *
5112 ***NOTE:
5113 *
5114 * @param pMac Pointer to Global MAC structure
5115 * @param msgType Indicates the SME message type
5116 * @param *pMsgBuf A pointer to the SME message buffer
5117 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5118 * false - if pMsgBuf is not to be freed.
5119 */
5120static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5121{
5122 tpSirStartBeaconIndication pBeaconStartInd;
5123 tpPESession psessionEntry;
5124 uint8_t sessionId; /* PE sessionID */
5125
5126 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005127 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005128 return;
5129 }
5130
5131 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5132 psessionEntry = pe_find_session_by_bssid(pMac,
5133 pBeaconStartInd->bssid,
5134 &sessionId);
5135 if (psessionEntry == NULL) {
5136 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005137 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005138 return;
5139 }
5140
5141 if (pBeaconStartInd->beaconStartStatus == true) {
5142 /*
5143 * Currently this Indication comes from SAP
5144 * to start Beacon Tx on a DFS channel
5145 * since beaconing has to be done on DFS
5146 * channel only after CAC WAIT is completed.
5147 * On a DFS Channel LIM does not start beacon
5148 * Tx right after the WMA_ADD_BSS_RSP.
5149 */
5150 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05305151 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005152 FL("Start Beacon with ssid %s Ch %d"),
5153 psessionEntry->ssId.ssId,
5154 psessionEntry->currentOperChannel);
5155 lim_send_beacon_ind(pMac, psessionEntry);
5156 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005157 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005158 return;
5159 }
5160}
5161
5162/**
5163 * lim_process_sme_channel_change_request() - process sme ch change req
5164 *
5165 * @mac_ctx: Pointer to Global MAC structure
5166 * @msg_buf: pointer to the SME message buffer
5167 *
5168 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5169 *
5170 * Return: None
5171 */
5172static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5173 uint32_t *msg_buf)
5174{
5175 tpSirChanChangeRequest ch_change_req;
5176 tpPESession session_entry;
5177 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005178 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005179 uint32_t val = 0;
5180
5181 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005182 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005183 return;
5184 }
5185 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5186
5187 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5188 ch_change_req->targetChannel);
5189
5190 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5191 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005192 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005193 return;
5194 }
5195
5196 session_entry = pe_find_session_by_bssid(mac_ctx,
5197 ch_change_req->bssid, &session_id);
5198 if (session_entry == NULL) {
5199 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005200 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005201 return;
5202 }
5203
5204 if (session_entry->currentOperChannel ==
5205 ch_change_req->targetChannel) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005206 pe_err("target CH is same as current CH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005207 return;
5208 }
5209
5210 if (LIM_IS_AP_ROLE(session_entry))
5211 session_entry->channelChangeReasonCode =
5212 LIM_SWITCH_CHANNEL_SAP_DFS;
5213 else
5214 session_entry->channelChangeReasonCode =
5215 LIM_SWITCH_CHANNEL_OPERATION;
5216
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005217 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005218 session_entry->currentOperChannel,
5219 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005220 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005221
5222 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005223 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005224 session_entry->ch_center_freq_seg0 =
5225 ch_change_req->center_freq_seg_0;
5226 session_entry->ch_center_freq_seg1 =
5227 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005228 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005229 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005230 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005231 session_entry->htRecommendedTxWidthSet =
5232 session_entry->htSupportedChannelWidthSet;
5233 session_entry->currentOperChannel =
5234 ch_change_req->targetChannel;
5235 session_entry->limRFBand =
5236 lim_get_rf_band(session_entry->currentOperChannel);
5237 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08005238 if (CHAN_HOP_ALL_BANDS_ENABLE ||
5239 SIR_BAND_5_GHZ == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005240 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5241 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005242 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005243 }
5244
5245 session_entry->lim11hEnable = val;
5246 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305247 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005248 &ch_change_req->operational_rateset,
5249 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305250 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005251 &ch_change_req->extended_rateset,
5252 sizeof(session_entry->extRateSet));
5253 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5254 session_entry->ch_center_freq_seg0,
5255 session_entry->ch_center_freq_seg1,
5256 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07005257 max_tx_pwr, session_entry->peSessionId,
5258 ch_change_req->cac_duration_ms,
5259 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005260}
5261
5262/******************************************************************************
5263* lim_start_bss_update_add_ie_buffer()
5264*
5265***FUNCTION:
5266* This function checks the src buffer and its length and then malloc for
5267* dst buffer update the same
5268*
5269***LOGIC:
5270*
5271***ASSUMPTIONS:
5272*
5273***NOTE:
5274*
5275* @param pMac Pointer to Global MAC structure
5276* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5277* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5278* @param *pSrcData_buff A pointer of uint8_t src buffer
5279* @param srcDataLen src buffer length
5280******************************************************************************/
5281
5282static void
5283lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5284 uint8_t **pDstData_buff,
5285 uint16_t *pDstDataLen,
5286 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5287{
5288
5289 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5290 *pDstDataLen = srcDataLen;
5291
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305292 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005293
5294 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005295 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005296 return;
5297 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305298 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005299 } else {
5300 *pDstData_buff = NULL;
5301 *pDstDataLen = 0;
5302 }
5303}
5304
5305/******************************************************************************
5306* lim_update_add_ie_buffer()
5307*
5308***FUNCTION:
5309* This function checks the src buffer and length if src buffer length more
5310* than dst buffer length then free the dst buffer and malloc for the new src
5311* length, and update the dst buffer and length. But if dst buffer is bigger
5312* than src buffer length then it just update the dst buffer and length
5313*
5314***LOGIC:
5315*
5316***ASSUMPTIONS:
5317*
5318***NOTE:
5319*
5320* @param pMac Pointer to Global MAC structure
5321* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5322* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5323* @param *pSrcData_buff A pointer of uint8_t src buffer
5324* @param srcDataLen src buffer length
5325******************************************************************************/
5326
5327static void
5328lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5329 uint8_t **pDstData_buff,
5330 uint16_t *pDstDataLen,
5331 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5332{
5333
5334 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005335 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005336 return;
5337 }
5338
5339 if (srcDataLen > *pDstDataLen) {
5340 *pDstDataLen = srcDataLen;
5341 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305342 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005343 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305344 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005345
5346 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005347 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005348 *pDstDataLen = 0;
5349 return;
5350 }
5351 }
5352
5353 /* copy the content of buffer into dst buffer
5354 */
5355 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305356 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005357
5358}
5359
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005360/**
5361 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5362 * @pMac : Pointer to Global MAC structure
5363 * @pDstData_buff : A pointer to pointer of dst buffer
5364 * @pDstDataLen : A pointer to pointer of dst buffer length
5365 * @pModifyIE : A pointer to tSirModifyIE
5366 *
5367 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5368 *
5369 * Return:
5370 * True or false depending upon whether IE is updated or not
5371 */
5372static bool
5373lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5374 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5375{
Hong Shi1553d692016-09-28 12:16:19 +08005376 int32_t oui_length;
5377 uint8_t *ibss_ie = NULL;
5378 uint8_t *vendor_ie;
5379#define MAC_VENDOR_OUI "\x00\x16\x32"
5380#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005381
5382 ibss_ie = pModifyIE->pIEBuffer;
5383 oui_length = pModifyIE->oui_length;
5384
5385 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005386 pe_err("Invalid set IBSS vendor IE command length %d",
5387 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005388 return false;
5389 }
5390
Hong Shi1553d692016-09-28 12:16:19 +08005391 /*
5392 * Why replace only beacon OUI data here:
5393 * 1. other ie (such as wpa) shall not be overwritten here.
5394 * 2. per spec, beacon oui ie might be set twice and original one
5395 * shall be updated.
5396 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005397 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005398 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5399 if (vendor_ie) {
5400 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5401 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5402 pModifyIE->ieBufferlength);
5403 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005404 uint16_t new_length;
5405 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005406
Naveen Rawat668dee32017-09-29 14:39:40 -07005407 /*
5408 * check for uint16 overflow before using sum of two numbers as
5409 * length of size to malloc
5410 */
5411 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5412 pe_err("U16 overflow due to %d + %d",
5413 pModifyIE->ieBufferlength, *pDstDataLen);
5414 return false;
5415 }
5416
5417 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5418 new_ptr = qdf_mem_malloc(new_length);
Hong Shi1553d692016-09-28 12:16:19 +08005419 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005420 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005421 return false;
5422 }
5423 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5424 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5425 pModifyIE->ieBufferlength);
5426 qdf_mem_free(*pDstData_buff);
5427 *pDstDataLen = new_length;
5428 *pDstData_buff = new_ptr;
5429 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005430 return true;
5431}
5432
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005433/*
5434* lim_process_modify_add_ies() - process modify additional IE req.
5435*
5436* @mac_ctx: Pointer to Global MAC structure
5437* @msg_buf: pointer to the SME message buffer
5438*
5439* This function update the PE buffers for additional IEs.
5440*
5441* Return: None
5442*/
5443static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5444 uint32_t *msg_buf)
5445{
5446 tpSirModifyIEsInd modify_add_ies;
5447 tpPESession session_entry;
5448 uint8_t session_id;
5449 bool ret = false;
5450 tSirAddIeParams *add_ie_params;
5451
5452 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005453 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005454 return;
5455 }
5456
5457 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5458 /* Incoming message has smeSession, use BSSID to find PE session */
5459 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005460 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005461
5462 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005463 pe_err("Session not found for given bssid"
5464 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005465 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005466 goto end;
5467 }
5468 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5469 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5470 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005471 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005472 modify_add_ies->modifyIE.pIEBuffer,
5473 modify_add_ies->modifyIE.ieBufferlength,
5474 modify_add_ies->modifyIE.ieID,
5475 modify_add_ies->modifyIE.ieIDLen,
5476 modify_add_ies->updateType);
5477 goto end;
5478 }
5479 add_ie_params = &session_entry->addIeParams;
5480 switch (modify_add_ies->updateType) {
5481 case eUPDATE_IE_PROBE_RESP:
5482 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005483 if (LIM_IS_IBSS_ROLE(session_entry)) {
5484 lim_update_ibss_prop_add_ies(mac_ctx,
5485 &add_ie_params->probeRespData_buff,
5486 &add_ie_params->probeRespDataLen,
5487 &modify_add_ies->modifyIE);
5488 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005489 break;
5490 case eUPDATE_IE_ASSOC_RESP:
5491 /* assoc resp IE */
5492 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305493 QDF_TRACE(QDF_MODULE_ID_PE,
5494 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005495 "assoc resp add ie not present %d"),
5496 add_ie_params->assocRespDataLen);
5497 }
5498 /* search through the buffer and modify the IE */
5499 break;
5500 case eUPDATE_IE_PROBE_BCN:
5501 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005502 if (LIM_IS_IBSS_ROLE(session_entry)) {
5503 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5504 &add_ie_params->probeRespBCNData_buff,
5505 &add_ie_params->probeRespBCNDataLen,
5506 &modify_add_ies->modifyIE);
5507 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005508 if (ret == true && modify_add_ies->modifyIE.notify) {
5509 lim_handle_param_update(mac_ctx,
5510 modify_add_ies->updateType);
5511 }
5512 break;
5513 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005514 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005515 modify_add_ies->updateType);
5516 break;
5517 }
5518end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305519 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005520 modify_add_ies->modifyIE.pIEBuffer = NULL;
5521}
5522
5523/*
5524* lim_process_update_add_ies() - process additional IE update req
5525*
5526* @mac_ctx: Pointer to Global MAC structure
5527* @msg_buf: pointer to the SME message buffer
5528*
5529* This function update the PE buffers for additional IEs.
5530*
5531* Return: None
5532*/
5533static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5534 uint32_t *msg_buf)
5535{
5536 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5537 uint8_t session_id;
5538 tpPESession session_entry;
5539 tSirAddIeParams *addn_ie;
5540 uint16_t new_length = 0;
5541 uint8_t *new_ptr = NULL;
5542 tSirUpdateIE *update_ie;
5543
5544 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005545 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005546 return;
5547 }
5548 update_ie = &update_add_ies->updateIE;
5549 /* incoming message has smeSession, use BSSID to find PE session */
5550 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005551 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005552
5553 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005554 pe_err("Session not found for given bssid"
5555 MAC_ADDRESS_STR,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005556 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005557 goto end;
5558 }
5559 addn_ie = &session_entry->addIeParams;
5560 /* if len is 0, upper layer requested freeing of buffer */
5561 if (0 == update_ie->ieBufferlength) {
5562 switch (update_add_ies->updateType) {
5563 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305564 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005565 addn_ie->probeRespData_buff = NULL;
5566 addn_ie->probeRespDataLen = 0;
5567 break;
5568 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305569 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005570 addn_ie->assocRespData_buff = NULL;
5571 addn_ie->assocRespDataLen = 0;
5572 break;
5573 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305574 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005575 addn_ie->probeRespBCNData_buff = NULL;
5576 addn_ie->probeRespBCNDataLen = 0;
5577
5578 if (update_ie->notify)
5579 lim_handle_param_update(mac_ctx,
5580 update_add_ies->updateType);
5581 break;
5582 default:
5583 break;
5584 }
5585 return;
5586 }
5587 switch (update_add_ies->updateType) {
5588 case eUPDATE_IE_PROBE_RESP:
5589 if (update_ie->append) {
5590 /*
5591 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005592 * with combined length.
5593 * Multiple back to back append commands
5594 * can lead to a huge length.So, check
5595 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005596 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005597 if (addn_ie->probeRespDataLen >
5598 (USHRT_MAX - update_ie->ieBufferlength)) {
5599 pe_err("IE Length overflow, curr:%d, new:%d",
5600 addn_ie->probeRespDataLen,
5601 update_ie->ieBufferlength);
5602 goto end;
5603 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005604 new_length = update_ie->ieBufferlength +
5605 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305606 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005607 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005608 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005609 goto end;
5610 }
5611 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305612 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005613 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305614 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005615 update_ie->pAdditionIEBuffer,
5616 update_ie->ieBufferlength);
5617 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305618 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005619 /* adjust length accordingly */
5620 addn_ie->probeRespDataLen = new_length;
5621 /* save refernece of local buffer in PE session */
5622 addn_ie->probeRespData_buff = new_ptr;
5623 goto end;
5624 }
5625 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5626 &addn_ie->probeRespDataLen,
5627 update_ie->pAdditionIEBuffer,
5628 update_ie->ieBufferlength);
5629 break;
5630 case eUPDATE_IE_ASSOC_RESP:
5631 /* assoc resp IE */
5632 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5633 &addn_ie->assocRespDataLen,
5634 update_ie->pAdditionIEBuffer,
5635 update_ie->ieBufferlength);
5636 break;
5637 case eUPDATE_IE_PROBE_BCN:
5638 /* probe resp Bcn IE */
5639 lim_update_add_ie_buffer(mac_ctx,
5640 &addn_ie->probeRespBCNData_buff,
5641 &addn_ie->probeRespBCNDataLen,
5642 update_ie->pAdditionIEBuffer,
5643 update_ie->ieBufferlength);
5644 if (update_ie->notify)
5645 lim_handle_param_update(mac_ctx,
5646 update_add_ies->updateType);
5647 break;
5648 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005649 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005650 break;
5651 }
5652end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305653 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005654 update_ie->pAdditionIEBuffer = NULL;
5655}
5656
5657/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305658 * send_extended_chan_switch_action_frame()- function to send ECSA
5659 * action frame for each sta connected to SAP/GO and AP in case of
5660 * STA .
5661 * @mac_ctx: pointer to global mac structure
5662 * @new_channel: new channel to switch to.
5663 * @ch_bandwidth: BW of channel to calculate op_class
5664 * @session_entry: pe session
5665 *
5666 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5667 *
5668 * Return: void
5669 */
5670
5671static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5672 uint16_t new_channel, uint8_t ch_bandwidth,
5673 tpPESession session_entry)
5674{
5675 uint16_t op_class;
5676 uint8_t switch_mode = 0, i;
5677 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005678 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305679
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005680 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305681 mac_ctx->scan.countryCodeCurrent,
5682 new_channel,
5683 ch_bandwidth);
5684
5685 if (LIM_IS_AP_ROLE(session_entry) &&
5686 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005687 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305688
gaoleze2920bd2017-03-21 17:38:42 +08005689 switch_count = session_entry->gLimChannelSwitch.switchCount;
5690
Abhishek Singh518323d2015-10-19 17:42:01 +05305691 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005692 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305693 psta =
5694 session_entry->dph.dphHashTable.pDphNodeArray + i;
5695 if (psta && psta->added)
5696 lim_send_extended_chan_switch_action_frame(
5697 mac_ctx,
5698 psta->staAddr,
5699 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005700 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305701 }
5702 } else if (LIM_IS_STA_ROLE(session_entry)) {
5703 lim_send_extended_chan_switch_action_frame(mac_ctx,
5704 session_entry->bssId,
5705 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005706 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305707 }
5708
5709}
5710
5711/**
gaolez76d2a162017-03-21 19:23:58 +08005712 * lim_send_chan_switch_action_frame()- Send an action frame
5713 * containing CSA IE or ECSA IE depending on the connected
5714 * sta capability.
5715 *
5716 * @mac_ctx: pointer to global mac structure
5717 * @new_channel: new channel to switch to.
5718 * @ch_bandwidth: BW of channel to calculate op_class
5719 * @session_entry: pe session
5720 *
5721 * Return: void
5722 */
5723static
5724void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5725 uint16_t new_channel,
5726 uint8_t ch_bandwidth,
5727 tpPESession session_entry)
5728{
5729 uint16_t op_class;
5730 uint8_t switch_mode = 0, i;
5731 uint8_t switch_count;
5732 tpDphHashNode psta;
5733 tpDphHashNode dph_node_array_ptr;
5734
5735 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5736
5737 op_class = wlan_reg_dmn_get_opclass_from_channel(
5738 mac_ctx->scan.countryCodeCurrent,
5739 new_channel, ch_bandwidth);
5740
5741 if (LIM_IS_AP_ROLE(session_entry) &&
5742 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5743 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5744
5745 switch_count = session_entry->gLimChannelSwitch.switchCount;
5746
5747 if (LIM_IS_AP_ROLE(session_entry)) {
5748 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5749 psta = dph_node_array_ptr + i;
5750 if (!(psta && psta->added))
5751 continue;
5752 if (session_entry->lim_non_ecsa_cap_num == 0)
5753 lim_send_extended_chan_switch_action_frame
5754 (mac_ctx, psta->staAddr, switch_mode,
5755 op_class, new_channel, switch_count,
5756 session_entry);
5757 else
5758 lim_send_channel_switch_mgmt_frame
5759 (mac_ctx, psta->staAddr, switch_mode,
5760 new_channel, switch_count,
5761 session_entry);
5762 }
5763 } else if (LIM_IS_STA_ROLE(session_entry)) {
5764 lim_send_extended_chan_switch_action_frame
5765 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5766 new_channel, switch_count, session_entry);
5767 }
5768}
5769
5770/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005771 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5772 *
5773 * @mac_ctx: Pointer to Global MAC structure
5774 * @msg_buf: pointer to the SME message buffer
5775 *
5776 * This function processes SME request messages from HDD or upper layer
5777 * application.
5778 *
5779 * Return: None
5780 */
5781static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5782 uint32_t *msg_buf)
5783{
5784 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5785 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005786 uint8_t session_id;
5787 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005788 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005789
5790 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005791 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005792 return;
5793 }
5794
5795 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5796 session_entry = pe_find_session_by_bssid(mac_ctx,
5797 dfs_csa_ie_req->bssid, &session_id);
5798 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005799 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005800 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5801 return;
5802 }
5803
5804 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005805 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005806 GET_LIM_SYSTEM_ROLE(session_entry));
5807 return;
5808 }
5809
5810 /* target channel */
5811 session_entry->gLimChannelSwitch.primaryChannel =
5812 dfs_csa_ie_req->targetChannel;
5813
5814 /* Channel switch announcement needs to be included in beacon */
5815 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005816 session_entry->gLimChannelSwitch.switchCount =
5817 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005818 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005819 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305820 session_entry->gLimChannelSwitch.sec_ch_offset =
5821 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005822 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005823 session_entry->gLimChannelSwitch.switchMode =
5824 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005825
5826 /*
5827 * Validate if SAP is operating HT or VHT mode and set the Channel
5828 * Switch Wrapper element with the Wide Band Switch subelement.
5829 */
5830 if (true != session_entry->vhtCapability)
5831 goto skip_vht;
5832
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005833 /* Now encode the Wider Ch BW element depending on the ch width */
5834 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005835 switch (dfs_csa_ie_req->ch_params.ch_width) {
5836 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005837 /*
5838 * Wide channel BW sublement in channel wrapper element is not
5839 * required in case of 20 Mhz operation. Currently It is set
5840 * only set in case of 40/80 Mhz Operation.
5841 */
5842 session_entry->dfsIncludeChanWrapperIe = false;
5843 wider_bw_ch_switch->newChanWidth =
5844 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5845 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005846 case CH_WIDTH_40MHZ:
5847 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005848 wider_bw_ch_switch->newChanWidth =
5849 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5850 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005851 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005852 session_entry->dfsIncludeChanWrapperIe = true;
5853 wider_bw_ch_switch->newChanWidth =
5854 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5855 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005856 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005857 session_entry->dfsIncludeChanWrapperIe = true;
5858 wider_bw_ch_switch->newChanWidth =
5859 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5860 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005861 case CH_WIDTH_80P80MHZ:
5862 session_entry->dfsIncludeChanWrapperIe = true;
5863 wider_bw_ch_switch->newChanWidth =
5864 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005865 /*
5866 * This is not applicable for 20/40/80 Mhz.
5867 * Only used when we support 80+80 Mhz operation.
5868 * In case of 80+80 Mhz, this parameter indicates
5869 * center channel frequency index of 80 Mhz channel of
5870 * frequency segment 1.
5871 */
5872 wider_bw_ch_switch->newCenterChanFreq1 =
5873 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005874 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005875 default:
5876 session_entry->dfsIncludeChanWrapperIe = false;
5877 /*
5878 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5879 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5880 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005881 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005882 break;
5883 }
5884 /* Fetch the center channel based on the channel width */
5885 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005886 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005887skip_vht:
5888 /* Send CSA IE request from here */
5889 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5890 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005891 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005892 return;
5893 }
5894
5895 /*
5896 * First beacon update request is sent here, the remaining updates are
5897 * done when the FW responds back after sending the first beacon after
5898 * the template update
5899 */
5900 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305901
5902 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5903 ch_offset = BW80;
5904 else
5905 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5906
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005907 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305908 session_entry->gLimChannelSwitch.switchCount,
5909 session_entry->gLimChannelSwitch.primaryChannel,
5910 session_entry->gLimChannelSwitch.ch_width,
5911 session_entry->dfsIncludeChanWrapperIe,
5912 ch_offset);
5913
gaolez76d2a162017-03-21 19:23:58 +08005914 /* Send ECSA/CSA Action frame after updating the beacon */
5915 if (CHAN_HOP_ALL_BANDS_ENABLE)
5916 lim_send_chan_switch_action_frame(mac_ctx,
5917 session_entry->gLimChannelSwitch.primaryChannel,
5918 ch_offset, session_entry);
5919 else
5920 send_extended_chan_switch_action_frame(mac_ctx,
5921 session_entry->gLimChannelSwitch.primaryChannel,
5922 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005923 session_entry->gLimChannelSwitch.switchCount--;
5924}
5925
5926/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305927 * lim_process_ext_change_channel()- function to send ECSA
5928 * action frame for STA/CLI .
5929 * @mac_ctx: pointer to global mac structure
5930 * @msg: params from sme for new channel.
5931 *
5932 * This function is called to send ECSA frame for STA/CLI.
5933 *
5934 * Return: void
5935 */
5936
5937static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5938 uint32_t *msg)
5939{
5940 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5941 (struct sir_sme_ext_cng_chan_req *) msg;
5942 tpPESession session_entry = NULL;
5943
5944 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005945 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305946 return;
5947 }
5948 session_entry =
5949 pe_find_session_by_sme_session_id(mac_ctx,
5950 ext_chng_channel->session_id);
5951 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005952 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305953 ext_chng_channel->session_id);
5954 return;
5955 }
5956 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005957 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305958 return;
5959 }
5960 send_extended_chan_switch_action_frame(mac_ctx,
5961 ext_chng_channel->new_channel,
5962 0, session_entry);
5963}
5964
5965/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005966 * lim_process_nss_update_request() - process sme nss update req
5967 *
5968 * @mac_ctx: Pointer to Global MAC structure
5969 * @msg_buf: pointer to the SME message buffer
5970 *
5971 * This function processes SME request messages from HDD or upper layer
5972 * application.
5973 *
5974 * Return: None
5975 */
5976static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5977 uint32_t *msg_buf)
5978{
5979 struct sir_nss_update_request *nss_update_req_ptr;
5980 tpPESession session_entry = NULL;
5981
5982 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005983 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005984 return;
5985 }
5986
5987 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305988 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005989 nss_update_req_ptr->vdev_id);
5990 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005991 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005992 nss_update_req_ptr->vdev_id);
5993 return;
5994 }
5995
5996 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005997 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005998 GET_LIM_SYSTEM_ROLE(session_entry));
5999 return;
6000 }
6001
6002 /* populate nss field in the beacon */
6003 session_entry->gLimOperatingMode.present = 1;
6004 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05306005 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
6006
6007 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
6008 (session_entry->ch_width > CH_WIDTH_80MHZ))
6009 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
6010
6011 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
6012
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006013 /* Send nss update request from here */
6014 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6015 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006016 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006017 return;
6018 }
6019
6020 lim_send_beacon_ind(mac_ctx, session_entry);
6021}
6022
6023/**
6024 * lim_process_set_ie_req() - process sme set IE request
6025 *
6026 * @mac_ctx: Pointer to Global MAC structure
6027 * @msg_buf: pointer to the SME message buffer
6028 *
6029 * This function processes SME request messages from HDD or upper layer
6030 * application.
6031 *
6032 * Return: None
6033 */
6034static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6035{
6036 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306037 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006038
6039 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006040 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006041 return;
6042 }
6043
6044 msg = (struct send_extcap_ie *)msg_buf;
6045 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306046 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006047 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006048
6049}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006050
6051#ifdef WLAN_FEATURE_11AX_BSS_COLOR
6052void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6053{
6054 struct sir_set_he_bss_color *bss_color;
6055 tpPESession session_entry = NULL;
6056 tUpdateBeaconParams beacon_params;
6057
6058 if (!msg_buf) {
6059 pe_err("Buffer is Pointing to NULL");
6060 return;
6061 }
6062
6063 bss_color = (struct sir_set_he_bss_color *)msg_buf;
6064 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
6065 bss_color->session_id);
6066 if (!session_entry) {
6067 pe_err("Session not found for given session_id %d",
6068 bss_color->session_id);
6069 return;
6070 }
6071
6072 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6073 pe_err("Invalid SystemRole %d",
6074 GET_LIM_SYSTEM_ROLE(session_entry));
6075 return;
6076 }
6077
6078 if (bss_color->bss_color == session_entry->he_op.bss_color) {
6079 pe_err("No change in BSS color, current BSS color %d",
6080 bss_color->bss_color);
6081 return;
6082 }
6083 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
6084 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
6085 session_entry->he_op.bss_col_disabled = 1;
6086 session_entry->he_bss_color_change.countdown =
6087 BSS_COLOR_SWITCH_COUNTDOWN;
6088 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
6089 session_entry->he_op.bss_color =
6090 session_entry->he_bss_color_change.new_color;
6091 WMI_HEOPS_COLOR_SET(beacon_params.he_ops,
6092 session_entry->he_op.bss_color);
6093 WMI_HEOPS_BSSCOLORDISABLE_SET(beacon_params.he_ops,
6094 session_entry->he_op.bss_col_disabled);
6095 session_entry->bss_color_changing = 1;
6096
6097 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6098 eSIR_SUCCESS) {
6099 pe_err("Unable to set op mode IE in beacon");
6100 return;
6101 }
6102
6103 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
6104}
6105#endif