blob: 8eb9e39f5d89853493e93d30587e11e5314b51e4 [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;
557 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700558
559 pe_debug("sending WMA_SYS_READY_IND msg to HAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800560 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
561
562 if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700563 pe_err("wma_post_ctrl_msg failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800564 return true;
565 }
566 return false;
567}
568
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800569/**
570 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
571 *@mac_ctx: Pointer to Global MAC structure
572 *@session: A pointer to session entry
573 *@sme_start_bss_req: Start BSS Request from upper layers.
574 *
575 * This function is used to configure the start bss parameters
576 * in to the session.
577 *
578 * Return: None.
579 */
580static void
581lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
582 tpSirSmeStartBssReq sme_start_bss_req)
583{
584 session->limSystemRole = eLIM_AP_ROLE;
585 session->privacy = sme_start_bss_req->privacy;
586 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
587 session->authType = sme_start_bss_req->authType;
588 /* Store the DTIM period */
589 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
590 /* Enable/disable UAPSD */
591 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530592 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800593 session->proxyProbeRspEn = 0;
594 } else {
595 /*
596 * To detect PBC overlap in SAP WPS mode,
597 * Host handles Probe Requests.
598 */
599 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
600 session->proxyProbeRspEn = 1;
601 else
602 session->proxyProbeRspEn = 0;
603 }
604 session->ssidHidden = sme_start_bss_req->ssidHidden;
605 session->wps_state = sme_start_bss_req->wps_state;
606 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530607 session->vendor_vht_sap =
608 sme_start_bss_req->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800609 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
610 &session->shortSlotTimeSupported);
611 session->isCoalesingInIBSSAllowed =
612 sme_start_bss_req->isCoalesingInIBSSAllowed;
613
Jiachao Wu712d4fd2017-08-23 16:52:34 +0800614 session->beacon_tx_rate = sme_start_bss_req->beacon_tx_rate;
615
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800616}
617
618/**
619 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
620 *@mac_ctx: Pointer to Global MAC structure
621 *@msg_buf: A pointer to the SME message buffer
622 *
623 * This function is called to process SME_START_BSS_REQ message
624 * from HDD or upper layer application.
625 *
626 * Return: None
627 */
628static void
629__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
630{
631 uint16_t size;
632 uint32_t val = 0;
633 tSirRetStatus ret_status;
634 tSirMacChanNum channel_number;
635 tLimMlmStartReq *mlm_start_req = NULL;
636 tpSirSmeStartBssReq sme_start_bss_req = NULL;
637 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
638 /* Flag Used in case of IBSS to Auto generate BSSID. */
639 uint32_t auto_gen_bssid = false;
640 uint8_t session_id;
641 tpPESession session = NULL;
Krunal Sonib37bb352016-12-20 14:12:21 -0800642 uint8_t sme_session_id = 0xFF;
643 uint16_t sme_transaction_id = 0xFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800644 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700645 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800646 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
647
648/* FEATURE_WLAN_DIAG_SUPPORT */
649#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
650 /*
651 * Since the session is not created yet, sending NULL.
652 * The response should have the correct state.
653 */
654 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
655 NULL, 0, 0);
656#endif /* FEATURE_WLAN_DIAG_SUPPORT */
657
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700658 pe_debug("Received START_BSS_REQ");
Krunal Sonib37bb352016-12-20 14:12:21 -0800659 size = sizeof(tSirSmeStartBssReq);
660 sme_start_bss_req = qdf_mem_malloc(size);
661 if (NULL == sme_start_bss_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700662 pe_err("Allocate Memory fail for LimStartBssReq");
Krunal Sonib37bb352016-12-20 14:12:21 -0800663 /* Send failure response to host */
664 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
665 goto free;
666 }
667 qdf_mem_copy(sme_start_bss_req, msg_buf, sizeof(tSirSmeStartBssReq));
668 sme_session_id = sme_start_bss_req->sessionId;
669 sme_transaction_id = sme_start_bss_req->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800670
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800671 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
672 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800673 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
674 sme_start_bss_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700675 pe_warn("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800676 ret_code = eSIR_SME_INVALID_PARAMETERS;
677 goto free;
678 }
679
680 /*
681 * This is the place where PE is going to create a session.
682 * If session is not existed, then create a new session
683 */
684 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800685 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800686 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700687 pe_warn("Session Already exists for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800688 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
689 session = NULL;
690 goto free;
691 } else {
692 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800693 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800694 &session_id, mac_ctx->lim.maxStation,
695 sme_start_bss_req->bssType);
696 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700697 pe_warn("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800698 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
699 goto free;
700 }
701 }
702
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700703 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
704 /* Probe resp add ie */
705 lim_start_bss_update_add_ie_buffer(mac_ctx,
706 &session->addIeParams.probeRespData_buff,
707 &session->addIeParams.probeRespDataLen,
708 sme_start_bss_req->addIeParams.
709 probeRespData_buff,
710 sme_start_bss_req->addIeParams.
711 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800712
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700713 /* Probe Beacon add ie */
714 lim_start_bss_update_add_ie_buffer(mac_ctx,
715 &session->addIeParams.probeRespBCNData_buff,
716 &session->addIeParams.probeRespBCNDataLen,
717 sme_start_bss_req->addIeParams.
718 probeRespBCNData_buff,
719 sme_start_bss_req->addIeParams.
720 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800721
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700722 /* Assoc resp IE */
723 lim_start_bss_update_add_ie_buffer(mac_ctx,
724 &session->addIeParams.assocRespData_buff,
725 &session->addIeParams.assocRespDataLen,
726 sme_start_bss_req->addIeParams.
727 assocRespData_buff,
728 sme_start_bss_req->addIeParams.
729 assocRespDataLen);
730 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800731 /* Store the session related params in newly created session */
732 session->pLimStartBssReq = sme_start_bss_req;
733
734 /* Store PE session_id in session Table */
735 session->peSessionId = session_id;
736
737 /* Store SME session Id in sessionTable */
738 session->smeSessionId = sme_start_bss_req->sessionId;
739
740 session->transactionId = sme_start_bss_req->transactionId;
741
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530742 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743 &(sme_start_bss_req->htConfig),
744 sizeof(session->htConfig));
745
Sandeep Puligilla98917432016-06-10 13:50:28 -0700746 qdf_mem_copy(&(session->vht_config),
747 &(sme_start_bss_req->vht_config),
748 sizeof(session->vht_config));
749
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800750 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800751 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800752
753 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530754 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800755 (uint8_t *) &sme_start_bss_req->ssId,
756 (sme_start_bss_req->ssId.length + 1));
757
758 session->bssType = sme_start_bss_req->bssType;
759
760 session->nwType = sme_start_bss_req->nwType;
761
762 session->beaconParams.beaconInterval =
763 sme_start_bss_req->beaconInterval;
764
765 /* Store the channel number in session Table */
766 session->currentOperChannel =
767 sme_start_bss_req->channelId;
768
769 /* Store Persona */
770 session->pePersona = sme_start_bss_req->bssPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +0530771 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800772 FL("PE PERSONA=%d"), session->pePersona);
773
774 /* Update the phymode */
775 session->gLimPhyMode = sme_start_bss_req->nwType;
776
777 session->maxTxPower =
778 cfg_get_regulatory_max_transmit_power(mac_ctx,
779 session->currentOperChannel);
780 /* Store the dot 11 mode in to the session Table */
781 session->dot11mode = sme_start_bss_req->dot11mode;
782#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
783 session->cc_switch_mode =
784 sme_start_bss_req->cc_switch_mode;
785#endif
786 session->htCapability =
787 IS_DOT11_MODE_HT(session->dot11mode);
788 session->vhtCapability =
789 IS_DOT11_MODE_VHT(session->dot11mode);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800790
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700791 pe_debug("HT[%d], VHT[%d]",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800792 session->htCapability, session->vhtCapability);
793
794 if (IS_DOT11_MODE_HE(session->dot11mode)) {
795 lim_update_session_he_capable(mac_ctx, session);
796 lim_copy_bss_he_cap(session, sme_start_bss_req);
797 }
798
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800799 session->txLdpcIniFeatureEnabled =
800 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800801#ifdef WLAN_FEATURE_11W
802 session->limRmfEnabled =
803 sme_start_bss_req->pmfCapable ? 1 : 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700804 pe_debug("Session RMF enabled: %d", session->limRmfEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800805#endif
806
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530807 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800808 (void *)&sme_start_bss_req->operationalRateSet,
809 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530810 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800811 (void *)&sme_start_bss_req->extendedRateSet,
812 sizeof(tSirMacRateSet));
813
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700814 if (IS_5G_CH(session->currentOperChannel))
815 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
816 else
817 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
818
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800819 switch (sme_start_bss_req->bssType) {
820 case eSIR_INFRA_AP_MODE:
821 lim_configure_ap_start_bss_session(mac_ctx, session,
822 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700823 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700824 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700825 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700826 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800827 break;
828 case eSIR_IBSS_MODE:
829 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
830 lim_get_short_slot_from_phy_mode(mac_ctx, session,
831 session->gLimPhyMode,
832 &session->shortSlotTimeSupported);
833
834 /*
835 * initialize to "OPEN".
836 * will be updated upon key installation
837 */
838 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700839 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800840
841 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700842 case eSIR_NDI_MODE:
843 session->limSystemRole = eLIM_NDI_ROLE;
844 break;
845
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800846
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847 /*
848 * There is one more mode called auto mode.
849 * which is used no where
850 */
851
852 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
853
854 default:
855 /* not used anywhere...used in scan function */
856 break;
857 }
858
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700859 pe_debug("persona - %d, nss - %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700860 session->pePersona, session->vdev_nss);
861 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800862 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700863 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800864 * parsed (Re)Assoc request structure
865 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700866 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800867 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530868 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700869 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800870 if (NULL == session->parsedAssocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700871 pe_warn("AllocateMemory() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800872 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
873 goto free;
874 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800875 }
876
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700877 if (!sme_start_bss_req->channelId &&
878 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700879 pe_err("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800880 ret_code = eSIR_SME_INVALID_PARAMETERS;
881 goto free;
882 }
883 channel_number = sme_start_bss_req->channelId;
884#ifdef QCA_HT_2040_COEX
885 if (sme_start_bss_req->obssEnabled)
886 session->htSupportedChannelWidthSet =
887 session->htCapability;
888 else
889#endif
890 session->htSupportedChannelWidthSet =
891 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
892 session->htSecondaryChannelOffset =
893 sme_start_bss_req->sec_ch_offset;
894 session->htRecommendedTxWidthSet =
895 (session->htSecondaryChannelOffset) ? 1 : 0;
Abhishek Singh4294f802017-08-10 16:37:07 +0530896 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800897 FL("cbMode %u"), sme_start_bss_req->cbMode);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800898 if (lim_is_session_he_capable(session) ||
899 session->vhtCapability || session->htCapability) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800900 chanwidth = sme_start_bss_req->vht_channel_width;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700901 pe_debug("vht_channel_width %u htSupportedChannelWidthSet %d",
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800902 sme_start_bss_req->vht_channel_width,
903 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800904 session->ch_width = chanwidth;
905 if (session->htSupportedChannelWidthSet) {
906 session->ch_center_freq_seg0 =
907 sme_start_bss_req->center_freq_seg0;
908 session->ch_center_freq_seg1 =
909 sme_start_bss_req->center_freq_seg1;
910 } else {
911 session->ch_center_freq_seg0 = 0;
912 session->ch_center_freq_seg1 = 0;
913 }
914 }
915
916 if (session->vhtCapability &&
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800917 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800918 session->nss = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700919 pe_debug("nss set to [%d]", session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700921 pe_debug("vht su tx bformer %d",
Krunal Soni53993f72016-07-08 18:20:03 -0700922 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800923
924 /* Delete pre-auth list if any */
925 lim_delete_pre_auth_list(mac_ctx);
926
Krunal Soni53993f72016-07-08 18:20:03 -0700927 if (session->nss == 1) {
928 session->vht_config.su_beam_former = 0;
929 session->vht_config.tx_stbc = 0;
930 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530931 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -0700932 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800933 /*
934 * keep the RSN/WPA IE information in PE Session Entry
935 * later will be using this to check when received (Re)Assoc req
936 */
937 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
938 &sme_start_bss_req->rsnIE, session);
939
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700940 if (LIM_IS_AP_ROLE(session) ||
941 LIM_IS_IBSS_ROLE(session) ||
942 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800943 session->gLimProtectionControl =
944 sme_start_bss_req->protEnabled;
945 /*
946 * each byte will have the following info
947 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
948 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
949 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530950 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800951 (void *)&sme_start_bss_req->ht_capab,
952 sizeof(uint16_t));
953 /* Initialize WPS PBC session link list */
954 session->pAPWPSPBCSession = NULL;
955 }
956 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530957 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800958 if (NULL == mlm_start_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700959 pe_err("Allocate Memory failed for mlmStartReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800960 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
961 goto free;
962 }
963
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800964 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530965 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800966 (uint8_t *) &sme_start_bss_req->ssId,
967 sme_start_bss_req->ssId.length + 1);
968 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
969 mlm_start_req->obssProtEnabled =
970 sme_start_bss_req->obssProtEnabled;
971
972 mlm_start_req->bssType = session->bssType;
973
974 /* Fill PE session Id from the session Table */
975 mlm_start_req->sessionId = session->peSessionId;
976
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700977 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
978 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800979 /*
980 * Copy the BSSId from sessionTable to
981 * mlmStartReq struct
982 */
983 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
984 } else {
985 /* ibss mode */
986 mac_ctx->lim.gLimIbssCoalescingHappened = false;
987
988 ret_status = wlan_cfg_get_int(mac_ctx,
989 WNI_CFG_IBSS_AUTO_BSSID,
990 &auto_gen_bssid);
991 if (ret_status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700992 pe_err("Get Auto Gen BSSID fail,Status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800993 ret_status);
Abhishek Singh4294f802017-08-10 16:37:07 +0530994 ret_code = eSIR_LOGE_EXCEPTION;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995 goto free;
996 }
997
998 if (!auto_gen_bssid) {
999 /*
1000 * We're not auto generating BSSID.
1001 * Instead, get it from session entry
1002 */
1003 sir_copy_mac_addr(mlm_start_req->bssId,
1004 session->bssId);
1005 /*
1006 * Start IBSS group BSSID
1007 * Auto Generating BSSID.
1008 */
1009 auto_gen_bssid = ((mlm_start_req->bssId[0] &
1010 0x01) ? true : false);
1011 }
1012
1013 if (auto_gen_bssid) {
1014 /*
1015 * if BSSID is not any uc id.
1016 * then use locally generated BSSID.
1017 * Autogenerate the BSSID
1018 */
1019 lim_get_random_bssid(mac_ctx,
1020 mlm_start_req->bssId);
1021 mlm_start_req->bssId[0] = 0x02;
1022
1023 /*
1024 * Copy randomly generated BSSID
1025 * to the session Table
1026 */
1027 sir_copy_mac_addr(session->bssId,
1028 mlm_start_req->bssId);
1029 }
1030 }
1031 /* store the channel num in mlmstart req structure */
1032 mlm_start_req->channelNumber = session->currentOperChannel;
1033 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
1034 mlm_start_req->beaconPeriod =
1035 session->beaconParams.beaconInterval;
Arif Hussain671a1902017-03-17 09:08:32 -07001036 mlm_start_req->cac_duration_ms =
1037 sme_start_bss_req->cac_duration_ms;
1038 mlm_start_req->dfs_regdomain =
1039 sme_start_bss_req->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 if (LIM_IS_AP_ROLE(session)) {
1041 mlm_start_req->dtimPeriod = session->dtimPeriod;
1042 mlm_start_req->wps_state = session->wps_state;
1043
1044 } else {
1045 if (wlan_cfg_get_int(mac_ctx,
1046 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001047 pe_err("could not retrieve DTIM Period");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048 mlm_start_req->dtimPeriod = (uint8_t) val;
1049 }
1050
1051 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
1052 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001053 pe_err("could not retrieve Beacon interval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001054 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
1055
1056 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
1057 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001058 pe_err("could not retrieve CFPMaxDuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001059 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1060
1061 /*
1062 * this may not be needed anymore now,
1063 * as rateSet is now included in the
1064 * session entry and MLM has session context.
1065 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301066 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001067 (void *)&session->rateSet,
1068 sizeof(tSirMacRateSet));
1069
1070 /* Now populate the 11n related parameters */
1071 mlm_start_req->nwType = session->nwType;
1072 mlm_start_req->htCapable = session->htCapability;
1073
1074 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1075 /* Unused */
1076 mlm_start_req->dualCTSProtection =
1077 mac_ctx->lim.gHTDualCTSProtection;
1078 mlm_start_req->txChannelWidthSet =
1079 session->htRecommendedTxWidthSet;
1080
1081 session->limRFBand = lim_get_rf_band(channel_number);
1082
1083 /* Initialize 11h Enable Flag */
1084 session->lim11hEnable = 0;
gaolez76d2a162017-03-21 19:23:58 +08001085 if (mlm_start_req->bssType != eSIR_IBSS_MODE &&
1086 (CHAN_HOP_ALL_BANDS_ENABLE ||
1087 SIR_BAND_5_GHZ == session->limRFBand)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001088 if (wlan_cfg_get_int(mac_ctx,
1089 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001090 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001091 else
1092 session->lim11hEnable = val;
1093
1094 if (session->lim11hEnable &&
1095 (eSIR_INFRA_AP_MODE ==
1096 mlm_start_req->bssType)) {
1097 cfg_get_wmi_dfs_master_param =
1098 wlan_cfg_get_int(mac_ctx,
1099 WNI_CFG_DFS_MASTER_ENABLED,
1100 &val);
1101 session->lim11hEnable = val;
1102 }
1103 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1104 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001105 pe_err("Get Fail, CFG DFS ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001106 }
1107
1108 if (!session->lim11hEnable) {
1109 if (cfg_set_int(mac_ctx,
1110 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1111 eSIR_SUCCESS)
1112 /*
1113 * Failed to set the CFG param
1114 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1115 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001116 pe_err("Set LOCAL_POWER_CONSTRAINT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001117 }
1118
Jiachao Wu712d4fd2017-08-23 16:52:34 +08001119 mlm_start_req->beacon_tx_rate = session->beacon_tx_rate;
1120
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001121 session->limPrevSmeState = session->limSmeState;
1122 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1123 MTRACE(mac_trace
1124 (mac_ctx, TRACE_CODE_SME_STATE,
1125 session->peSessionId,
1126 session->limSmeState));
1127
1128 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1129 (uint32_t *) mlm_start_req);
1130 return;
1131 } else {
1132
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001133 pe_err("Received unexpected START_BSS_REQ, in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001134 mac_ctx->lim.gLimSmeState);
1135 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001136 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001137 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1138
1139free:
1140 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001141 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001142 session->pLimStartBssReq = NULL;
1143 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001144 if (NULL != sme_start_bss_req)
1145 qdf_mem_free(sme_start_bss_req);
1146 if (NULL != mlm_start_req)
1147 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001148 if (NULL != session) {
1149 pe_delete_session(mac_ctx, session);
1150 session = NULL;
1151 }
1152 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1153 session, sme_session_id, sme_transaction_id);
1154}
1155
1156/**
1157 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1158 *
1159 * @pMac: Global MAC context
1160 * @pMsg: Message pointer
1161 *
1162 * Wrapper for the function __lim_handle_sme_start_bss_request
1163 * This message will be defered until softmac come out of
1164 * scan mode or if we have detected radar on the current
1165 * operating channel.
1166 *
1167 * return true - If we consumed the buffer
1168 * false - If have defered the message.
1169 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001170static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1171 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001172{
1173 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1174 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1175 /**
1176 * If message defered, buffer is not consumed yet.
1177 * So return false
1178 */
1179 return false;
1180 }
1181
1182 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1183 return true;
1184}
1185
1186/**
1187 * lim_get_random_bssid()
1188 *
1189 * FUNCTION:This function is called to process generate the random number for bssid
1190 * This function is called to process SME_SCAN_REQ message
1191 * from HDD or upper layer application.
1192 *
1193 * LOGIC:
1194 *
1195 * ASSUMPTIONS:
1196 *
1197 * NOTE:
1198 * 1. geneartes the unique random number for bssid in ibss
1199 *
1200 * @param pMac Pointer to Global MAC structure
1201 * @param *data Pointer to bssid buffer
1202 * @return None
1203 */
1204void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1205{
1206 uint32_t random[2];
1207 random[0] = tx_time_get();
1208 random[0] |= (random[0] << 15);
1209 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301210 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001211}
1212
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301213static QDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001214 tpSirSmeScanReq pScanReq)
1215{
1216 tSirScanOffloadReq *pScanOffloadReq;
1217 uint8_t *p;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001218 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001219 uint16_t i, len;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001220 uint16_t addn_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001221 tSirRetStatus status, rc = eSIR_SUCCESS;
1222 tDot11fIEExtCap extracted_extcap = {0};
1223 bool extcap_present = true;
1224
1225 if (pScanReq->uIEFieldLen) {
1226 status = lim_strip_extcap_update_struct(pMac,
1227 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1228 &pScanReq->uIEFieldLen, &extracted_extcap);
1229
1230 if (eSIR_SUCCESS != status) {
1231 extcap_present = false;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001232 pe_debug("Unable to Strip ExtCap IE from Scan Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001233 }
1234
1235 if (extcap_present) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001236 pe_debug("Extcap was part of SCAN IE - Updating FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001237 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1238 &extracted_extcap, true);
1239 }
1240 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001241 pe_debug("No IEs in the scan request from supplicant");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001242 }
1243
1244 /**
1245 * The tSirScanOffloadReq will reserve the space for first channel,
1246 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1247 */
1248 len = sizeof(tSirScanOffloadReq) +
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001249 (pScanReq->channelList.numChannels - 1) +
1250 pScanReq->uIEFieldLen;
Naveen Rawat02e12662016-08-31 16:49:27 -07001251
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301252 pScanOffloadReq = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001253 if (NULL == pScanOffloadReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001254 pe_err("AllocateMemory failed for pScanOffloadReq");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301255 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001256 }
1257
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001258 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1259 msg.bodyptr = pScanOffloadReq;
1260 msg.bodyval = 0;
1261
Anurag Chouhanc5548422016-02-24 18:33:27 +05301262 qdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001263
1264 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001265 pe_err("Invalid value (%d) for numSsid",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001266 SIR_SCAN_MAX_NUM_SSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301267 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301268 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001269 }
1270
1271 pScanOffloadReq->numSsid = pScanReq->numSsid;
1272 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1273 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301274 qdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001275 (uint8_t *) pScanReq->ssId[i].ssId,
1276 pScanOffloadReq->ssId[i].length);
1277 }
1278
1279 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301280 qdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001281 pScanOffloadReq->bssType = pScanReq->bssType;
1282 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1283 pScanOffloadReq->scanType = pScanReq->scanType;
1284 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1285 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1286 pScanOffloadReq->restTime = pScanReq->restTime;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05301287 pScanOffloadReq->min_rest_time = pScanReq->min_rest_time;
1288 pScanOffloadReq->idle_time = pScanReq->idle_time;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301289 pScanOffloadReq->scan_adaptive_dwell_mode =
1290 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001291
Paul Zhangd2315472017-02-22 10:02:50 +08001292 for (i = 0; i < pMac->lim.maxBssId; i++) {
1293 tpPESession session_entry =
1294 pe_find_session_by_sme_session_id(pMac, i);
1295 if (session_entry &&
1296 (eLIM_MLM_LINK_ESTABLISHED_STATE ==
1297 session_entry->limMlmState) &&
1298 (session_entry->beaconParams.beaconInterval
1299 < BEACON_INTERVAL_THRESHOLD)) {
1300 pScanOffloadReq->burst_scan_duration =
1301 STA_BURST_SCAN_DURATION;
1302 break;
1303 }
1304 }
1305
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001306 /* for normal scan, the value for p2pScanType should be 0
1307 always */
1308 if (pScanReq->p2pSearch)
1309 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1310
1311 pScanOffloadReq->sessionId = pScanReq->sessionId;
1312 pScanOffloadReq->scan_id = pScanReq->scan_id;
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07001313 pScanOffloadReq->scan_requestor_id = USER_SCAN_REQUESTOR_ID;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301314 pScanOffloadReq->scan_adaptive_dwell_mode =
1315 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001316
1317 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001318 pe_err("Invalid pe sessionID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001319 pScanOffloadReq->sessionId);
1320
1321 pScanOffloadReq->channelList.numChannels =
1322 pScanReq->channelList.numChannels;
1323 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1324 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1325 p[i] = pScanReq->channelList.channelNumber[i];
1326
1327 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1328 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1329 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301330 qdf_mem_copy((uint8_t *) pScanOffloadReq +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001331 pScanOffloadReq->uIEFieldOffset,
1332 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1333 pScanReq->uIEFieldLen);
Naveen Rawat02e12662016-08-31 16:49:27 -07001334
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001335 rc = wma_post_ctrl_msg(pMac, &msg);
1336 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001337 pe_err("wma_post_ctrl_msg() return failure");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301338 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301339 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001340 }
1341
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001342 pe_debug("Processed Offload Scan Request Successfully");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001343
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301344 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001345}
1346
1347/**
1348 * __lim_process_sme_scan_req() - Process the SME Scan Request
1349 * @mac_ctx: Global MAC Context
1350 * @msg_buf: Buffer which contains the request and pertinent parameters
1351 *
1352 * This function is called to process SME_SCAN_REQ message
1353 * from HDD or upper layer application.
1354 *
1355 * Return: None
1356 */
1357
1358static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1359 uint32_t *msg_buf)
1360{
1361 tpSirSmeScanReq scan_req;
1362 uint8_t valid_req = 0;
1363
1364#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1365 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1366 eSIR_SUCCESS, eSIR_SUCCESS);
1367#endif
Sreelakshmi Konamki1bb6f312016-12-08 12:32:01 +05301368 mac_ctx->lim.beacon_probe_rsp_cnt_per_scan = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001369
1370 scan_req = (tpSirSmeScanReq) msg_buf;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001371 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 -08001372 scan_req->scan_id, scan_req->channelList.numChannels,
1373 scan_req->minChannelTime, scan_req->maxChannelTime,
1374 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1375 scan_req->returnFreshResults, scan_req->returnUniqueResults,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301376 lim_scan_type_to_string(scan_req->scanType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1378 /*
1379 * Since scan req always requires a response, we will overwrite response
1380 * required here. This is added esp to take care of the condition where
1381 * in p2p go case, we hold the scan req and insert single NOA. We send
1382 * the held scan request to FW later on getting start NOA ind from FW so
1383 * we lose state of the gLimRspReqd flag for the scan req if any other
1384 * request comes by then. e.g. While unit testing, we found when insert
1385 * single NOA is done, we see a get stats request which turns the flag
1386 * gLimRspReqd to false; now when we actually start the saved scan req
1387 * for init scan after getting NOA started, the gLimRspReqd being a
1388 * global flag is showing false instead of true value for this saved
1389 * scan req. Since all scan reqs coming to lim require a response,
1390 * there is no harm in setting the global flag gLimRspReqd to true here.
1391 */
1392 mac_ctx->lim.gLimRspReqd = true;
1393
1394 /*
1395 * copy the Self MAC address from SmeReq to the globalplace,
1396 * used for sending probe req
1397 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001398 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1399 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001400 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1401
1402 if (!valid_req || mac_ctx->lim.scan_disabled) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001403 pe_err("Scan disabled %d, Valid Scan Req %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001404 mac_ctx->lim.scan_disabled, valid_req);
1405
1406 if (mac_ctx->lim.gLimRspReqd) {
1407 mac_ctx->lim.gLimRspReqd = false;
1408
1409 lim_send_sme_scan_rsp(mac_ctx,
1410 eSIR_SME_INVALID_PARAMETERS,
1411 scan_req->sessionId,
1412 scan_req->transactionId,
1413 scan_req->scan_id);
1414 }
1415 return;
1416 }
1417
1418 /*
1419 * If scan request is received in idle, joinFailed
1420 * states or in link established state (in STA role)
1421 * or in normal state (in STA-in-IBSS/AP role) with
1422 * 'return fresh scan results' request from HDD or
1423 * it is periodic background scanning request,
1424 * trigger fresh scan request to MLM
1425 */
1426 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1427
1428 mac_ctx->lim.gLim24Band11dScanDone = 0;
1429 mac_ctx->lim.gLim50Band11dScanDone = 0;
1430 mac_ctx->lim.gLimReturnAfterFirstMatch =
1431 scan_req->returnAfterFirstMatch;
1432 mac_ctx->lim.gLimReturnUniqueResults =
1433 ((scan_req->returnUniqueResults) > 0 ? true : false);
1434
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301435 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001436 lim_send_hal_start_scan_offload_req(mac_ctx,
1437 scan_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001438 pe_err("Couldn't send Offload scan request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001439 lim_send_sme_scan_rsp(mac_ctx,
1440 eSIR_SME_INVALID_PARAMETERS,
1441 scan_req->sessionId,
1442 scan_req->transactionId,
1443 scan_req->scan_id);
1444 return;
1445 }
Anurag Chouhanffb21542016-02-17 14:33:03 +05301446 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001447 /* In all other cases return 'cached' scan results */
1448 if (mac_ctx->lim.gLimRspReqd) {
1449 mac_ctx->lim.gLimRspReqd = false;
1450 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1451 scan_req->sessionId,
1452 scan_req->transactionId, scan_req->scan_id);
1453 }
1454 }
1455}
1456
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001457/**
1458 * __lim_process_clear_dfs_channel_list()
1459 *
1460 ***FUNCTION:
1461 ***Clear DFS channel list when country is changed/aquired.
1462 .*This message is sent from SME.
1463 *
1464 ***LOGIC:
1465 *
1466 ***ASSUMPTIONS:
1467 *
1468 ***NOTE:
1469 *
1470 * @param pMac Pointer to Global MAC structure
1471 * @param *pMsgBuf A pointer to the SME message buffer
1472 * @return None
1473 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001474static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1475 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001476{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301477 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001478}
1479
1480/**
1481 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1482 * @mac_ctx: Pointer to Global MAC structure
1483 * @msg_buf: A pointer to the SME message buffer
1484 *
1485 * This function is called to process SME_JOIN_REQ message
1486 * from HDD or upper layer application.
1487 *
1488 * Return: None
1489 */
1490static void
1491__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1492{
1493 tpSirSmeJoinReq sme_join_req = NULL;
1494 tLimMlmJoinReq *mlm_join_req;
1495 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1496 uint32_t val = 0;
1497 uint16_t n_size;
1498 uint8_t session_id;
1499 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301500 uint8_t sme_session_id = 0;
1501 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001502 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001503 uint16_t ie_len;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001504 const uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001505 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001506 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001507
Arif Hussain995fcaf2016-07-18 11:28:22 -07001508 if (!mac_ctx || !msg_buf) {
1509 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1510 FL("JOIN REQ with invalid data"));
1511 return;
1512 }
1513
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001514/* FEATURE_WLAN_DIAG_SUPPORT */
1515#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1516 /*
1517 * Not sending any session, since it is not created yet.
1518 * The response whould have correct state.
1519 */
1520 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1521#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1522
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001523 /*
1524 * Expect Join request in idle state.
1525 * Reassociate request is expected in link established state.
1526 */
1527
1528 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1529 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1530 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1531 msg_buf);
1532
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301533 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001534 if (NULL == sme_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001535 pe_err("AllocateMemory failed for sme_join_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001536 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301537 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001538 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301539 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001540 n_size);
1541
1542 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1543 /* Received invalid eWNI_SME_JOIN_REQ */
1544 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001545 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001546 sme_join_req->sessionId);
1547 ret_code = eSIR_SME_INVALID_PARAMETERS;
1548 goto end;
1549 }
1550
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001551 /*
1552 * Update the capability here itself as this is used in
1553 * lim_extract_ap_capability() below. If not updated issues
1554 * like not honoring power constraint on 1st association after
1555 * driver loading might occur.
1556 */
1557 lim_update_rrm_capability(mac_ctx, sme_join_req);
1558
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001559 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001560 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001561 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001562 &session_id);
1563
1564 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001565 pe_err("Session(%d) Already exists for BSSID: "
1566 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001567 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001568 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001569 session->limSmeState);
1570
1571 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1572 session->smeSessionId == sme_join_req->sessionId) {
1573 /*
1574 * Received eWNI_SME_JOIN_REQ for same
1575 * BSS as currently associated.
1576 * Log the event and send success
1577 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001578 pe_warn("SessionId: %d", session_id);
1579 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001580 /* Send Join success response to host */
1581 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1582 session = NULL;
1583 goto end;
1584 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001585 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001586 ret_code = eSIR_SME_REFUSED;
1587 session = NULL;
1588 goto end;
1589 }
1590 } else {
1591 /*
1592 * Session Entry does not exist for given BSSId
1593 * Try to Create a new session
1594 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001595 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001596 &session_id, mac_ctx->lim.maxStation,
1597 eSIR_INFRASTRUCTURE_MODE);
1598 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001599 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001600 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1601 goto end;
1602 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001603 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001604 session_id);
1605 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001606 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001607
1608 /*
1609 * Store Session related parameters
1610 * Store PE session Id in session Table
1611 */
1612 session->peSessionId = session_id;
1613
1614 /* store the smejoin req handle in session table */
1615 session->pLimJoinReq = sme_join_req;
1616
1617 /* Store SME session Id in sessionTable */
1618 session->smeSessionId = sme_join_req->sessionId;
1619
1620 /* Store SME transaction Id in session Table */
1621 session->transactionId = sme_join_req->transactionId;
1622
1623 /* Store beaconInterval */
1624 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001625 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001626
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301627 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001628 sizeof(session->htConfig));
1629
Sandeep Puligilla98917432016-06-10 13:50:28 -07001630 qdf_mem_copy(&(session->vht_config),
1631 &(sme_join_req->vht_config),
1632 sizeof(session->vht_config));
1633
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001634 /* Copying of bssId is already done, while creating session */
1635 sir_copy_mac_addr(session->selfMacAddr,
1636 sme_join_req->selfMacAddr);
1637 session->bssType = sme_join_req->bsstype;
1638
1639 session->statypeForBss = STA_ENTRY_PEER;
1640 session->limWmeEnabled = sme_join_req->isWMEenabled;
1641 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301642 session->wps_registration = sme_join_req->wps_registration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001643
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301644 session->enable_bcast_probe_rsp =
1645 sme_join_req->enable_bcast_probe_rsp;
1646
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001647 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001648 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001649 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1650
Naveen Rawat08db88f2017-09-08 15:07:48 -07001651 vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001652 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001653 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001654
1655 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001656 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001657 session->isCiscoVendorAP = true;
1658 } else {
1659 session->isCiscoVendorAP = false;
1660 }
1661
1662 /* Copy the dot 11 mode in to the session table */
1663
1664 session->dot11mode = sme_join_req->dot11mode;
1665#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1666 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1667#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001668 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001669 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1670 session->enableHtSmps = sme_join_req->enableHtSmps;
1671 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001672 session->send_smps_action =
1673 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001674 /*
1675 * By default supported NSS 1x1 is set to true
1676 * and later on updated while determining session
1677 * supported rates which is the intersection of
1678 * self and peer rates
1679 */
1680 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301681 /*Store Persona */
1682 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001683 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 -08001684 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001685 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001686 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301687 session->supported_nss_1x1,
1688 session->pePersona,
1689 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001690
1691 /*Store Persona */
1692 session->pePersona = sme_join_req->staPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +05301693 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301694 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d force_24ghz_in_ht20 %d"),
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001695 session->pePersona, sme_join_req->cbMode,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301696 session->nwType, session->dot11mode,
1697 sme_join_req->force_24ghz_in_ht20);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001698
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001699 /* Copy The channel Id to the session Table */
1700 session->currentOperChannel = bss_desc->channelId;
1701 if (IS_5G_CH(session->currentOperChannel))
1702 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001703 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001704 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1705 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1706 session->vdev_nss = vdev_type_nss->p2p_cli;
1707 else
1708 session->vdev_nss = vdev_type_nss->sta;
1709 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001710 session->vhtCapability =
1711 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001712 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301713 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001714 session->vht_config.su_beam_formee =
1715 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001716 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001717 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001719 session->enableVhtpAid =
1720 sme_join_req->enableVhtpAid;
1721 session->enableVhtGid =
1722 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001723 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001724 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001725 }
Krunal Soni53993f72016-07-08 18:20:03 -07001726
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001727 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1728 lim_update_session_he_capable(mac_ctx, session);
1729 lim_copy_join_req_he_cap(session, sme_join_req);
1730 }
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001731
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001732 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301733 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001734 session->vht_config.su_beam_formee,
1735 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001736 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001737 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001738 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001739 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301740 session->force_24ghz_in_ht20 =
1741 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001742 /* cbMode is already merged value of peer and self -
1743 * done by csr in csr_get_cb_mode_from_ies */
1744 session->htSupportedChannelWidthSet =
1745 (sme_join_req->cbMode) ? 1 : 0;
1746 session->htRecommendedTxWidthSet =
1747 session->htSupportedChannelWidthSet;
1748 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1749
1750 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1751 session->ch_center_freq_seg0 =
1752 session->currentOperChannel - 2;
1753 session->ch_width = CH_WIDTH_40MHZ;
1754 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1755 sme_join_req->cbMode) {
1756 session->ch_center_freq_seg0 =
1757 session->currentOperChannel + 2;
1758 session->ch_width = CH_WIDTH_40MHZ;
1759 } else {
1760 session->ch_center_freq_seg0 = 0;
1761 session->ch_width = CH_WIDTH_20MHZ;
1762 }
1763
1764 /* Record if management frames need to be protected */
1765#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001766 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001767 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001768 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001769 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001770#endif
1771
1772#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001773 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001774#endif
1775
1776 /* Copy the SSID from smejoinreq to session entry */
1777 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301778 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001779 session->ssId.length);
1780
1781 /*
1782 * Determin 11r or ESE connection based on input from SME
1783 * which inturn is dependent on the profile the user wants
1784 * to connect to, So input is coming from supplicant
1785 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001786 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787#ifdef FEATURE_WLAN_ESE
1788 session->isESEconnection = sme_join_req->isESEconnection;
1789#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001790 session->isFastTransitionEnabled =
1791 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001792
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001793 session->isFastRoamIniFeatureEnabled =
1794 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001795 session->txLdpcIniFeatureEnabled =
1796 sme_join_req->txLdpcIniFeatureEnabled;
1797
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301798 lim_update_fils_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001799 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1800 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001801 } else {
1802 /*
1803 * Throw an error and return and make
1804 * sure to delete the session.
1805 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001806 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807 session->bssType);
1808 ret_code = eSIR_SME_INVALID_PARAMETERS;
1809 goto end;
1810 }
1811
1812 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301813 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001814 &sme_join_req->addIEScan, sizeof(tSirAddie));
1815
1816 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301817 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001818 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1819
1820 val = sizeof(tLimMlmJoinReq) +
1821 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301822 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001823 if (NULL == mlm_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001824 pe_err("AllocateMemory failed for mlmJoinReq");
Nitesh Shah0102cac2016-07-13 14:38:30 +05301825 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1826 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001827 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001828
1829 /* PE SessionId is stored as a part of JoinReq */
1830 mlm_join_req->sessionId = session->peSessionId;
1831
1832 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1833 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1834 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001835 pe_err("couldn't retrieve JoinFailureTimer value"
1836 " setting to default value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001837 mlm_join_req->joinFailureTimeout =
1838 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1839 }
1840
1841 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301842 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001843 (void *)&sme_join_req->operationalRateSet,
1844 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301845 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001846 (void *)&sme_join_req->extendedRateSet,
1847 sizeof(tSirMacRateSet));
1848 /*
1849 * this may not be needed anymore now, as rateSet is now
1850 * included in the session entry and MLM has session context.
1851 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301852 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853 (void *)&session->rateSet,
1854 sizeof(tSirMacRateSet));
1855
1856 session->encryptType = sme_join_req->UCEncryptionType;
1857
1858 mlm_join_req->bssDescription.length =
1859 session->pLimJoinReq->bssDescription.length;
1860
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301861 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862 (uint8_t *)
1863 &session->pLimJoinReq->bssDescription.bssId,
1864 session->pLimJoinReq->bssDescription.length + 2);
1865
1866 session->limCurrentBssCaps =
1867 session->pLimJoinReq->bssDescription.capabilityInfo;
1868
1869 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1870 session->currentOperChannel);
1871 local_power_constraint = reg_max;
1872
1873 lim_extract_ap_capability(mac_ctx,
1874 (uint8_t *)
1875 session->pLimJoinReq->bssDescription.ieFields,
1876 lim_get_ielen_from_bss_description(
1877 &session->pLimJoinReq->bssDescription),
1878 &session->limCurrentBssQosCaps,
1879 &session->limCurrentBssPropCap,
1880 &session->gLimCurrentBssUapsd,
1881 &local_power_constraint, session);
1882
Krunal Soni53993f72016-07-08 18:20:03 -07001883 /*
1884 * Once the AP capabilities are available then set the
1885 * beam forming capabilities accordingly.
1886 */
1887 if (session->nss == 1) {
1888 session->vht_config.su_beam_former = 0;
1889 session->vht_config.tx_stbc = 0;
1890 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301891 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001892 }
1893
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001894 session->maxTxPower = lim_get_max_tx_power(reg_max,
1895 local_power_constraint,
1896 mac_ctx->roam.configParam.nTxPowerCap);
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301897
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001898 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301899 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001900
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301901 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1902 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1903 pe_debug("Update MaxTxPower in join Req to %d",
1904 sme_join_req->powerCap.maxTxPower);
1905 }
1906
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001907 if (session->gLimCurrentBssUapsd) {
1908 session->gUapsdPerAcBitmask =
1909 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001910 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001911 session->gUapsdPerAcBitmask);
1912
1913 /* resetting the dynamic uapsd mask */
1914 session->gUapsdPerAcDeliveryEnableMask = 0;
1915 session->gUapsdPerAcTriggerEnableMask = 0;
1916 }
1917
1918 session->limRFBand =
1919 lim_get_rf_band(session->currentOperChannel);
1920
1921 /* Initialize 11h Enable Flag */
1922 if (SIR_BAND_5_GHZ == session->limRFBand) {
1923 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1924 &val) != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001925 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001926 session->lim11hEnable =
1927 WNI_CFG_11H_ENABLED_STADEF;
1928 } else {
1929 session->lim11hEnable = val;
1930 }
1931 } else {
1932 session->lim11hEnable = 0;
1933 }
1934
1935 /*
1936 * To care of the scenario when STA transitions from
1937 * IBSS to Infrastructure mode.
1938 */
1939 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1940
1941 session->limPrevSmeState = session->limSmeState;
1942 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1943 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1944 session->peSessionId,
1945 session->limSmeState));
1946
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001947 /* Indicate whether spectrum management is enabled */
1948 session->spectrumMgtEnabled =
1949 sme_join_req->spectrumMgtIndicator;
1950
1951 /* Enable the spectrum management if this is a DFS channel */
1952 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001953 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001954 session->currentOperChannel))
1955 session->spectrumMgtEnabled = true;
1956
1957 session->isOSENConnection = sme_join_req->isOSENConnection;
1958
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001959 /* Issue LIM_MLM_JOIN_REQ to MLM */
1960 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1961 (uint32_t *) mlm_join_req);
1962 return;
1963
1964 } else {
1965 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001966 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001967 mac_ctx->lim.gLimSmeState);
1968 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1969 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1970 session = NULL;
1971 goto end;
1972 }
1973
1974end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301975 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1976 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001977
1978 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301979 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001980 sme_join_req = NULL;
1981 if (NULL != session)
1982 session->pLimJoinReq = NULL;
1983 }
1984 if (ret_code != eSIR_SME_SUCCESS) {
1985 if (NULL != session) {
1986 pe_delete_session(mac_ctx, session);
1987 session = NULL;
1988 }
1989 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001990 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991 sme_session_id, ret_code);
1992 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1993 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1994 sme_transaction_id);
1995}
1996
Amar Singhala297bfa2015-10-15 15:07:29 -07001997uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 uint8_t iniTxPower)
1999{
2000 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302001 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
2002 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002003 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2004 maxTxPower = txPower;
2005 else if (txPower < MIN_TX_PWR_CAP)
2006 maxTxPower = MIN_TX_PWR_CAP;
2007 else
2008 maxTxPower = MAX_TX_PWR_CAP;
2009
2010 return maxTxPower;
2011}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002012
2013/**
2014 * __lim_process_sme_reassoc_req() - process reassoc req
2015 *
2016 * @mac_ctx: Pointer to Global MAC structure
2017 * @msg_buf: pointer to the SME message buffer
2018 *
2019 * This function is called to process SME_REASSOC_REQ message
2020 * from HDD or upper layer application.
2021 *
2022 * Return: None
2023 */
2024
2025static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2026 uint32_t *msg_buf)
2027{
2028 uint16_t caps;
2029 uint32_t val;
2030 tpSirSmeJoinReq reassoc_req = NULL;
2031 tLimMlmReassocReq *mlm_reassoc_req;
2032 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2033 tpPESession session_entry = NULL;
2034 uint8_t session_id;
2035 uint8_t sme_session_id;
2036 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002037 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002038 uint32_t tele_bcn_en = 0;
2039 uint16_t size;
2040
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002041 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302042 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002043 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002044 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002045
2046 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2047 goto end;
2048 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302049 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002050
2051 if (!lim_is_sme_join_req_valid(mac_ctx,
2052 (tpSirSmeJoinReq)reassoc_req)) {
2053 /*
2054 * Received invalid eWNI_SME_REASSOC_REQ
2055 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002056 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002057
2058 ret_code = eSIR_SME_INVALID_PARAMETERS;
2059 goto end;
2060 }
2061
2062 session_entry = pe_find_session_by_bssid(mac_ctx,
2063 reassoc_req->bssDescription.bssId,
2064 &session_id);
2065 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002066 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002067 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2068 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002069 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002070 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
2071 &sme_session_id, &transaction_id);
2072 session_entry =
2073 pe_find_session_by_sme_session_id(mac_ctx,
2074 sme_session_id);
2075 if (session_entry != NULL)
2076 lim_handle_sme_join_result(mac_ctx,
2077 eSIR_SME_INVALID_PARAMETERS,
2078 eSIR_MAC_UNSPEC_FAILURE_STATUS,
2079 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002080 goto end;
2081 }
2082#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2083 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2084 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2085#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2086 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2087
2088 /* Store the reassoc handle in the session Table */
2089 session_entry->pLimReAssocReq = reassoc_req;
2090
2091 session_entry->dot11mode = reassoc_req->dot11mode;
2092 session_entry->vhtCapability =
2093 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002094
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302095 if (session_entry->vhtCapability) {
2096 if (session_entry->pePersona == QDF_STA_MODE) {
2097 session_entry->vht_config.su_beam_formee =
2098 reassoc_req->vht_config.su_beam_formee;
2099 } else {
2100 reassoc_req->vht_config.su_beam_formee = 0;
2101 }
2102 session_entry->enableVhtpAid =
2103 reassoc_req->enableVhtpAid;
2104 session_entry->enableVhtGid =
2105 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002106 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302107 }
2108
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002109 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302110 session_entry->vhtCapability,
2111 session_entry->vht_config.su_beam_formee,
2112 session_entry->vht_config.su_beam_former);
2113
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002114 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2115 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002116 session_entry->send_smps_action =
2117 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002118 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002119 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002120 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002121 session_entry->send_smps_action,
2122 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002123 /*
2124 * Reassociate request is expected
2125 * in link established state only.
2126 */
2127
2128 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002129 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2130 /*
2131 * May be from 11r FT pre-auth. So lets check it
2132 * before we bail out
2133 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002134 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002135 session_entry->peSessionId);
2136
2137 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302138 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002139 session_entry->limReAssocbssId,
2140 6)) {
2141 lim_print_mac_addr(mac_ctx,
2142 reassoc_req->bssDescription.
2143 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002144 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002145 ret_code = eSIR_SME_INVALID_PARAMETERS;
2146 goto end;
2147 }
2148
2149 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2150 session_entry);
2151 return;
2152 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002153 /*
2154 * Should not have received eWNI_SME_REASSOC_REQ
2155 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002156 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002157 session_entry->limSmeState);
2158 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2159
2160 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2161 goto end;
2162 }
2163
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302164 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002165 session_entry->pLimReAssocReq->bssDescription.bssId,
2166 sizeof(tSirMacAddr));
2167
2168 session_entry->limReassocChannelId =
2169 session_entry->pLimReAssocReq->bssDescription.channelId;
2170
2171 session_entry->reAssocHtSupportedChannelWidthSet =
2172 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2173 session_entry->reAssocHtRecommendedTxWidthSet =
2174 session_entry->reAssocHtSupportedChannelWidthSet;
2175 session_entry->reAssocHtSecondaryChannelOffset =
2176 session_entry->pLimReAssocReq->cbMode;
2177
2178 session_entry->limReassocBssCaps =
2179 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2180 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2181 session_entry->currentOperChannel);
2182 local_pwr_constraint = reg_max;
2183
2184 lim_extract_ap_capability(mac_ctx,
2185 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2186 lim_get_ielen_from_bss_description(
2187 &session_entry->pLimReAssocReq->bssDescription),
2188 &session_entry->limReassocBssQosCaps,
2189 &session_entry->limReassocBssPropCap,
2190 &session_entry->gLimCurrentBssUapsd,
2191 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302192 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002193 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302194 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002195 /* Copy the SSID from session entry to local variable */
2196 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302197 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002198 reassoc_req->ssId.ssId,
2199 session_entry->limReassocSSID.length);
2200 if (session_entry->gLimCurrentBssUapsd) {
2201 session_entry->gUapsdPerAcBitmask =
2202 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002203 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002204 session_entry->gUapsdPerAcBitmask);
2205 }
2206
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302207 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002208 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002209 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002210
2211 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2212 goto end;
2213 }
2214
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302215 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002216 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2217
2218 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2219 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002220 eSIR_SUCCESS)
2221 pe_err("could not retrieve ReassocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002222
2223 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002224 eSIR_SUCCESS)
2225 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302226
2227 lim_update_caps_info_for_bss(mac_ctx, &caps,
2228 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002229 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302230
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002231 mlm_reassoc_req->capabilityInfo = caps;
2232
2233 /* Update PE session_id */
2234 mlm_reassoc_req->sessionId = session_id;
2235
2236 /*
2237 * If telescopic beaconing is enabled, set listen interval to
2238 * WNI_CFG_TELE_BCN_MAX_LI
2239 */
2240 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2241 &tele_bcn_en) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002242 pe_err("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002243
2244 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2245
2246 if (tele_bcn_en) {
2247 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2248 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002249 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002250 } else {
2251 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &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 }
2255
2256 mlm_reassoc_req->listenInterval = (uint16_t) val;
2257
2258 /* Indicate whether spectrum management is enabled */
2259 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2260
2261 /* Enable the spectrum management if this is a DFS channel */
2262 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002263 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002264 session_entry->currentOperChannel))
2265 session_entry->spectrumMgtEnabled = true;
2266
2267 session_entry->limPrevSmeState = session_entry->limSmeState;
2268 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2269
2270 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2271 session_entry->peSessionId,
2272 session_entry->limSmeState));
2273
2274 lim_post_mlm_message(mac_ctx,
2275 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2276 return;
2277end:
2278 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302279 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002280 if (session_entry)
2281 session_entry->pLimReAssocReq = NULL;
2282 }
2283
2284 if (session_entry) {
2285 /*
2286 * error occurred after we determined the session so extract
2287 * session and transaction info from there
2288 */
2289 sme_session_id = session_entry->smeSessionId;
2290 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002291 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002292 /*
2293 * error occurred before or during the time we determined
2294 * the session so extract the session and transaction info
2295 * from the message
2296 */
2297 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2298 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002299 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002300 /*
2301 * Send Reassoc failure response to host
2302 * (note session_entry may be NULL, but that's OK)
2303 */
2304 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2305 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2306 session_entry, sme_session_id,
2307 transaction_id);
2308}
2309
2310bool send_disassoc_frame = 1;
2311/**
2312 * __lim_process_sme_disassoc_req()
2313 *
2314 ***FUNCTION:
2315 * This function is called to process SME_DISASSOC_REQ message
2316 * from HDD or upper layer application.
2317 *
2318 ***LOGIC:
2319 *
2320 ***ASSUMPTIONS:
2321 *
2322 ***NOTE:
2323 *
2324 * @param pMac Pointer to Global MAC structure
2325 * @param *pMsgBuf A pointer to the SME message buffer
2326 * @return None
2327 */
2328
2329static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2330{
2331 uint16_t disassocTrigger, reasonCode;
2332 tLimMlmDisassocReq *pMlmDisassocReq;
2333 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2334 tSirSmeDisassocReq smeDisassocReq;
2335 tpPESession psessionEntry = NULL;
2336 uint8_t sessionId;
2337 uint8_t smesessionId;
2338 uint16_t smetransactionId;
2339
2340 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002341 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002342 return;
2343 }
2344
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302345 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002346 smesessionId = smeDisassocReq.sessionId;
2347 smetransactionId = smeDisassocReq.transactionId;
2348 if (!lim_is_sme_disassoc_req_valid(pMac,
2349 &smeDisassocReq,
2350 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002351 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002352 if (pMac->lim.gLimRspReqd) {
2353 pMac->lim.gLimRspReqd = false;
2354
2355 retCode = eSIR_SME_INVALID_PARAMETERS;
2356 disassocTrigger = eLIM_HOST_DISASSOC;
2357 goto sendDisassoc;
2358 }
2359
2360 return;
2361 }
2362
2363 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002364 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002365 &sessionId);
2366 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002367 pe_err("session does not exist for given bssId "
2368 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002369 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002370 retCode = eSIR_SME_INVALID_PARAMETERS;
2371 disassocTrigger = eLIM_HOST_DISASSOC;
2372 goto sendDisassoc;
2373 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002374 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2375 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002376 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2377 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002378 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002379
2380#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2381 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2382 0, smeDisassocReq.reasonCode);
2383#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2384
2385 /* Update SME session Id and SME transaction ID */
2386
2387 psessionEntry->smeSessionId = smesessionId;
2388 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002389 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002390 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002391
2392 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2393 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002394 switch (psessionEntry->limSmeState) {
2395 case eLIM_SME_ASSOCIATED_STATE:
2396 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002397 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002398 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002399 psessionEntry->limPrevSmeState =
2400 psessionEntry->limSmeState;
2401 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002402 /* Delete all TDLS peers connected before leaving BSS */
2403 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002404 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2405 psessionEntry->peSessionId,
2406 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002407 break;
2408
2409 case eLIM_SME_WT_DEAUTH_STATE:
2410 /* PE shall still process the DISASSOC_REQ and proceed with
2411 * link tear down even if it had already sent a DEAUTH_IND to
2412 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2413 * its been set when PE entered WT_DEAUTH_STATE.
2414 */
2415 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2416 MTRACE(mac_trace
2417 (pMac, TRACE_CODE_SME_STATE,
2418 psessionEntry->peSessionId,
2419 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002420 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002421 break;
2422
2423 case eLIM_SME_WT_DISASSOC_STATE:
2424 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2425 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2426 * PE can continue processing DISASSOC_REQ and send the response instead
2427 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2428 * for disassoc frame.
2429 *
2430 * It will send a disassoc, which is ok. However, we can use the global flag
2431 * sendDisassoc to not send disassoc frame.
2432 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002433 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002434 break;
2435
2436 case eLIM_SME_JOIN_FAILURE_STATE: {
2437 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002438 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002439 if (pMac->lim.gLimRspReqd) {
2440 retCode = eSIR_SME_SUCCESS;
2441 disassocTrigger = eLIM_HOST_DISASSOC;
2442 goto sendDisassoc;
2443 }
2444 }
2445 break;
2446 default:
2447 /**
2448 * STA is not currently associated.
2449 * Log error and send response to host
2450 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002451 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002452 psessionEntry->limSmeState);
2453 lim_print_sme_state(pMac, LOGE,
2454 psessionEntry->limSmeState);
2455
2456 if (pMac->lim.gLimRspReqd) {
2457 if (psessionEntry->limSmeState !=
2458 eLIM_SME_WT_ASSOC_STATE)
2459 pMac->lim.gLimRspReqd = false;
2460
2461 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2462 disassocTrigger = eLIM_HOST_DISASSOC;
2463 goto sendDisassoc;
2464 }
2465
2466 return;
2467 }
2468
2469 break;
2470
2471 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002472 /* Fall through */
2473 break;
2474
2475 case eLIM_STA_IN_IBSS_ROLE:
2476 default:
2477 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002478 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002479 GET_LIM_SYSTEM_ROLE(psessionEntry));
2480
2481 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2482 disassocTrigger = eLIM_HOST_DISASSOC;
2483 goto sendDisassoc;
2484 } /* end switch (pMac->lim.gLimSystemRole) */
2485
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302486 disassocTrigger = eLIM_HOST_DISASSOC;
2487 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002488
2489 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002490 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002491 send_disassoc_frame = 0;
2492 }
2493 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002494 pe_debug("Sending Disasscoc with disassoc Trigger"
2495 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002496 disassocTrigger, reasonCode);
2497
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302498 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002499 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002500 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002501 return;
2502 }
2503
Anurag Chouhanc5548422016-02-24 18:33:27 +05302504 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002505 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002506
2507 pMlmDisassocReq->reasonCode = reasonCode;
2508 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2509
2510 /* Update PE session ID */
2511 pMlmDisassocReq->sessionId = sessionId;
2512
2513 lim_post_mlm_message(pMac,
2514 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2515 return;
2516
2517sendDisassoc:
2518 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002519 lim_send_sme_disassoc_ntf(pMac,
2520 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002521 retCode,
2522 disassocTrigger,
2523 1, smesessionId, smetransactionId,
2524 psessionEntry);
2525 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002526 lim_send_sme_disassoc_ntf(pMac,
2527 smeDisassocReq.peer_macaddr.bytes,
2528 retCode, disassocTrigger, 1,
2529 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002530
2531} /*** end __lim_process_sme_disassoc_req() ***/
2532
2533/** -----------------------------------------------------------------
2534 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2535
2536 This function is called to process SME_DISASSOC_CNF message
2537 from HDD or upper layer application.
2538
2539 \param pMac - global mac structure
2540 \param pStaDs - station dph hash node
2541 \return none
2542 \sa
2543 ----------------------------------------------------------------- */
2544static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2545{
2546 tSirSmeDisassocCnf smeDisassocCnf;
2547 uint16_t aid;
2548 tpDphHashNode pStaDs;
2549 tpPESession psessionEntry;
2550 uint8_t sessionId;
2551
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302552 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002553 sizeof(struct sSirSmeDisassocCnf));
2554
2555 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002556 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002557 &sessionId);
2558 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002559 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002560 return;
2561 }
2562
2563 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002564 pe_err("received invalid SME_DISASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002565 return;
2566 }
2567#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2568 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2569 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2570 psessionEntry,
2571 (uint16_t) smeDisassocCnf.statusCode, 0);
2572 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2573 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2574 psessionEntry,
2575 (uint16_t) smeDisassocCnf.statusCode, 0);
2576#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2577
2578 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2579 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002580 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2581 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2582 && (psessionEntry->limSmeState !=
2583 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002584 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002585 psessionEntry->limSmeState);
2586 lim_print_sme_state(pMac, LOGE,
2587 psessionEntry->limSmeState);
2588 return;
2589 }
2590 break;
2591
2592 case eLIM_AP_ROLE:
2593 /* Fall through */
2594 break;
2595
2596 case eLIM_STA_IN_IBSS_ROLE:
2597 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002598 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002599 GET_LIM_SYSTEM_ROLE(psessionEntry));
2600
2601 return;
2602 }
2603
2604 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2605 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2606 LIM_IS_AP_ROLE(psessionEntry)) {
2607 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002608 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002609 &psessionEntry->dph.dphHashTable);
2610 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002611 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2612 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002613 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002614 return;
2615 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302616
2617 if ((pStaDs->mlmStaContext.mlmState ==
2618 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2619 (pStaDs->mlmStaContext.mlmState ==
2620 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002621 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002622 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302623 pStaDs->mlmStaContext.mlmState);
2624 return;
2625 }
2626
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002627 /* Delete FT session if there exists one */
2628 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002629 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2630
2631 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002632 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002633 }
2634
2635 return;
2636}
2637
2638/**
2639 * __lim_process_sme_deauth_req() - process sme deauth req
2640 * @mac_ctx: Pointer to Global MAC structure
2641 * @msg_buf: pointer to the SME message buffer
2642 *
2643 * This function is called to process SME_DEAUTH_REQ message
2644 * from HDD or upper layer application.
2645 *
2646 * Return: None
2647 */
2648
2649static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2650 uint32_t *msg_buf)
2651{
2652 uint16_t deauth_trigger, reason_code;
2653 tLimMlmDeauthReq *mlm_deauth_req;
2654 tSirSmeDeauthReq sme_deauth_req;
2655 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2656 tpPESession session_entry;
2657 uint8_t session_id; /* PE sessionId */
2658 uint8_t sme_session_id;
2659 uint16_t sme_transaction_id;
2660
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302661 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002662 sme_session_id = sme_deauth_req.sessionId;
2663 sme_transaction_id = sme_deauth_req.transactionId;
2664
2665 /*
2666 * We need to get a session first but we don't even know
2667 * if the message is correct.
2668 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002669 session_entry = pe_find_session_by_bssid(mac_ctx,
2670 sme_deauth_req.bssid.bytes,
2671 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002672 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002673 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002674 ret_code = eSIR_SME_INVALID_PARAMETERS;
2675 deauth_trigger = eLIM_HOST_DEAUTH;
2676 goto send_deauth;
2677 }
2678
2679 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2680 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002681 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002682 mac_ctx->lim.gLimRspReqd = false;
2683
2684 ret_code = eSIR_SME_INVALID_PARAMETERS;
2685 deauth_trigger = eLIM_HOST_DEAUTH;
2686 goto send_deauth;
2687 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002688 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2689 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002690 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2691 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002692 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002693#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2694 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2695 session_entry, 0, sme_deauth_req.reasonCode);
2696#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2697
2698 /* Update SME session ID and Transaction ID */
2699 session_entry->smeSessionId = sme_session_id;
2700 session_entry->transactionId = sme_transaction_id;
2701
2702 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2703 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002704 switch (session_entry->limSmeState) {
2705 case eLIM_SME_ASSOCIATED_STATE:
2706 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302707 /* Delete all TDLS peers connected before leaving BSS */
2708 lim_delete_tdls_peers(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002709 case eLIM_SME_WT_ASSOC_STATE:
2710 case eLIM_SME_JOIN_FAILURE_STATE:
2711 case eLIM_SME_IDLE_STATE:
2712 session_entry->limPrevSmeState =
2713 session_entry->limSmeState;
2714 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2715 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2716 session_entry->peSessionId,
2717 session_entry->limSmeState));
2718 /* Send Deauthentication request to MLM below */
2719 break;
2720 case eLIM_SME_WT_DEAUTH_STATE:
2721 case eLIM_SME_WT_DISASSOC_STATE:
2722 /*
2723 * PE Recieved a Deauth/Disassoc frame. Normally it get
2724 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2725 * Which means host is also trying to disconnect.
2726 * PE can continue processing DEAUTH_REQ and send
2727 * the response instead of failing the request.
2728 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2729 * was sent for deauth/disassoc frame.
2730 */
2731 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002732 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002733 break;
2734 default:
2735 /*
2736 * STA is not in a state to deauthenticate with
2737 * peer. Log error and send response to host.
2738 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002739 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002740 session_entry->limSmeState);
2741 lim_print_sme_state(mac_ctx, LOGE,
2742 session_entry->limSmeState);
2743
2744 if (mac_ctx->lim.gLimRspReqd) {
2745 mac_ctx->lim.gLimRspReqd = false;
2746
2747 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2748 deauth_trigger = eLIM_HOST_DEAUTH;
2749
wadesong42968e92017-06-08 14:11:21 +08002750 /*
2751 * here we received deauth request from AP so
2752 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2753 * have ISSUED delSta then mlm state should be
2754 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2755 * delBSS rsp then mlm state should be
2756 * eLIM_MLM_IDLE_STATE so the below condition
2757 * captures the state where delSta not done
2758 * and firmware still in connected state.
2759 */
2760 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002761 eLIM_SME_WT_DEAUTH_STATE &&
2762 session_entry->limMlmState !=
2763 eLIM_MLM_IDLE_STATE &&
2764 session_entry->limMlmState !=
2765 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002766 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002767 goto send_deauth;
2768 }
2769 return;
2770 }
2771 break;
2772
2773 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002774 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002775 if (mac_ctx->lim.gLimRspReqd) {
2776 mac_ctx->lim.gLimRspReqd = false;
2777 ret_code = eSIR_SME_INVALID_PARAMETERS;
2778 deauth_trigger = eLIM_HOST_DEAUTH;
2779 goto send_deauth;
2780 }
2781 return;
2782 case eLIM_AP_ROLE:
2783 break;
2784 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002785 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002786 GET_LIM_SYSTEM_ROLE(session_entry));
2787 if (mac_ctx->lim.gLimRspReqd) {
2788 mac_ctx->lim.gLimRspReqd = false;
2789 ret_code = eSIR_SME_INVALID_PARAMETERS;
2790 deauth_trigger = eLIM_HOST_DEAUTH;
2791 goto send_deauth;
2792 }
2793 return;
2794 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2795
2796 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2797 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002798 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002799 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2800 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2801 } else {
2802 deauth_trigger = eLIM_HOST_DEAUTH;
2803 reason_code = sme_deauth_req.reasonCode;
2804 }
2805
2806 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302807 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002808 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002809 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002810 if (mac_ctx->lim.gLimRspReqd) {
2811 mac_ctx->lim.gLimRspReqd = false;
2812 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2813 deauth_trigger = eLIM_HOST_DEAUTH;
2814 goto send_deauth;
2815 }
2816 return;
2817 }
2818
Anurag Chouhanc5548422016-02-24 18:33:27 +05302819 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002820 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002821
2822 mlm_deauth_req->reasonCode = reason_code;
2823 mlm_deauth_req->deauthTrigger = deauth_trigger;
2824
2825 /* Update PE session Id */
2826 mlm_deauth_req->sessionId = session_id;
2827
2828 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2829 (uint32_t *)mlm_deauth_req);
2830 return;
2831
2832send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002833 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2834 ret_code, deauth_trigger, 1,
2835 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002836}
2837
2838/**
2839 * __lim_process_sme_set_context_req()
2840 *
2841 * @mac_ctx: Pointer to Global MAC structure
2842 * @msg_buf: pointer to the SME message buffer
2843 *
2844 * This function is called to process SME_SETCONTEXT_REQ message
2845 * from HDD or upper layer application.
2846 *
2847 * Return: None
2848 */
2849
2850static void
2851__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2852{
2853 tpSirSmeSetContextReq set_context_req;
2854 tLimMlmSetKeysReq *mlm_set_key_req;
2855 tpPESession session_entry;
2856 uint8_t session_id; /* PE sessionID */
2857 uint8_t sme_session_id;
2858 uint16_t sme_transaction_id;
2859
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002860 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002861 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002862 return;
2863 }
2864
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302865 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002866 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002867 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002868 return;
2869 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302870 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002871 sizeof(struct sSirSmeSetContextReq));
2872 sme_session_id = set_context_req->sessionId;
2873 sme_transaction_id = set_context_req->transactionId;
2874
2875 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002876 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002877 goto end;
2878 }
2879
2880 if (set_context_req->keyMaterial.numKeys >
2881 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002882 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002883 set_context_req->keyMaterial.numKeys);
2884 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002885 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002886 eSIR_SME_INVALID_PARAMETERS, NULL,
2887 sme_session_id, sme_transaction_id);
2888 goto end;
2889 }
2890
2891 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002892 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002893 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002894 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002895 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002896 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002897 eSIR_SME_INVALID_PARAMETERS, NULL,
2898 sme_session_id, sme_transaction_id);
2899 goto end;
2900 }
2901#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2902 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2903 session_entry, 0, 0);
2904#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2905
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002906 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002907 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2908 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002909 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002910 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2911 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302912 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002913 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002914 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002915 goto end;
2916 }
2917 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2918 mlm_set_key_req->numKeys =
2919 set_context_req->keyMaterial.numKeys;
2920 if (mlm_set_key_req->numKeys >
2921 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002922 pe_err("no.of keys exceeded max num of default keys limit");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002923 goto end;
2924 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302925 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002926 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002927
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302928 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929 (uint8_t *) &set_context_req->keyMaterial.key,
2930 sizeof(tSirKeys) *
2931 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2932 numKeys : 1));
2933
2934 mlm_set_key_req->sessionId = session_id;
2935 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002936 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002937 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002938
2939 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2940 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2941 LIM_IS_AP_ROLE(session_entry)) {
2942 if (set_context_req->keyMaterial.key[0].keyLength) {
2943 uint8_t key_id;
2944 key_id =
2945 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302946 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002947 &session_entry->WEPKeyMaterial[key_id],
2948 (uint8_t *) &set_context_req->keyMaterial,
2949 sizeof(tSirKeyMaterial));
2950 } else {
2951 uint32_t i;
2952 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2953 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302954 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002955 &mlm_set_key_req->key[i],
2956 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2957 sizeof(tSirKeys));
2958 }
2959 }
2960 }
2961 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2962 (uint32_t *) mlm_set_key_req);
2963 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002964 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002965 GET_LIM_SYSTEM_ROLE(session_entry),
2966 session_entry->limSmeState);
2967 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2968
2969 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002970 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002971 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2972 session_entry, sme_session_id,
2973 sme_transaction_id);
2974 }
2975end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302976 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002977 return;
2978}
2979
2980/**
2981 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2982 *
2983 * @mac_ctx: Pointer to Global MAC structure
2984 * @msg_buf: pointer to the SME message buffer
2985 *
2986 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2987 * from HDD or upper layer application.
2988 *
2989 * Return: None
2990 */
2991
Jeff Johnson801f1532016-10-07 07:54:50 -07002992static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2993 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002994{
2995 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2996 tpDphHashNode sta_ds = NULL;
2997 tpPESession session_entry = NULL;
2998 tSap_Event sap_event;
2999 tpWLAN_SAPEventCB sap_event_cb = NULL;
3000 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3001 uint8_t session_id = CSR_SESSION_ID_INVALID;
3002 uint8_t assoc_id = 0;
3003 uint8_t sta_cnt = 0;
3004
3005 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003006 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003007 return;
3008 }
3009
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303010 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003011 sizeof(struct sSirSmeGetAssocSTAsReq));
3012 /*
3013 * Get Associated stations from PE.
3014 * Find PE session Entry
3015 */
3016 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003017 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003018 &session_id);
3019 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003020 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003021 goto lim_assoc_sta_end;
3022 }
3023
3024 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003025 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003026 session_entry->limSmeState,
3027 GET_LIM_SYSTEM_ROLE(session_entry));
3028 goto lim_assoc_sta_end;
3029 }
3030 /* Retrieve values obtained in the request message */
3031 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3032 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3033
3034 if (NULL == assoc_sta_tmp)
3035 goto lim_assoc_sta_end;
3036 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3037 assoc_id++) {
3038 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3039 &session_entry->dph.dphHashTable);
3040 if (NULL == sta_ds)
3041 continue;
3042 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303043 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003044 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303045 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003046 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3047 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3048
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303049 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003050 (uint8_t *)&sta_ds->supportedRates,
3051 sizeof(tSirSupportedRates));
3052 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3053 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3054 assoc_sta_tmp->Support40Mhz =
3055 sta_ds->htDsssCckRate40MHzSupport;
3056
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003057 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003059 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003060 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003061 pe_debug("Association Id: %d Station Index: %d",
3062 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003063 assoc_sta_tmp++;
3064 sta_cnt++;
3065 }
3066 }
3067lim_assoc_sta_end:
3068 /*
3069 * Call hdd callback with sap event to send the list of
3070 * associated stations from PE
3071 */
3072 if (sap_event_cb != NULL) {
3073 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3074 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303075 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003076 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3077 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3078 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3079 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3080 }
3081}
3082
3083/**
3084 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3085 *
3086 * @mac_ctx: Pointer to Global MAC structure
3087 * @msg_buf: pointer to WPS PBC overlap query message
3088 *
3089 * This function parses get WPS PBC overlap information
3090 * message and call callback to pass WPS PBC overlap
3091 * information back to hdd.
3092 *
3093 * Return: None
3094 */
Jeff Johnson801f1532016-10-07 07:54:50 -07003095static void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3096 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003097{
3098 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3099 tpPESession session_entry = NULL;
3100 tSap_Event sap_event;
3101 tpWLAN_SAPEventCB sap_event_cb = NULL;
3102 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003103 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3104
3105 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003106 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003107 return;
3108 }
3109
3110 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303111 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003112
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303113 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003114 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3115 /*
3116 * Get Associated stations from PE
3117 * Find PE session Entry
3118 */
3119 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003120 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003121 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003122 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003123 goto lim_get_wpspbc_sessions_end;
3124 }
3125
3126 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003127 pe_err("Received unexpected message in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003128 GET_LIM_SYSTEM_ROLE(session_entry));
3129 goto lim_get_wpspbc_sessions_end;
3130 }
3131 /*
3132 * Call hdd callback with sap event to send the
3133 * WPS PBC overlap information
3134 */
3135 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303136 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003137
Anurag Chouhanc5548422016-02-24 18:33:27 +05303138 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003139 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003140 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003141 sap_get_wpspbc_event->UUID_E,
3142 &sap_get_wpspbc_event->wpsPBCOverlap,
3143 session_entry);
3144 } else {
3145 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003146 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147 session_entry);
3148 /* don't have to inform the HDD/Host */
3149 return;
3150 }
3151
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003152 pe_debug("wpsPBCOverlap %d", sap_get_wpspbc_event->wpsPBCOverlap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003153 lim_print_mac_addr(mac_ctx,
Abhishek Singh4294f802017-08-10 16:37:07 +05303154 sap_get_wpspbc_event->addr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003155
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303156 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003157
3158lim_get_wpspbc_sessions_end:
3159 sap_event_cb =
3160 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3161 if (NULL != sap_event_cb)
3162 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3163}
3164
3165/**
3166 * __lim_counter_measures()
3167 *
3168 * FUNCTION:
3169 * This function is called to "implement" MIC counter measure
3170 * and is *temporary* only
3171 *
3172 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3173 * we don't do the proper STA disassoc sequence since the
3174 * BSS will be stoped anyway
3175 *
3176 ***ASSUMPTIONS:
3177 *
3178 ***NOTE:
3179 *
3180 * @param pMac Pointer to Global MAC structure
3181 * @return None
3182 */
3183
3184static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3185{
3186 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003187 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003188 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3189 mac, psessionEntry, false);
3190};
3191
Jeff Johnson801f1532016-10-07 07:54:50 -07003192static void lim_process_tkip_counter_measures(tpAniSirGlobal pMac,
3193 uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003194{
3195 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3196 tpPESession psessionEntry;
3197 uint8_t sessionId; /* PE sessionId */
3198
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303199 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003200 sizeof(struct sSirSmeTkipCntrMeasReq));
3201
3202 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003203 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003204 if (NULL == psessionEntry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003205 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003206 return;
3207 }
3208
3209 if (tkipCntrMeasReq.bEnable)
3210 __lim_counter_measures(pMac, psessionEntry);
3211
3212 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3213}
3214
3215static void
3216__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3217{
3218 tSirSmeStopBssReq stopBssReq;
3219 tSirRetStatus status;
3220 tLimSmeStates prevState;
3221 tpPESession psessionEntry;
3222 uint8_t smesessionId;
3223 uint8_t sessionId;
3224 uint16_t smetransactionId;
3225 uint8_t i = 0;
3226 tpDphHashNode pStaDs = NULL;
3227
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303228 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003229 smesessionId = stopBssReq.sessionId;
3230 smetransactionId = stopBssReq.transactionId;
3231
3232 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003233 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003234 /* Send Stop BSS response to host */
3235 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3236 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3237 smetransactionId);
3238 return;
3239 }
3240
3241 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003242 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243 &sessionId);
3244 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003245 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003246 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3247 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3248 smetransactionId);
3249 return;
3250 }
3251#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3252 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3253 0, 0);
3254#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3255
3256 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3257 LIM_IS_STA_ROLE(psessionEntry)) {
3258 /**
3259 * Should not have received STOP_BSS_REQ in states
3260 * other than 'normal' state or on STA in Infrastructure
3261 * mode. Log error and return response to host.
3262 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003263 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003264 psessionEntry->limSmeState,
3265 GET_LIM_SYSTEM_ROLE(psessionEntry));
3266 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3267 /* / Send Stop BSS response to host */
3268 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3269 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3270 smetransactionId);
3271 return;
3272 }
3273
3274 if (LIM_IS_AP_ROLE(psessionEntry))
3275 lim_wpspbc_close(pMac, psessionEntry);
3276
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003277 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003278 stopBssReq.reasonCode);
3279
3280 prevState = psessionEntry->limSmeState;
3281
3282 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3283 MTRACE(mac_trace
3284 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3285 psessionEntry->limSmeState));
3286
3287 /* Update SME session Id and Transaction Id */
3288 psessionEntry->smeSessionId = smesessionId;
3289 psessionEntry->transactionId = smetransactionId;
3290
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003291 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3292 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3293 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003294 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3295 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3296 /* Send disassoc all stations associated thru TKIP */
3297 __lim_counter_measures(pMac, psessionEntry);
3298 else
3299 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003300 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3301 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003302 }
3303
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003304 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3305 /* Free the buffer allocated in START_BSS_REQ */
3306 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3307 psessionEntry->addIeParams.probeRespDataLen = 0;
3308 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003309
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003310 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3311 psessionEntry->addIeParams.assocRespDataLen = 0;
3312 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003313
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003314 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3315 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3316 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003317
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003318 /*
3319 * lim_del_bss is also called as part of coalescing,
3320 * when we send DEL BSS followed by Add Bss msg.
3321 */
3322 pMac->lim.gLimIbssCoalescingHappened = false;
3323 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003324 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3325 pStaDs =
3326 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3327 if (NULL == pStaDs)
3328 continue;
3329 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3330 if (eSIR_SUCCESS == status) {
3331 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3332 pStaDs->assocId, psessionEntry);
3333 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3334 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003335 pe_err("lim_del_sta failed with Status: %d", status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303336 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003337 }
3338 }
3339 /* send a delBss to HAL and wait for a response */
3340 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3341
3342 if (status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003343 pe_err("delBss failed for bss %d", psessionEntry->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344 psessionEntry->limSmeState = prevState;
3345
3346 MTRACE(mac_trace
3347 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3348 psessionEntry->limSmeState));
3349
3350 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3351 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3352 smetransactionId);
3353 }
3354}
3355
3356/**
3357 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3358 * @pMac: Global MAC context
3359 * @pMsg: Message from SME
3360 *
3361 * Wrapper for the function __lim_handle_sme_stop_bss_request
3362 * This message will be defered until softmac come out of
3363 * scan mode. Message should be handled even if we have
3364 * detected radar in the current operating channel.
3365 *
3366 * Return: true - If we consumed the buffer
3367 * false - If have defered the message.
3368 */
3369
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003370static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3371 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003372{
3373 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3374 /**
3375 * If message defered, buffer is not consumed yet.
3376 * So return false
3377 */
3378 return false;
3379 }
3380 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3381 return true;
3382} /*** end __lim_process_sme_stop_bss_req() ***/
3383
3384void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3385 uint32_t body, tpPESession psessionEntry)
3386{
3387
3388 (void)body;
3389 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3390 lim_ibss_delete(pMac, psessionEntry);
3391 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3392 lim_delete_pre_auth_list(pMac);
3393 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3394 psessionEntry->smeSessionId,
3395 psessionEntry->transactionId);
3396 return;
3397}
3398
3399/**
3400 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3401 *
3402 * @mac_ctx: pointer to mac context
3403 * @msg_type: message type
3404 * @msg_buf: pointer to the SME message buffer
3405 *
3406 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3407 * in BTAMP AP.
3408 *
3409 * Return: None
3410 */
3411
3412void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3413 uint32_t *msg_buf)
3414{
3415 tSirSmeAssocCnf assoc_cnf;
3416 tpDphHashNode sta_ds = NULL;
3417 tpPESession session_entry = NULL;
3418 uint8_t session_id;
3419 tpSirAssocReq assoc_req;
3420
3421 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003422 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003423 goto end;
3424 }
3425
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303426 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003427 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003428 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003429 goto end;
3430 }
3431
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003432 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003433 &session_id);
3434 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003435 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436 goto end;
3437 }
3438
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003439 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003440 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3441 (session_entry->limSmeState !=
3442 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003443 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003444 msg_type, session_entry->limSmeState,
3445 GET_LIM_SYSTEM_ROLE(session_entry));
3446 goto end;
3447 }
3448 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3449 &session_entry->dph.dphHashTable);
3450 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003451 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003452 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303453 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003454
3455 /*
3456 * send a DISASSOC_IND message to WSM to make sure
3457 * the state in WSM and LIM is the same
3458 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003459 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003460 eSIR_SME_STA_NOT_ASSOCIATED,
3461 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3462 session_entry->smeSessionId,
3463 session_entry->transactionId,
3464 session_entry);
3465 goto end;
3466 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303467 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003468 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303469 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003470 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003471 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303472 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003473 goto end;
3474 }
3475
3476 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3477 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3478 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3479 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3480 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003481 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3482 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003483 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303484 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003485 goto end;
3486 }
3487 /*
3488 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3489 * has been received
3490 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003491 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003492 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3493 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3494
3495 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3496 /*
3497 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3498 * when it had received Assoc Request frame. Now, PE just needs
3499 * to send association rsp frame to the requesting BTAMP-STA.
3500 */
3501 sta_ds->mlmStaContext.mlmState =
3502 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003503 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003504 sta_ds->assocId);
3505 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3506 sta_ds->assocId, sta_ds->staAddr,
3507 sta_ds->mlmStaContext.subType, sta_ds,
3508 session_entry);
3509 goto end;
3510 } else {
3511 /*
3512 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3513 * to be associated since the HAL sta entry is created for
3514 * denied STA we need to remove this HAL entry.
3515 * So to do that set updateContext to 1
3516 */
3517 if (!sta_ds->mlmStaContext.updateContext)
3518 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003519 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003520 assoc_cnf.statusCode, sta_ds->assocId);
3521 lim_reject_association(mac_ctx, sta_ds->staAddr,
3522 sta_ds->mlmStaContext.subType,
3523 true, sta_ds->mlmStaContext.authType,
3524 sta_ds->assocId, true,
Varun Reddy Yeturu8c68b472017-06-15 16:05:38 -07003525 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003526 session_entry);
3527 }
3528end:
3529 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3530 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3531 assoc_req = (tpSirAssocReq)
3532 session_entry->parsedAssocReq[sta_ds->assocId];
3533 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303534 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003535 assoc_req->assocReqFrame = NULL;
3536 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303537 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003538 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3539 }
3540}
3541
3542static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3543{
3544 tpDphHashNode pStaDs;
3545 tSirMacAddr peerMac;
3546 tpSirAddtsReq pSirAddts;
3547 uint32_t timeout;
3548 tpPESession psessionEntry;
3549 uint8_t sessionId; /* PE sessionId */
3550 uint8_t smesessionId;
3551 uint16_t smetransactionId;
3552
3553 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003554 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003555 return;
3556 }
3557
3558 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3559 &smetransactionId);
3560
3561 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3562
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003563 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3564 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003565 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003566 pe_err("Session Does not exist for given bssId");
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303567 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3568 NULL, pSirAddts->req.tspec,
3569 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003570 return;
3571 }
3572#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3573 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3574 0);
3575#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3576
3577 /* if sta
3578 * - verify assoc state
3579 * - send addts request to ap
3580 * - wait for addts response from ap
3581 * if ap, just ignore with error log
3582 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003583 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3584 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3585 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003587 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003588 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303589 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003590 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003591
3592 pStaDs =
3593 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3594 &psessionEntry->dph.dphHashTable);
3595
3596 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003597 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303598 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003599 }
3600
3601 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3602 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003603 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303604 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003605 }
3606
3607 pSirAddts->req.wsmTspecPresent = 0;
3608 pSirAddts->req.wmeTspecPresent = 0;
3609 pSirAddts->req.lleTspecPresent = 0;
3610
3611 if ((pStaDs->wsmEnabled) &&
3612 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3613 SIR_MAC_ACCESSPOLICY_EDCA))
3614 pSirAddts->req.wsmTspecPresent = 1;
3615 else if (pStaDs->wmeEnabled)
3616 pSirAddts->req.wmeTspecPresent = 1;
3617 else if (pStaDs->lleEnabled)
3618 pSirAddts->req.lleTspecPresent = 1;
3619 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003620 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303621 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003622 }
3623
3624 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3625 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003626 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003627 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303628 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003629 }
3630
3631 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003632 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003633 pMac->lim.gLimAddtsReq.req.dialogToken,
3634 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3635 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3636 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303637 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003638 }
3639
3640 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3641
3642 /* save the addts request */
3643 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303644 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003645 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3646
3647 /* ship out the message now */
3648 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3649 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303650 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003651 /* start a timer to wait for the response */
3652 if (pSirAddts->timeout)
3653 timeout = pSirAddts->timeout;
3654 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3655 eSIR_SUCCESS) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303656 pe_debug("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003657 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303658 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003659 }
3660
3661 timeout = SYS_MS_TO_TICKS(timeout);
3662 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3663 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003664 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303665 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666 }
3667 pMac->lim.gLimAddtsRspTimerCount++;
3668 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3669 pMac->lim.gLimAddtsRspTimerCount) !=
3670 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003671 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303672 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003673 }
3674 MTRACE(mac_trace
3675 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3676 eLIM_ADDTS_RSP_TIMER));
3677
3678 /* add the sessionId to the timer object */
3679 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3680 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3681 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003682 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303683 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003684 }
3685 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303686
3687send_failure_addts_rsp:
3688 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3689 psessionEntry, pSirAddts->req.tspec,
3690 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003691}
3692
3693static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3694{
3695 tSirMacAddr peerMacAddr;
3696 uint8_t ac;
3697 tSirMacTSInfo *pTsinfo;
3698 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3699 tpDphHashNode pStaDs = NULL;
3700 tpPESession psessionEntry;
3701 uint8_t sessionId;
3702 uint32_t status = eSIR_SUCCESS;
3703 uint8_t smesessionId;
3704 uint16_t smetransactionId;
3705
3706 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3707 &smetransactionId);
3708
3709 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003710 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003711 &sessionId);
3712 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003713 pe_err("Session Does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003714 status = eSIR_FAILURE;
3715 goto end;
3716 }
3717#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3718 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3719 0);
3720#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3721
3722 if (eSIR_SUCCESS !=
3723 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003724 pe_err("lim_validate_delts_req failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003725 status = eSIR_FAILURE;
3726 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3727 smesessionId, smetransactionId);
3728 return;
3729 }
3730
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003731 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3732 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003733 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3734
3735 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3736 pDeltsReq->req.wmeTspecPresent,
3737 &pDeltsReq->req.tsinfo,
3738 &pDeltsReq->req.tspec, psessionEntry);
3739
3740 pTsinfo =
3741 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3742 tsinfo : &pDeltsReq->req.tsinfo;
3743
3744 /* We've successfully send DELTS frame to AP. Update the
3745 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3746 * is no longer trigger enabled or delivery enabled
3747 */
3748 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3749 pTsinfo, CLEAR_UAPSD_MASK);
3750
3751 /* We're deleting the TSPEC, so this particular AC is no longer
3752 * admitted. PE needs to downgrade the EDCA
3753 * parameters(for the AC for which TS is being deleted) to the
3754 * next best AC for which ACM is not enabled, and send the
3755 * updated values to HAL.
3756 */
3757 ac = upToAc(pTsinfo->traffic.userPrio);
3758
3759 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3760 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3761 ~(1 << ac);
3762 } else if (pTsinfo->traffic.direction ==
3763 SIR_MAC_DIRECTION_DNLINK) {
3764 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3765 ~(1 << ac);
3766 } else if (pTsinfo->traffic.direction ==
3767 SIR_MAC_DIRECTION_BIDIR) {
3768 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3769 ~(1 << ac);
3770 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3771 ~(1 << ac);
3772 }
3773
3774 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3775 psessionEntry);
3776
3777 pStaDs =
3778 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3779 &psessionEntry->dph.dphHashTable);
3780 if (pStaDs != NULL) {
3781 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3782 pStaDs->bssId);
3783 status = eSIR_SUCCESS;
3784 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003785 pe_err("Self entry missing in Hash Table");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003786 status = eSIR_FAILURE;
3787 }
3788#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003789 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003790#endif
3791
3792 /* send an sme response back */
3793end:
3794 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3795 smesessionId, smetransactionId);
3796}
3797
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303798void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003799{
3800 /* fetch the sessionEntry based on the sessionId */
3801 tpPESession psessionEntry;
3802 psessionEntry = pe_find_session_by_session_id(pMac,
3803 pMac->lim.limTimers.gLimAddtsRspTimer.
3804 sessionId);
3805 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003806 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003807 return;
3808 }
3809
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003810 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003811 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003812 GET_LIM_SYSTEM_ROLE(psessionEntry));
3813 pMac->lim.gLimAddtsSent = false;
3814 return;
3815 }
3816
3817 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003818 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003819 return;
3820 }
3821
3822 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003823 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003824 pMac->lim.gLimAddtsRspTimerCount);
3825 return;
3826 }
3827 /* this a real response timeout */
3828 pMac->lim.gLimAddtsSent = false;
3829 pMac->lim.gLimAddtsRspTimerCount++;
3830
3831 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3832 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3833 psessionEntry->smeSessionId,
3834 psessionEntry->transactionId);
3835}
3836
3837/**
3838 * __lim_process_sme_get_statistics_request()
3839 *
3840 ***FUNCTION:
3841 *
3842 *
3843 ***NOTE:
3844 *
3845 * @param pMac Pointer to Global MAC structure
3846 * @param *pMsgBuf A pointer to the SME message buffer
3847 * @return None
3848 */
3849static void
3850__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3851{
3852 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003853 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003854
3855 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3856
3857 msgQ.type = WMA_GET_STATISTICS_REQ;
3858
3859 msgQ.reserved = 0;
3860 msgQ.bodyptr = pMsgBuf;
3861 msgQ.bodyval = 0;
3862 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3863
3864 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303865 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003866 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003867 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003868 return;
3869 }
3870
3871 return;
3872}
3873
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003874#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003875/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003876 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003877 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003878 * @pMac: Pointer to Global MAC structure
3879 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003880 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003881 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003882 */
3883static void
3884__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3885{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003886 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003887
3888 msgQ.type = WMA_TSM_STATS_REQ;
3889 msgQ.reserved = 0;
3890 msgQ.bodyptr = pMsgBuf;
3891 msgQ.bodyval = 0;
3892 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3893
3894 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303895 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003896 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003897 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003898 return;
3899 }
3900}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003901#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003902
3903static void
3904__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3905{
3906 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
3907 tpPESession psessionEntry;
3908 uint8_t sessionId; /* PE sessionID */
3909
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003910 pe_debug("received UPDATE_APWPSIEs_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003911
3912 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003913 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003914 return;
3915 }
3916
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303917 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003918 if (NULL == pUpdateAPWPSIEsReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003919 pe_err("call to AllocateMemory failed for pUpdateAPWPSIEsReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003920 return;
3921 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303922 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003923 sizeof(struct sSirUpdateAPWPSIEsReq));
3924
3925 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08003926 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003927 &sessionId);
3928 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003929 pe_warn("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003930 goto end;
3931 }
3932
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303933 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003934 sizeof(tSirAPWPSIEs));
3935
3936 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3937 lim_send_beacon_ind(pMac, psessionEntry);
3938
3939end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303940 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003941 return;
3942}
3943
Naveen Rawat8029a402017-06-01 10:54:19 -07003944static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3945 struct update_config *msg)
3946{
3947 tpPESession pe_session;
3948
3949 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3950 if (msg == NULL) {
3951 pe_err("Buffer is Pointing to NULL");
3952 return;
3953 }
3954
3955 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3956 msg->sme_session_id);
3957 if (pe_session == NULL) {
3958 pe_warn("Session does not exist for given BSSID");
3959 return;
3960 }
3961
3962 switch (msg->capab) {
3963 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3964 pe_session->htConfig.ht_rx_ldpc = msg->value;
3965 break;
3966 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3967 pe_session->htConfig.ht_tx_stbc = msg->value;
3968 break;
3969 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3970 pe_session->htConfig.ht_rx_stbc = msg->value;
3971 break;
3972 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3973 pe_session->htConfig.ht_sgi20 = msg->value;
3974 break;
3975 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3976 pe_session->htConfig.ht_sgi40 = msg->value;
3977 break;
3978 }
3979
3980 if (LIM_IS_AP_ROLE(pe_session)) {
3981 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3982 lim_send_beacon_ind(mac_ctx, pe_session);
3983 }
3984}
3985
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003986void
3987lim_send_vdev_restart(tpAniSirGlobal pMac,
3988 tpPESession psessionEntry, uint8_t sessionId)
3989{
3990 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003991 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003992 tSirRetStatus retCode = eSIR_SUCCESS;
3993
3994 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003995 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003996 return;
3997 }
3998
3999 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304000 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004001 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004002 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004003 return;
4004 }
4005
4006 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4007 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004008 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004009
4010 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4011 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4012 msgQ.bodyval = 0;
4013
4014 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4015 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004016 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304017 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004018 }
4019}
4020
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304021/**
4022 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
4023 * @mac_ctx: Pointer to Global MAC structure
4024 * @msg_buf: Pointer to SME message buffer
4025 *
4026 * Return: None
4027 */
4028static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
4029 uint32_t *msg_buf)
4030{
4031 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004032 struct scheduler_msg wma_msg = {0};
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304033 tSirRetStatus status;
4034 tSirRoamOffloadScanReq *req_buffer;
4035 uint16_t local_ie_len;
4036 uint8_t *local_ie_buf;
4037
4038 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
4039 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
4040 req_buffer->sessionId);
4041
4042 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
4043 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004044 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05304045 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304046 return;
4047 }
4048
4049 local_ie_len = req_buffer->assoc_ie.length;
4050 /* Update ext cap IE if present */
4051 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07004052 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
4053 local_ie_buf, &local_ie_len)) {
4054 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07004055 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
4056 req_buffer->assoc_ie.length = local_ie_len;
4057 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
4058 local_ie_buf, local_ie_len);
4059 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304060 }
4061 qdf_mem_free(local_ie_buf);
4062
4063 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
4064 wma_msg.bodyptr = req_buffer;
4065
4066 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
4067 if (eSIR_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004068 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304069 qdf_mem_free(req_buffer);
4070 }
4071}
4072
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304073/*
4074 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
4075 * @mac_ctx: Pointer to global mac context
4076 * @session: Pointer to PE session
4077 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
4078 * 1 - Disable broadcast SSID
4079 *
4080 * Return: None
4081 */
4082static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
4083 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004084{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004085 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004086 session->ssidHidden, ssid_hidden);
4087
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004088 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304089 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004090 } else {
4091 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05304092 return;
4093 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004094
4095 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304096 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004097
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004098 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304099}
4100
4101/**
4102 * __lim_process_sme_session_update - process SME session update msg
4103 *
4104 * @mac_ctx: Pointer to global mac context
4105 * @msg_buf: Pointer to the received message buffer
4106 *
4107 * Return: None
4108 */
4109static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
4110 uint32_t *msg_buf)
4111{
4112 struct sir_update_session_param *msg;
4113 tpPESession session;
4114
4115 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004116 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304117 return;
4118 }
4119
4120 msg = (struct sir_update_session_param *) msg_buf;
4121
4122 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
4123 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004124 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304125 msg->session_id);
4126 return;
4127 }
4128
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004129 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304130 msg->param_type, msg->param_val);
4131 switch (msg->param_type) {
4132 case SIR_PARAM_SSID_HIDDEN:
4133 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
4134 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05304135 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
4136 session->ignore_assoc_disallowed = msg->param_val;
4137 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304138 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004139 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304140 break;
4141 }
4142}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004143
4144static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4145{
4146 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4147 tpPESession psessionEntry;
4148 uint8_t sessionId; /* PE sessionID */
4149
4150 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004151 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004152 return;
4153 }
4154
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304155 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004156 if (NULL == pUpdateAPWPARSNIEsReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004157 pe_err("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004158 return;
4159 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304160 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004161 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4162
4163 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004164 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004165 &sessionId);
4166 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004167 pe_warn("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004168 goto end;
4169 }
4170
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304171 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004172 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4173
4174 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4175 &psessionEntry->
4176 pLimStartBssReq->rsnIE,
4177 psessionEntry);
4178
4179 psessionEntry->pLimStartBssReq->privacy = 1;
4180 psessionEntry->privacy = 1;
4181
4182 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4183 lim_send_beacon_ind(pMac, psessionEntry);
4184
4185end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304186 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004187 return;
4188} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4189
4190/*
4191 Update the beacon Interval dynamically if beaconInterval is different in MCC
4192 */
4193static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4194{
4195 tpSirChangeBIParams pChangeBIParams;
4196 tpPESession psessionEntry;
4197 uint8_t sessionId = 0;
4198 tUpdateBeaconParams beaconParams;
4199
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004200 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201
4202 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004203 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004204 return;
4205 }
4206
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304207 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004208 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4209
4210 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004211 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004212 &sessionId);
4213 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004214 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004215 return;
4216 }
4217
4218 /*Update sessionEntry Beacon Interval */
4219 if (psessionEntry->beaconParams.beaconInterval !=
4220 pChangeBIParams->beaconInterval) {
4221 psessionEntry->beaconParams.beaconInterval =
4222 pChangeBIParams->beaconInterval;
4223 }
4224
4225 /*Update sch beaconInterval */
4226 if (pMac->sch.schObject.gSchBeaconInterval !=
4227 pChangeBIParams->beaconInterval) {
4228 pMac->sch.schObject.gSchBeaconInterval =
4229 pChangeBIParams->beaconInterval;
4230
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004231 pe_debug("LIM send update BeaconInterval Indication: %d",
4232 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004233
4234 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4235 /* Update beacon */
4236 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4237
4238 beaconParams.bssIdx = psessionEntry->bssIdx;
4239 /* Set change in beacon Interval */
4240 beaconParams.beaconInterval =
4241 pChangeBIParams->beaconInterval;
4242 beaconParams.paramChangeBitmap =
4243 PARAM_BCN_INTERVAL_CHANGED;
4244 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4245 }
4246 }
4247
4248 return;
4249} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4250
4251#ifdef QCA_HT_2040_COEX
4252static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4253 uint32_t *pMsgBuf)
4254{
4255 tpSirSetHT2040Mode pSetHT2040Mode;
4256 tpPESession psessionEntry;
4257 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004258 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004259 tUpdateVHTOpMode *pHtOpMode = NULL;
4260 uint16_t staId = 0;
4261 tpDphHashNode pStaDs = NULL;
4262
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004263 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004264 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004265 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004266 return;
4267 }
4268
4269 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4270
4271 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004272 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004273 &sessionId);
4274 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004275 pe_debug("Session does not exist for given BSSID");
4276 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004277 return;
4278 }
4279
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004280 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004281 pSetHT2040Mode->cbMode);
4282 /*Update sessionEntry HT related fields */
4283 switch (pSetHT2040Mode->cbMode) {
4284 case PHY_SINGLE_CHANNEL_CENTERED:
4285 psessionEntry->htSecondaryChannelOffset =
4286 PHY_SINGLE_CHANNEL_CENTERED;
4287 psessionEntry->htRecommendedTxWidthSet = 0;
4288 if (pSetHT2040Mode->obssEnabled)
4289 psessionEntry->htSupportedChannelWidthSet
4290 = eHT_CHANNEL_WIDTH_40MHZ;
4291 else
4292 psessionEntry->htSupportedChannelWidthSet
4293 = eHT_CHANNEL_WIDTH_20MHZ;
4294 break;
4295 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4296 psessionEntry->htSecondaryChannelOffset =
4297 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4298 psessionEntry->htRecommendedTxWidthSet = 1;
4299 break;
4300 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4301 psessionEntry->htSecondaryChannelOffset =
4302 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4303 psessionEntry->htRecommendedTxWidthSet = 1;
4304 break;
4305 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004306 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004307 return;
4308 }
4309
4310 /* Update beacon */
4311 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4312 lim_send_beacon_ind(pMac, psessionEntry);
4313
4314 /* update OP Mode for each associated peer */
4315 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4316 pStaDs = dph_get_hash_entry(pMac, staId,
4317 &psessionEntry->dph.dphHashTable);
4318 if (NULL == pStaDs)
4319 continue;
4320
4321 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304322 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004323 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004324 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004325 return;
4326 }
4327 pHtOpMode->opMode =
4328 (psessionEntry->htSecondaryChannelOffset ==
4329 PHY_SINGLE_CHANNEL_CENTERED) ?
4330 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4331 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304332 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004333 sizeof(tSirMacAddr));
4334 pHtOpMode->smesessionId = sessionId;
4335
4336 msg.type = WMA_UPDATE_OP_MODE;
4337 msg.reserved = 0;
4338 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004339 if (!QDF_IS_STATUS_SUCCESS
4340 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
4341 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304342 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004343 return;
4344 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004345 pe_debug("Notifed FW about OP mode: %d for staId=%d",
4346 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004347
4348 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004349 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004350 }
4351
4352 return;
4353}
4354#endif
4355
4356/* -------------------------------------------------------------------- */
4357/**
4358 * __lim_process_report_message
4359 *
4360 * FUNCTION: Processes the next received Radio Resource Management message
4361 *
4362 * LOGIC:
4363 *
4364 * ASSUMPTIONS:
4365 *
4366 * NOTE:
4367 *
4368 * @param None
4369 * @return None
4370 */
4371
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004372static void __lim_process_report_message(tpAniSirGlobal pMac,
4373 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004374{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004375 switch (pMsg->type) {
4376 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4377 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4378 break;
4379 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004380 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004381 break;
4382 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004383 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004384 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004385}
4386
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004387/* -------------------------------------------------------------------- */
4388/**
4389 * lim_send_set_max_tx_power_req
4390 *
4391 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4392 *
4393 * LOGIC:
4394 *
4395 * ASSUMPTIONS:
4396 *
4397 * NOTE:
4398 *
4399 * @param txPower txPower to be set.
4400 * @param pSessionEntry session entry.
4401 * @return None
4402 */
4403tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004404lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004405 tpPESession pSessionEntry)
4406{
4407 tpMaxTxPowerParams pMaxTxParams = NULL;
4408 tSirRetStatus retCode = eSIR_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004409 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004410
4411 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004412 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004413 return eSIR_FAILURE;
4414 }
4415
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304416 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004417 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004418 pe_err("Unable to allocate memory for pMaxTxParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004419 return eSIR_MEM_ALLOC_FAILED;
4420
4421 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004422 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304423 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304424 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304425 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004426 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304427 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004428
4429 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4430 msgQ.bodyptr = pMaxTxParams;
4431 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004432 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004433 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4434 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4435 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004436 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304437 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004438 }
4439 return retCode;
4440}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004441
4442/**
4443 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4444 *
4445 * @mac_ctx: Pointer to Global MAC structure
4446 * @msg_buf: pointer to the SME message buffer
4447 *
4448 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4449 * from SME. It Register this information within PE.
4450 *
4451 * Return: None
4452 */
4453static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4454 uint32_t *msg_buf)
4455{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304456 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004457 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4458 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4459 struct mgmt_frm_reg_info *next = NULL;
4460 bool match = false;
4461
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004462 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004463 sme_req->registerFrame, sme_req->frameType,
4464 sme_req->matchLen);
4465 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304466 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304467 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4468 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304469 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004470
4471 while (lim_mgmt_regn != NULL) {
4472 if (lim_mgmt_regn->frameType != sme_req->frameType)
4473 goto skip_match;
4474 if (sme_req->matchLen) {
4475 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304476 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004477 sme_req->matchData,
4478 lim_mgmt_regn->matchLen))) {
4479 /* found match! */
4480 match = true;
4481 break;
4482 }
4483 } else {
4484 /* found match! */
4485 match = true;
4486 break;
4487 }
4488skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304489 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304490 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004491 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304492 (qdf_list_node_t *)lim_mgmt_regn,
4493 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304494 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004495 lim_mgmt_regn = next;
4496 next = NULL;
4497 }
4498 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304499 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004500 if (QDF_STATUS_SUCCESS ==
4501 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004502 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004503 (qdf_list_node_t *)lim_mgmt_regn))
4504 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304505 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004506 }
4507
4508 if (sme_req->registerFrame) {
4509 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304510 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004511 sme_req->matchLen);
4512 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004513 lim_mgmt_regn->frameType = sme_req->frameType;
4514 lim_mgmt_regn->matchLen = sme_req->matchLen;
4515 lim_mgmt_regn->sessionId = sme_req->sessionId;
4516 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304517 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004518 sme_req->matchData,
4519 sme_req->matchLen);
4520 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304521 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004522 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304523 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004524 gLimMgmtFrameRegistratinQueue,
4525 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304526 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004527 &mac_ctx->lim.lim_frame_register_lock);
4528 }
4529 }
4530 return;
4531}
4532
4533static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4534{
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004535 pe_debug("Dereg msgType %d", pMac->lim.gDeferMsgTypeForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004536 pMac->lim.gDeferMsgTypeForNOA = 0;
4537 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4538 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304539 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004540 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4541 }
4542}
4543
4544/**
4545 * lim_process_regd_defd_sme_req_after_noa_start()
4546 *
4547 * mac_ctx: Pointer to Global MAC structure
4548 *
4549 * This function is called to process deferred sme req message
4550 * after noa start.
4551 *
4552 * Return: None
4553 */
4554void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4555{
4556 bool buf_consumed = true;
4557
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004558 pe_debug("Process defd sme req %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004559 mac_ctx->lim.gDeferMsgTypeForNOA);
4560
4561 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4562 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004563 pe_warn("start rcvd from FW when no sme deferred msg pending. Do nothing");
4564 pe_warn("It may happen when NOA start ind and timeout happen at the same time");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004565 return;
4566 }
4567 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4568 case eWNI_SME_SCAN_REQ:
4569 __lim_process_sme_scan_req(mac_ctx,
4570 mac_ctx->lim.gpDefdSmeMsgForNOA);
4571 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004572 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4573 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4574 mac_ctx->lim.gpDefdSmeMsgForNOA);
4575 /*
4576 * lim_process_remain_on_chnl_req doesnt want us to free
4577 * the buffer since it is freed in lim_remain_on_chn_rsp.
4578 * this change is to avoid "double free"
4579 */
4580 if (false == buf_consumed)
4581 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4582 break;
4583 case eWNI_SME_JOIN_REQ:
4584 __lim_process_sme_join_req(mac_ctx,
4585 mac_ctx->lim.gpDefdSmeMsgForNOA);
4586 break;
4587 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004588 pe_err("Unknown deferred msg type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004589 mac_ctx->lim.gDeferMsgTypeForNOA);
4590 break;
4591 }
4592 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4593}
4594
4595static void
4596__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4597{
4598 tpSirResetAPCapsChange pResetCapsChange;
4599 tpPESession psessionEntry;
4600 uint8_t sessionId = 0;
4601 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004602 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004603 return;
4604 }
4605
4606 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4607 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004608 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4609 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004610 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004611 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004612 return;
4613 }
4614
4615 psessionEntry->limSentCapsChangeNtf = false;
4616 return;
4617}
4618
4619/**
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304620 * lim_register_p2p_ack_ind_cb() - Save the p2p ack indication callback.
4621 * @mac_ctx: Mac pointer
4622 * @msg_buf: Msg pointer containing the callback
4623 *
4624 * This function is used to save the p2p ack indication callback in PE.
4625 *
4626 * Return: None
4627 */
4628static void lim_register_p2p_ack_ind_cb(tpAniSirGlobal mac_ctx,
4629 uint32_t *msg_buf)
4630{
4631 struct sir_sme_p2p_ack_ind_cb_req *sme_req =
4632 (struct sir_sme_p2p_ack_ind_cb_req *)msg_buf;
4633
4634 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004635 pe_err("msg_buf is null");
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304636 return;
4637 }
4638 if (sme_req->callback)
4639 mac_ctx->p2p_ack_ind_cb =
4640 sme_req->callback;
4641 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004642 pe_err("sme_req->callback is null");
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304643}
4644
4645/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304646 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4647 * indication callback in PE.
4648 * @mac_ptr: Mac pointer
4649 * @msg_buf: Msg pointer containing the callback
4650 *
4651 * This function is used save the Management frame
4652 * indication callback in PE.
4653 *
4654 * Return: None
4655 */
4656static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4657 uint32_t *msg_buf)
4658{
4659 struct sir_sme_mgmt_frame_cb_req *sme_req =
4660 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4661
4662 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004663 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304664 return;
4665 }
4666 if (sme_req->callback)
4667 mac_ctx->mgmt_frame_ind_cb =
4668 (sir_mgmt_frame_ind_callback)sme_req->callback;
4669 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004670 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304671}
4672
4673/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304674 *__lim_process_send_disassoc_frame: function processes disassoc frame
4675 * @mac_ctx: pointer to mac context
4676 * @msg_buf: message buffer
4677 *
4678 * function processes disassoc request received from SME
4679 *
4680 * return: none
4681 */
4682static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4683 uint32_t *msg_buf)
4684{
4685 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4686 tSirRetStatus status;
4687 tpPESession session_entry = NULL;
4688 uint8_t sme_session_id;
4689 uint16_t sme_trans_id;
4690
4691 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004692 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304693 return;
4694 }
4695
4696 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4697 &sme_trans_id);
4698
4699 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4700 &sme_send_disassoc_frame_req,
4701 (uint8_t *)msg_buf);
4702
4703 if ((eSIR_FAILURE == status) ||
4704 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4705 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004706 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304707 return;
4708 }
4709
4710 session_entry = pe_find_session_by_sme_session_id(
4711 mac_ctx, sme_session_id);
4712 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004713 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304714 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4715 return;
4716 }
4717
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004718 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 +05304719 sme_send_disassoc_frame_req.msg_type,
4720 sme_send_disassoc_frame_req.length,
4721 sme_send_disassoc_frame_req.session_id,
4722 sme_send_disassoc_frame_req.trans_id,
4723 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4724 sme_send_disassoc_frame_req.reason,
4725 sme_send_disassoc_frame_req.wait_for_ack);
4726
4727 lim_send_disassoc_mgmt_frame(mac_ctx,
4728 sme_send_disassoc_frame_req.reason,
4729 sme_send_disassoc_frame_req.peer_mac,
4730 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4731}
4732
4733/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004734 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4735 * @mac_ctx: Pointer to Global MAC structure
4736 * @pdev_id: pdev id to set the IE.
4737 * @nss: Nss values to prepare the HT IE.
4738 *
4739 * Prepares the HT IE with self capabilities for different
4740 * Nss values and sends the set HT IE req to FW.
4741 *
4742 * Return: None
4743 */
4744static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4745 uint8_t nss)
4746{
4747 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004748 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004749 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004750 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004751 tHtCaps *p_ht_cap;
4752 int i;
4753
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004754 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004755 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4756 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004757 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004758 return;
4759 }
4760 ie_params->nss = i;
4761 ie_params->pdev_id = pdev_id;
4762 ie_params->ie_type = DOT11_HT_IE;
4763 /* 2 for IE len and EID */
4764 ie_params->ie_len = 2 + sizeof(tHtCaps);
4765 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4766 if (NULL == ie_params->ie_ptr) {
4767 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004768 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004769 return;
4770 }
4771 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4772 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4773 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4774 ie_params->ie_len);
4775
4776 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004777 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4778 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004779 if (NULL == p_ie) {
4780 qdf_mem_free(ie_params->ie_ptr);
4781 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004782 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004783 return;
4784 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004785 p_ht_cap = (tHtCaps *)&p_ie[2];
4786 p_ht_cap->supportedMCSSet[1] = 0;
4787 p_ht_cap->txSTBC = 0;
4788 }
4789
4790 msg.type = WMA_SET_PDEV_IE_REQ;
4791 msg.bodyptr = ie_params;
4792 msg.bodyval = 0;
4793
4794 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4795 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004796 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004797 qdf_mem_free(ie_params->ie_ptr);
4798 qdf_mem_free(ie_params);
4799 return;
4800 }
4801 }
4802}
4803
4804/**
4805 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4806 * @mac_ctx: Pointer to Global MAC structure
4807 * @pdev_id: pdev id to set the IE.
4808 * @nss: Nss values to prepare the VHT IE.
4809 *
4810 * Prepares the VHT IE with self capabilities for different
4811 * Nss values and sends the set VHT IE req to FW.
4812 *
4813 * Return: None
4814 */
4815static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4816 uint8_t nss)
4817{
4818 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004819 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004820 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004821 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004822 tSirMacVHTCapabilityInfo *vht_cap;
4823 int i;
4824 tSirVhtMcsInfo *vht_mcs;
4825
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004826 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004827 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4828 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004829 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004830 return;
4831 }
4832 ie_params->nss = i;
4833 ie_params->pdev_id = pdev_id;
4834 ie_params->ie_type = DOT11_VHT_IE;
4835 /* 2 for IE len and EID */
4836 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4837 sizeof(tSirVhtMcsInfo);
4838 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4839 if (NULL == ie_params->ie_ptr) {
4840 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004841 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004842 return;
4843 }
4844 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4845 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4846 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4847 ie_params->ie_len);
4848
4849 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004850 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4851 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004852 if (NULL == p_ie) {
4853 qdf_mem_free(ie_params->ie_ptr);
4854 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004855 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004856 return;
4857 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004858 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4859 vht_cap->txSTBC = 0;
4860 vht_mcs =
4861 (tSirVhtMcsInfo *)&p_ie[2 +
4862 sizeof(tSirMacVHTCapabilityInfo)];
4863 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4864 vht_mcs->rxHighest =
4865 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4866 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4867 vht_mcs->txHighest =
4868 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4869 }
4870 msg.type = WMA_SET_PDEV_IE_REQ;
4871 msg.bodyptr = ie_params;
4872 msg.bodyval = 0;
4873
4874 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4875 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004876 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004877 qdf_mem_free(ie_params->ie_ptr);
4878 qdf_mem_free(ie_params);
4879 return;
4880 }
4881 }
4882}
4883
4884/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004885 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4886 * @mac_ctx: Pointer to Global MAC structure
4887 * @msg_buf: Pointer to the SME message buffer
4888 *
4889 * This function is called by limProcessMessageQueue(). This function sets the
4890 * VDEV IEs to the FW.
4891 *
4892 * Return: None
4893 */
4894static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4895 uint32_t *msg_buf)
4896{
4897 struct sir_set_vdev_ies_per_band *p_msg =
4898 (struct sir_set_vdev_ies_per_band *)msg_buf;
4899
4900 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004901 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004902 return;
4903 }
4904
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004905 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004906 p_msg->vdev_id);
4907 /* intentionally using NULL here so that self capabilty are sent */
4908 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4909 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004910 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004911}
4912
4913/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004914 * lim_process_set_pdev_IEs() - process the set pdev IE req
4915 * @mac_ctx: Pointer to Global MAC structure
4916 * @msg_buf: Pointer to the SME message buffer
4917 *
4918 * This function is called by limProcessMessageQueue(). This
4919 * function sets the PDEV IEs to the FW.
4920 *
4921 * Return: None
4922 */
4923static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4924{
4925 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4926
4927 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4928
4929 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004930 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004931 return;
4932 }
4933
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004934 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004935 ht_vht_cfg->nss);
4936 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4937
4938 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4939 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4940 ht_vht_cfg->nss);
4941}
4942
4943/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304944 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4945 *
4946 * access policy
4947 * @mac_ctx: pointer to mac context
4948 * @msg: message buffer
4949 *
4950 * function processes vendor IE and access policy from SME and updates PE
4951 *
4952 * session entry
4953 *
4954 * return: none
4955*/
4956static void lim_process_sme_update_access_policy_vendor_ie(
4957 tpAniSirGlobal mac_ctx,
4958 uint32_t *msg)
4959{
4960 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4961 struct sPESession *pe_session_entry;
4962 uint8_t num_bytes;
4963
4964 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004965 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304966 return;
4967 }
4968 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4969 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4970 update_vendor_ie->sme_session_id);
4971
4972 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004973 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304974 update_vendor_ie->sme_session_id);
4975 return;
4976 }
4977 if (pe_session_entry->access_policy_vendor_ie)
4978 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4979
4980 num_bytes = update_vendor_ie->ie[1] + 2;
4981 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4982
4983 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004984 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304985 return;
4986 }
4987 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4988 &update_vendor_ie->ie[0], num_bytes);
4989
4990 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4991}
4992
4993/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004994 * lim_process_sme_req_messages()
4995 *
4996 ***FUNCTION:
4997 * This function is called by limProcessMessageQueue(). This
4998 * function processes SME request messages from HDD or upper layer
4999 * application.
5000 *
5001 ***LOGIC:
5002 *
5003 ***ASSUMPTIONS:
5004 *
5005 ***NOTE:
5006 *
5007 * @param pMac Pointer to Global MAC structure
5008 * @param msgType Indicates the SME message type
5009 * @param *pMsgBuf A pointer to the SME message buffer
5010 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5011 * false - if pMsgBuf is not to be freed.
5012 */
5013
Rajeev Kumarfeb96382017-01-22 19:42:09 -08005014bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
5015 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005016{
5017 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
5018 uint32_t *pMsgBuf = pMsg->bodyptr;
5019 tpSirSmeScanReq pScanReq;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005020
5021 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005022 lim_msg_str(pMsg->type), pMsg->type,
5023 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5024 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005025
5026 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5027 /* If no insert NOA required then execute the code below */
5028
5029 switch (pMsg->type) {
5030 case eWNI_SME_SYS_READY_IND:
5031 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
5032 break;
5033
5034 case eWNI_SME_START_BSS_REQ:
5035 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
5036 break;
5037
5038 case eWNI_SME_SCAN_REQ:
5039 __lim_process_sme_scan_req(pMac, pMsgBuf);
5040 break;
5041
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005042 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5043 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
5044 break;
5045
5046 case eWNI_SME_UPDATE_NOA:
5047 __lim_process_sme_no_a_update(pMac, pMsgBuf);
5048 break;
5049 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5050 __lim_process_clear_dfs_channel_list(pMac, pMsg);
5051 break;
5052 case eWNI_SME_JOIN_REQ:
5053 __lim_process_sme_join_req(pMac, pMsgBuf);
5054 break;
5055
5056 case eWNI_SME_REASSOC_REQ:
5057 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
5058 break;
5059
5060 case eWNI_SME_DISASSOC_REQ:
5061 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
5062 break;
5063
5064 case eWNI_SME_DISASSOC_CNF:
5065 case eWNI_SME_DEAUTH_CNF:
5066 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
5067 break;
5068
5069 case eWNI_SME_DEAUTH_REQ:
5070 __lim_process_sme_deauth_req(pMac, pMsgBuf);
5071 break;
5072
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05305073 case eWNI_SME_SEND_DISASSOC_FRAME:
5074 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
5075 break;
5076
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005077 case eWNI_SME_SETCONTEXT_REQ:
5078 __lim_process_sme_set_context_req(pMac, pMsgBuf);
5079 break;
5080
5081 case eWNI_SME_STOP_BSS_REQ:
5082 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
5083 break;
5084
5085 case eWNI_SME_ASSOC_CNF:
5086 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005087 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005088 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5089 pMsgBuf);
5090 break;
5091
5092 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005093 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005094 __lim_process_sme_addts_req(pMac, pMsgBuf);
5095 break;
5096
5097 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005098 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005099 __lim_process_sme_delts_req(pMac, pMsgBuf);
5100 break;
5101
5102 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005103 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005104 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5105 break;
5106
5107 case eWNI_SME_GET_STATISTICS_REQ:
5108 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5109 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5110 bufConsumed = false;
5111 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005112#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005113 case eWNI_SME_GET_TSM_STATS_REQ:
5114 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5115 bufConsumed = false;
5116 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005117#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005118 case eWNI_SME_GET_ASSOC_STAS_REQ:
5119 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5120 break;
5121 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5122 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5123 break;
5124
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05305125 case eWNI_SME_SESSION_UPDATE_PARAM:
5126 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005127 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05305128 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
5129 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
5130 bufConsumed = false;
5131 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005132 case eWNI_SME_UPDATE_APWPSIE_REQ:
5133 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5134 break;
5135 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5136 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5137 break;
5138
5139 case eWNI_SME_SET_APWPARSNIEs_REQ:
5140 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5141 break;
5142
5143 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5144 /* Update the beaconInterval */
5145 __lim_process_sme_change_bi(pMac, pMsgBuf);
5146 break;
5147
5148#ifdef QCA_HT_2040_COEX
5149 case eWNI_SME_SET_HT_2040_MODE:
5150 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5151 break;
5152#endif
5153
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005154 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5155 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5156 __lim_process_report_message(pMac, pMsg);
5157 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005158
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005159 case eWNI_SME_FT_PRE_AUTH_REQ:
5160 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5161 break;
5162 case eWNI_SME_FT_UPDATE_KEY:
5163 lim_process_ft_update_key(pMac, pMsgBuf);
5164 break;
5165
5166 case eWNI_SME_FT_AGGR_QOS_REQ:
5167 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5168 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005169
5170 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5171 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5172 break;
5173#ifdef FEATURE_WLAN_TDLS
5174 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5175 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5176 break;
5177 case eWNI_SME_TDLS_ADD_STA_REQ:
5178 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5179 break;
5180 case eWNI_SME_TDLS_DEL_STA_REQ:
5181 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5182 break;
5183 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5184 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5185 break;
5186#endif
5187 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5188 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5189 break;
5190
5191 case eWNI_SME_CHANNEL_CHANGE_REQ:
5192 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5193 break;
5194
5195 case eWNI_SME_START_BEACON_REQ:
5196 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5197 break;
5198
5199 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5200 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5201 break;
5202
5203 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5204 lim_process_update_add_ies(pMac, pMsgBuf);
5205 break;
5206
5207 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5208 lim_process_modify_add_ies(pMac, pMsgBuf);
5209 break;
5210 case eWNI_SME_SET_HW_MODE_REQ:
5211 lim_process_set_hw_mode(pMac, pMsgBuf);
5212 break;
5213 case eWNI_SME_NSS_UPDATE_REQ:
5214 lim_process_nss_update_request(pMac, pMsgBuf);
5215 break;
5216 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5217 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5218 break;
5219 case eWNI_SME_SET_IE_REQ:
5220 lim_process_set_ie_req(pMac, pMsgBuf);
5221 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305222 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5223 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5224 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305225 case eWNI_SME_EXT_CHANGE_CHANNEL:
5226 lim_process_ext_change_channel(pMac, pMsgBuf);
5227 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005228 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5229 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5230 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005231 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5232 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005233 break;
5234 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5235 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5236 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07005237 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005238 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005239 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005240 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005241 break;
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305242 case eWNI_SME_REGISTER_P2P_ACK_CB:
5243 lim_register_p2p_ack_ind_cb(pMac, pMsgBuf);
5244 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305245 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5246 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5247 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07005248 case eWNI_SME_UPDATE_CONFIG:
5249 lim_process_sme_update_config(pMac,
5250 (struct update_config *)pMsgBuf);
5251 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005252 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305253 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005254 pMsg->bodyptr = NULL;
5255 break;
5256 } /* switch (msgType) */
5257
5258 return bufConsumed;
5259} /*** end lim_process_sme_req_messages() ***/
5260
5261/**
5262 * lim_process_sme_start_beacon_req()
5263 *
5264 ***FUNCTION:
5265 * This function is called by limProcessMessageQueue(). This
5266 * function processes SME request messages from HDD or upper layer
5267 * application.
5268 *
5269 ***LOGIC:
5270 *
5271 ***ASSUMPTIONS:
5272 *
5273 ***NOTE:
5274 *
5275 * @param pMac Pointer to Global MAC structure
5276 * @param msgType Indicates the SME message type
5277 * @param *pMsgBuf A pointer to the SME message buffer
5278 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5279 * false - if pMsgBuf is not to be freed.
5280 */
5281static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5282{
5283 tpSirStartBeaconIndication pBeaconStartInd;
5284 tpPESession psessionEntry;
5285 uint8_t sessionId; /* PE sessionID */
5286
5287 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005288 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005289 return;
5290 }
5291
5292 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5293 psessionEntry = pe_find_session_by_bssid(pMac,
5294 pBeaconStartInd->bssid,
5295 &sessionId);
5296 if (psessionEntry == NULL) {
5297 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005298 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005299 return;
5300 }
5301
5302 if (pBeaconStartInd->beaconStartStatus == true) {
5303 /*
5304 * Currently this Indication comes from SAP
5305 * to start Beacon Tx on a DFS channel
5306 * since beaconing has to be done on DFS
5307 * channel only after CAC WAIT is completed.
5308 * On a DFS Channel LIM does not start beacon
5309 * Tx right after the WMA_ADD_BSS_RSP.
5310 */
5311 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05305312 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005313 FL("Start Beacon with ssid %s Ch %d"),
5314 psessionEntry->ssId.ssId,
5315 psessionEntry->currentOperChannel);
5316 lim_send_beacon_ind(pMac, psessionEntry);
5317 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005318 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005319 return;
5320 }
5321}
5322
5323/**
5324 * lim_process_sme_channel_change_request() - process sme ch change req
5325 *
5326 * @mac_ctx: Pointer to Global MAC structure
5327 * @msg_buf: pointer to the SME message buffer
5328 *
5329 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5330 *
5331 * Return: None
5332 */
5333static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5334 uint32_t *msg_buf)
5335{
5336 tpSirChanChangeRequest ch_change_req;
5337 tpPESession session_entry;
5338 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005339 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005340 uint32_t val = 0;
5341
5342 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005343 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005344 return;
5345 }
5346 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5347
5348 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5349 ch_change_req->targetChannel);
5350
5351 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5352 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005353 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005354 return;
5355 }
5356
5357 session_entry = pe_find_session_by_bssid(mac_ctx,
5358 ch_change_req->bssid, &session_id);
5359 if (session_entry == NULL) {
5360 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005361 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005362 return;
5363 }
5364
5365 if (session_entry->currentOperChannel ==
5366 ch_change_req->targetChannel) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005367 pe_err("target CH is same as current CH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005368 return;
5369 }
5370
5371 if (LIM_IS_AP_ROLE(session_entry))
5372 session_entry->channelChangeReasonCode =
5373 LIM_SWITCH_CHANNEL_SAP_DFS;
5374 else
5375 session_entry->channelChangeReasonCode =
5376 LIM_SWITCH_CHANNEL_OPERATION;
5377
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005378 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005379 session_entry->currentOperChannel,
5380 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005381 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005382
5383 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005384 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005385 session_entry->ch_center_freq_seg0 =
5386 ch_change_req->center_freq_seg_0;
5387 session_entry->ch_center_freq_seg1 =
5388 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005389 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005390 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005391 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005392 session_entry->htRecommendedTxWidthSet =
5393 session_entry->htSupportedChannelWidthSet;
5394 session_entry->currentOperChannel =
5395 ch_change_req->targetChannel;
5396 session_entry->limRFBand =
5397 lim_get_rf_band(session_entry->currentOperChannel);
5398 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08005399 if (CHAN_HOP_ALL_BANDS_ENABLE ||
5400 SIR_BAND_5_GHZ == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005401 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5402 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005403 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005404 }
5405
5406 session_entry->lim11hEnable = val;
5407 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305408 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005409 &ch_change_req->operational_rateset,
5410 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305411 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005412 &ch_change_req->extended_rateset,
5413 sizeof(session_entry->extRateSet));
5414 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5415 session_entry->ch_center_freq_seg0,
5416 session_entry->ch_center_freq_seg1,
5417 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07005418 max_tx_pwr, session_entry->peSessionId,
5419 ch_change_req->cac_duration_ms,
5420 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005421}
5422
5423/******************************************************************************
5424* lim_start_bss_update_add_ie_buffer()
5425*
5426***FUNCTION:
5427* This function checks the src buffer and its length and then malloc for
5428* dst buffer update the same
5429*
5430***LOGIC:
5431*
5432***ASSUMPTIONS:
5433*
5434***NOTE:
5435*
5436* @param pMac Pointer to Global MAC structure
5437* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5438* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5439* @param *pSrcData_buff A pointer of uint8_t src buffer
5440* @param srcDataLen src buffer length
5441******************************************************************************/
5442
5443static void
5444lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5445 uint8_t **pDstData_buff,
5446 uint16_t *pDstDataLen,
5447 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5448{
5449
5450 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5451 *pDstDataLen = srcDataLen;
5452
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305453 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005454
5455 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005456 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005457 return;
5458 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305459 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005460 } else {
5461 *pDstData_buff = NULL;
5462 *pDstDataLen = 0;
5463 }
5464}
5465
5466/******************************************************************************
5467* lim_update_add_ie_buffer()
5468*
5469***FUNCTION:
5470* This function checks the src buffer and length if src buffer length more
5471* than dst buffer length then free the dst buffer and malloc for the new src
5472* length, and update the dst buffer and length. But if dst buffer is bigger
5473* than src buffer length then it just update the dst buffer and length
5474*
5475***LOGIC:
5476*
5477***ASSUMPTIONS:
5478*
5479***NOTE:
5480*
5481* @param pMac Pointer to Global MAC structure
5482* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5483* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5484* @param *pSrcData_buff A pointer of uint8_t src buffer
5485* @param srcDataLen src buffer length
5486******************************************************************************/
5487
5488static void
5489lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5490 uint8_t **pDstData_buff,
5491 uint16_t *pDstDataLen,
5492 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5493{
5494
5495 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005496 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005497 return;
5498 }
5499
5500 if (srcDataLen > *pDstDataLen) {
5501 *pDstDataLen = srcDataLen;
5502 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305503 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005504 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305505 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005506
5507 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005508 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005509 *pDstDataLen = 0;
5510 return;
5511 }
5512 }
5513
5514 /* copy the content of buffer into dst buffer
5515 */
5516 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305517 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005518
5519}
5520
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005521/**
5522 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5523 * @pMac : Pointer to Global MAC structure
5524 * @pDstData_buff : A pointer to pointer of dst buffer
5525 * @pDstDataLen : A pointer to pointer of dst buffer length
5526 * @pModifyIE : A pointer to tSirModifyIE
5527 *
5528 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5529 *
5530 * Return:
5531 * True or false depending upon whether IE is updated or not
5532 */
5533static bool
5534lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5535 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5536{
Hong Shi1553d692016-09-28 12:16:19 +08005537 int32_t oui_length;
5538 uint8_t *ibss_ie = NULL;
5539 uint8_t *vendor_ie;
5540#define MAC_VENDOR_OUI "\x00\x16\x32"
5541#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005542
5543 ibss_ie = pModifyIE->pIEBuffer;
5544 oui_length = pModifyIE->oui_length;
5545
5546 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005547 pe_err("Invalid set IBSS vendor IE command length %d",
5548 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005549 return false;
5550 }
5551
Hong Shi1553d692016-09-28 12:16:19 +08005552 /*
5553 * Why replace only beacon OUI data here:
5554 * 1. other ie (such as wpa) shall not be overwritten here.
5555 * 2. per spec, beacon oui ie might be set twice and original one
5556 * shall be updated.
5557 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005558 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005559 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5560 if (vendor_ie) {
5561 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5562 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5563 pModifyIE->ieBufferlength);
5564 } else {
5565 uint16_t new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5566 uint8_t *new_ptr = qdf_mem_malloc(new_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005567
Hong Shi1553d692016-09-28 12:16:19 +08005568 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005569 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005570 return false;
5571 }
5572 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5573 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5574 pModifyIE->ieBufferlength);
5575 qdf_mem_free(*pDstData_buff);
5576 *pDstDataLen = new_length;
5577 *pDstData_buff = new_ptr;
5578 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005579 return true;
5580}
5581
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005582/*
5583* lim_process_modify_add_ies() - process modify additional IE req.
5584*
5585* @mac_ctx: Pointer to Global MAC structure
5586* @msg_buf: pointer to the SME message buffer
5587*
5588* This function update the PE buffers for additional IEs.
5589*
5590* Return: None
5591*/
5592static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5593 uint32_t *msg_buf)
5594{
5595 tpSirModifyIEsInd modify_add_ies;
5596 tpPESession session_entry;
5597 uint8_t session_id;
5598 bool ret = false;
5599 tSirAddIeParams *add_ie_params;
5600
5601 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005602 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005603 return;
5604 }
5605
5606 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5607 /* Incoming message has smeSession, use BSSID to find PE session */
5608 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005609 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005610
5611 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005612 pe_err("Session not found for given bssid"
5613 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005614 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005615 goto end;
5616 }
5617 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5618 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5619 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005620 pe_err("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005621 modify_add_ies->modifyIE.pIEBuffer,
5622 modify_add_ies->modifyIE.ieBufferlength,
5623 modify_add_ies->modifyIE.ieID,
5624 modify_add_ies->modifyIE.ieIDLen,
5625 modify_add_ies->updateType);
5626 goto end;
5627 }
5628 add_ie_params = &session_entry->addIeParams;
5629 switch (modify_add_ies->updateType) {
5630 case eUPDATE_IE_PROBE_RESP:
5631 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005632 if (LIM_IS_IBSS_ROLE(session_entry)) {
5633 lim_update_ibss_prop_add_ies(mac_ctx,
5634 &add_ie_params->probeRespData_buff,
5635 &add_ie_params->probeRespDataLen,
5636 &modify_add_ies->modifyIE);
5637 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005638 break;
5639 case eUPDATE_IE_ASSOC_RESP:
5640 /* assoc resp IE */
5641 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305642 QDF_TRACE(QDF_MODULE_ID_PE,
5643 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005644 "assoc resp add ie not present %d"),
5645 add_ie_params->assocRespDataLen);
5646 }
5647 /* search through the buffer and modify the IE */
5648 break;
5649 case eUPDATE_IE_PROBE_BCN:
5650 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005651 if (LIM_IS_IBSS_ROLE(session_entry)) {
5652 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5653 &add_ie_params->probeRespBCNData_buff,
5654 &add_ie_params->probeRespBCNDataLen,
5655 &modify_add_ies->modifyIE);
5656 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005657 if (ret == true && modify_add_ies->modifyIE.notify) {
5658 lim_handle_param_update(mac_ctx,
5659 modify_add_ies->updateType);
5660 }
5661 break;
5662 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005663 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005664 modify_add_ies->updateType);
5665 break;
5666 }
5667end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305668 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005669 modify_add_ies->modifyIE.pIEBuffer = NULL;
5670}
5671
5672/*
5673* lim_process_update_add_ies() - process additional IE update req
5674*
5675* @mac_ctx: Pointer to Global MAC structure
5676* @msg_buf: pointer to the SME message buffer
5677*
5678* This function update the PE buffers for additional IEs.
5679*
5680* Return: None
5681*/
5682static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5683 uint32_t *msg_buf)
5684{
5685 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5686 uint8_t session_id;
5687 tpPESession session_entry;
5688 tSirAddIeParams *addn_ie;
5689 uint16_t new_length = 0;
5690 uint8_t *new_ptr = NULL;
5691 tSirUpdateIE *update_ie;
5692
5693 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005694 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005695 return;
5696 }
5697 update_ie = &update_add_ies->updateIE;
5698 /* incoming message has smeSession, use BSSID to find PE session */
5699 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005700 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005701
5702 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005703 pe_err("Session not found for given bssid"
5704 MAC_ADDRESS_STR,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005705 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005706 goto end;
5707 }
5708 addn_ie = &session_entry->addIeParams;
5709 /* if len is 0, upper layer requested freeing of buffer */
5710 if (0 == update_ie->ieBufferlength) {
5711 switch (update_add_ies->updateType) {
5712 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305713 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005714 addn_ie->probeRespData_buff = NULL;
5715 addn_ie->probeRespDataLen = 0;
5716 break;
5717 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305718 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005719 addn_ie->assocRespData_buff = NULL;
5720 addn_ie->assocRespDataLen = 0;
5721 break;
5722 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305723 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005724 addn_ie->probeRespBCNData_buff = NULL;
5725 addn_ie->probeRespBCNDataLen = 0;
5726
5727 if (update_ie->notify)
5728 lim_handle_param_update(mac_ctx,
5729 update_add_ies->updateType);
5730 break;
5731 default:
5732 break;
5733 }
5734 return;
5735 }
5736 switch (update_add_ies->updateType) {
5737 case eUPDATE_IE_PROBE_RESP:
5738 if (update_ie->append) {
5739 /*
5740 * In case of append, allocate new memory
5741 * with combined length
5742 */
5743 new_length = update_ie->ieBufferlength +
5744 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305745 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005746 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005747 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005748 goto end;
5749 }
5750 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305751 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005752 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305753 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005754 update_ie->pAdditionIEBuffer,
5755 update_ie->ieBufferlength);
5756 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305757 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005758 /* adjust length accordingly */
5759 addn_ie->probeRespDataLen = new_length;
5760 /* save refernece of local buffer in PE session */
5761 addn_ie->probeRespData_buff = new_ptr;
5762 goto end;
5763 }
5764 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5765 &addn_ie->probeRespDataLen,
5766 update_ie->pAdditionIEBuffer,
5767 update_ie->ieBufferlength);
5768 break;
5769 case eUPDATE_IE_ASSOC_RESP:
5770 /* assoc resp IE */
5771 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5772 &addn_ie->assocRespDataLen,
5773 update_ie->pAdditionIEBuffer,
5774 update_ie->ieBufferlength);
5775 break;
5776 case eUPDATE_IE_PROBE_BCN:
5777 /* probe resp Bcn IE */
5778 lim_update_add_ie_buffer(mac_ctx,
5779 &addn_ie->probeRespBCNData_buff,
5780 &addn_ie->probeRespBCNDataLen,
5781 update_ie->pAdditionIEBuffer,
5782 update_ie->ieBufferlength);
5783 if (update_ie->notify)
5784 lim_handle_param_update(mac_ctx,
5785 update_add_ies->updateType);
5786 break;
5787 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005788 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005789 break;
5790 }
5791end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305792 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005793 update_ie->pAdditionIEBuffer = NULL;
5794}
5795
5796/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305797 * send_extended_chan_switch_action_frame()- function to send ECSA
5798 * action frame for each sta connected to SAP/GO and AP in case of
5799 * STA .
5800 * @mac_ctx: pointer to global mac structure
5801 * @new_channel: new channel to switch to.
5802 * @ch_bandwidth: BW of channel to calculate op_class
5803 * @session_entry: pe session
5804 *
5805 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5806 *
5807 * Return: void
5808 */
5809
5810static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5811 uint16_t new_channel, uint8_t ch_bandwidth,
5812 tpPESession session_entry)
5813{
5814 uint16_t op_class;
5815 uint8_t switch_mode = 0, i;
5816 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005817 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305818
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005819 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305820 mac_ctx->scan.countryCodeCurrent,
5821 new_channel,
5822 ch_bandwidth);
5823
5824 if (LIM_IS_AP_ROLE(session_entry) &&
5825 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005826 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305827
gaoleze2920bd2017-03-21 17:38:42 +08005828 switch_count = session_entry->gLimChannelSwitch.switchCount;
5829
Abhishek Singh518323d2015-10-19 17:42:01 +05305830 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005831 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305832 psta =
5833 session_entry->dph.dphHashTable.pDphNodeArray + i;
5834 if (psta && psta->added)
5835 lim_send_extended_chan_switch_action_frame(
5836 mac_ctx,
5837 psta->staAddr,
5838 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005839 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305840 }
5841 } else if (LIM_IS_STA_ROLE(session_entry)) {
5842 lim_send_extended_chan_switch_action_frame(mac_ctx,
5843 session_entry->bssId,
5844 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005845 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305846 }
5847
5848}
5849
5850/**
gaolez76d2a162017-03-21 19:23:58 +08005851 * lim_send_chan_switch_action_frame()- Send an action frame
5852 * containing CSA IE or ECSA IE depending on the connected
5853 * sta capability.
5854 *
5855 * @mac_ctx: pointer to global mac structure
5856 * @new_channel: new channel to switch to.
5857 * @ch_bandwidth: BW of channel to calculate op_class
5858 * @session_entry: pe session
5859 *
5860 * Return: void
5861 */
5862static
5863void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5864 uint16_t new_channel,
5865 uint8_t ch_bandwidth,
5866 tpPESession session_entry)
5867{
5868 uint16_t op_class;
5869 uint8_t switch_mode = 0, i;
5870 uint8_t switch_count;
5871 tpDphHashNode psta;
5872 tpDphHashNode dph_node_array_ptr;
5873
5874 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5875
5876 op_class = wlan_reg_dmn_get_opclass_from_channel(
5877 mac_ctx->scan.countryCodeCurrent,
5878 new_channel, ch_bandwidth);
5879
5880 if (LIM_IS_AP_ROLE(session_entry) &&
5881 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5882 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5883
5884 switch_count = session_entry->gLimChannelSwitch.switchCount;
5885
5886 if (LIM_IS_AP_ROLE(session_entry)) {
5887 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5888 psta = dph_node_array_ptr + i;
5889 if (!(psta && psta->added))
5890 continue;
5891 if (session_entry->lim_non_ecsa_cap_num == 0)
5892 lim_send_extended_chan_switch_action_frame
5893 (mac_ctx, psta->staAddr, switch_mode,
5894 op_class, new_channel, switch_count,
5895 session_entry);
5896 else
5897 lim_send_channel_switch_mgmt_frame
5898 (mac_ctx, psta->staAddr, switch_mode,
5899 new_channel, switch_count,
5900 session_entry);
5901 }
5902 } else if (LIM_IS_STA_ROLE(session_entry)) {
5903 lim_send_extended_chan_switch_action_frame
5904 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5905 new_channel, switch_count, session_entry);
5906 }
5907}
5908
5909/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005910 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5911 *
5912 * @mac_ctx: Pointer to Global MAC structure
5913 * @msg_buf: pointer to the SME message buffer
5914 *
5915 * This function processes SME request messages from HDD or upper layer
5916 * application.
5917 *
5918 * Return: None
5919 */
5920static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5921 uint32_t *msg_buf)
5922{
5923 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5924 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005925 uint8_t session_id;
5926 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005927 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005928
5929 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005930 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005931 return;
5932 }
5933
5934 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5935 session_entry = pe_find_session_by_bssid(mac_ctx,
5936 dfs_csa_ie_req->bssid, &session_id);
5937 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005938 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005939 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5940 return;
5941 }
5942
5943 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005944 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005945 GET_LIM_SYSTEM_ROLE(session_entry));
5946 return;
5947 }
5948
5949 /* target channel */
5950 session_entry->gLimChannelSwitch.primaryChannel =
5951 dfs_csa_ie_req->targetChannel;
5952
5953 /* Channel switch announcement needs to be included in beacon */
5954 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005955 session_entry->gLimChannelSwitch.switchCount =
5956 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005957 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005958 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305959 session_entry->gLimChannelSwitch.sec_ch_offset =
5960 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005961 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005962 session_entry->gLimChannelSwitch.switchMode =
5963 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005964
5965 /*
5966 * Validate if SAP is operating HT or VHT mode and set the Channel
5967 * Switch Wrapper element with the Wide Band Switch subelement.
5968 */
5969 if (true != session_entry->vhtCapability)
5970 goto skip_vht;
5971
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005972 /* Now encode the Wider Ch BW element depending on the ch width */
5973 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005974 switch (dfs_csa_ie_req->ch_params.ch_width) {
5975 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005976 /*
5977 * Wide channel BW sublement in channel wrapper element is not
5978 * required in case of 20 Mhz operation. Currently It is set
5979 * only set in case of 40/80 Mhz Operation.
5980 */
5981 session_entry->dfsIncludeChanWrapperIe = false;
5982 wider_bw_ch_switch->newChanWidth =
5983 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5984 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005985 case CH_WIDTH_40MHZ:
5986 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005987 wider_bw_ch_switch->newChanWidth =
5988 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5989 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005990 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005991 session_entry->dfsIncludeChanWrapperIe = true;
5992 wider_bw_ch_switch->newChanWidth =
5993 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5994 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005995 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005996 session_entry->dfsIncludeChanWrapperIe = true;
5997 wider_bw_ch_switch->newChanWidth =
5998 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5999 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006000 case CH_WIDTH_80P80MHZ:
6001 session_entry->dfsIncludeChanWrapperIe = true;
6002 wider_bw_ch_switch->newChanWidth =
6003 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08006004 /*
6005 * This is not applicable for 20/40/80 Mhz.
6006 * Only used when we support 80+80 Mhz operation.
6007 * In case of 80+80 Mhz, this parameter indicates
6008 * center channel frequency index of 80 Mhz channel of
6009 * frequency segment 1.
6010 */
6011 wider_bw_ch_switch->newCenterChanFreq1 =
6012 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006013 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006014 default:
6015 session_entry->dfsIncludeChanWrapperIe = false;
6016 /*
6017 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
6018 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
6019 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006020 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006021 break;
6022 }
6023 /* Fetch the center channel based on the channel width */
6024 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006025 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006026skip_vht:
6027 /* Send CSA IE request from here */
6028 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6029 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006030 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006031 return;
6032 }
6033
6034 /*
6035 * First beacon update request is sent here, the remaining updates are
6036 * done when the FW responds back after sending the first beacon after
6037 * the template update
6038 */
6039 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306040
6041 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
6042 ch_offset = BW80;
6043 else
6044 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
6045
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006046 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306047 session_entry->gLimChannelSwitch.switchCount,
6048 session_entry->gLimChannelSwitch.primaryChannel,
6049 session_entry->gLimChannelSwitch.ch_width,
6050 session_entry->dfsIncludeChanWrapperIe,
6051 ch_offset);
6052
gaolez76d2a162017-03-21 19:23:58 +08006053 /* Send ECSA/CSA Action frame after updating the beacon */
6054 if (CHAN_HOP_ALL_BANDS_ENABLE)
6055 lim_send_chan_switch_action_frame(mac_ctx,
6056 session_entry->gLimChannelSwitch.primaryChannel,
6057 ch_offset, session_entry);
6058 else
6059 send_extended_chan_switch_action_frame(mac_ctx,
6060 session_entry->gLimChannelSwitch.primaryChannel,
6061 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006062 session_entry->gLimChannelSwitch.switchCount--;
6063}
6064
6065/**
Abhishek Singh518323d2015-10-19 17:42:01 +05306066 * lim_process_ext_change_channel()- function to send ECSA
6067 * action frame for STA/CLI .
6068 * @mac_ctx: pointer to global mac structure
6069 * @msg: params from sme for new channel.
6070 *
6071 * This function is called to send ECSA frame for STA/CLI.
6072 *
6073 * Return: void
6074 */
6075
6076static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
6077 uint32_t *msg)
6078{
6079 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
6080 (struct sir_sme_ext_cng_chan_req *) msg;
6081 tpPESession session_entry = NULL;
6082
6083 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006084 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05306085 return;
6086 }
6087 session_entry =
6088 pe_find_session_by_sme_session_id(mac_ctx,
6089 ext_chng_channel->session_id);
6090 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006091 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05306092 ext_chng_channel->session_id);
6093 return;
6094 }
6095 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006096 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05306097 return;
6098 }
6099 send_extended_chan_switch_action_frame(mac_ctx,
6100 ext_chng_channel->new_channel,
6101 0, session_entry);
6102}
6103
6104/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006105 * lim_process_nss_update_request() - process sme nss update req
6106 *
6107 * @mac_ctx: Pointer to Global MAC structure
6108 * @msg_buf: pointer to the SME message buffer
6109 *
6110 * This function processes SME request messages from HDD or upper layer
6111 * application.
6112 *
6113 * Return: None
6114 */
6115static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
6116 uint32_t *msg_buf)
6117{
6118 struct sir_nss_update_request *nss_update_req_ptr;
6119 tpPESession session_entry = NULL;
6120
6121 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006122 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006123 return;
6124 }
6125
6126 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05306127 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006128 nss_update_req_ptr->vdev_id);
6129 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006130 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006131 nss_update_req_ptr->vdev_id);
6132 return;
6133 }
6134
6135 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006136 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006137 GET_LIM_SYSTEM_ROLE(session_entry));
6138 return;
6139 }
6140
6141 /* populate nss field in the beacon */
6142 session_entry->gLimOperatingMode.present = 1;
6143 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05306144 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
6145
6146 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
6147 (session_entry->ch_width > CH_WIDTH_80MHZ))
6148 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
6149
6150 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
6151
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006152 /* Send nss update request from here */
6153 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6154 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006155 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006156 return;
6157 }
6158
6159 lim_send_beacon_ind(mac_ctx, session_entry);
6160}
6161
6162/**
6163 * lim_process_set_ie_req() - process sme set IE request
6164 *
6165 * @mac_ctx: Pointer to Global MAC structure
6166 * @msg_buf: pointer to the SME message buffer
6167 *
6168 * This function processes SME request messages from HDD or upper layer
6169 * application.
6170 *
6171 * Return: None
6172 */
6173static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6174{
6175 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306176 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006177
6178 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006179 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006180 return;
6181 }
6182
6183 msg = (struct send_extcap_ie *)msg_buf;
6184 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306185 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006186 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006187
6188}