blob: 3ec5b4418175ee5b62b3cb8f4fa59bb8c6ff002f [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
614}
615
616/**
617 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
618 *@mac_ctx: Pointer to Global MAC structure
619 *@msg_buf: A pointer to the SME message buffer
620 *
621 * This function is called to process SME_START_BSS_REQ message
622 * from HDD or upper layer application.
623 *
624 * Return: None
625 */
626static void
627__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
628{
629 uint16_t size;
630 uint32_t val = 0;
631 tSirRetStatus ret_status;
632 tSirMacChanNum channel_number;
633 tLimMlmStartReq *mlm_start_req = NULL;
634 tpSirSmeStartBssReq sme_start_bss_req = NULL;
635 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
636 /* Flag Used in case of IBSS to Auto generate BSSID. */
637 uint32_t auto_gen_bssid = false;
638 uint8_t session_id;
639 tpPESession session = NULL;
Krunal Sonib37bb352016-12-20 14:12:21 -0800640 uint8_t sme_session_id = 0xFF;
641 uint16_t sme_transaction_id = 0xFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800642 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700643 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800644 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
645
646/* FEATURE_WLAN_DIAG_SUPPORT */
647#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
648 /*
649 * Since the session is not created yet, sending NULL.
650 * The response should have the correct state.
651 */
652 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
653 NULL, 0, 0);
654#endif /* FEATURE_WLAN_DIAG_SUPPORT */
655
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700656 pe_debug("Received START_BSS_REQ");
Krunal Sonib37bb352016-12-20 14:12:21 -0800657 size = sizeof(tSirSmeStartBssReq);
658 sme_start_bss_req = qdf_mem_malloc(size);
659 if (NULL == sme_start_bss_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700660 pe_err("Allocate Memory fail for LimStartBssReq");
Krunal Sonib37bb352016-12-20 14:12:21 -0800661 /* Send failure response to host */
662 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
663 goto free;
664 }
665 qdf_mem_copy(sme_start_bss_req, msg_buf, sizeof(tSirSmeStartBssReq));
666 sme_session_id = sme_start_bss_req->sessionId;
667 sme_transaction_id = sme_start_bss_req->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800668
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800669 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
670 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800671 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
672 sme_start_bss_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700673 pe_warn("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800674 ret_code = eSIR_SME_INVALID_PARAMETERS;
675 goto free;
676 }
677
678 /*
679 * This is the place where PE is going to create a session.
680 * If session is not existed, then create a new session
681 */
682 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800683 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800684 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700685 pe_warn("Session Already exists for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800686 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
687 session = NULL;
688 goto free;
689 } else {
690 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800691 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800692 &session_id, mac_ctx->lim.maxStation,
693 sme_start_bss_req->bssType);
694 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700695 pe_warn("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800696 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
697 goto free;
698 }
699 }
700
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700701 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
702 /* Probe resp add ie */
703 lim_start_bss_update_add_ie_buffer(mac_ctx,
704 &session->addIeParams.probeRespData_buff,
705 &session->addIeParams.probeRespDataLen,
706 sme_start_bss_req->addIeParams.
707 probeRespData_buff,
708 sme_start_bss_req->addIeParams.
709 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800710
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700711 /* Probe Beacon add ie */
712 lim_start_bss_update_add_ie_buffer(mac_ctx,
713 &session->addIeParams.probeRespBCNData_buff,
714 &session->addIeParams.probeRespBCNDataLen,
715 sme_start_bss_req->addIeParams.
716 probeRespBCNData_buff,
717 sme_start_bss_req->addIeParams.
718 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800719
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700720 /* Assoc resp IE */
721 lim_start_bss_update_add_ie_buffer(mac_ctx,
722 &session->addIeParams.assocRespData_buff,
723 &session->addIeParams.assocRespDataLen,
724 sme_start_bss_req->addIeParams.
725 assocRespData_buff,
726 sme_start_bss_req->addIeParams.
727 assocRespDataLen);
728 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800729 /* Store the session related params in newly created session */
730 session->pLimStartBssReq = sme_start_bss_req;
731
732 /* Store PE session_id in session Table */
733 session->peSessionId = session_id;
734
735 /* Store SME session Id in sessionTable */
736 session->smeSessionId = sme_start_bss_req->sessionId;
737
738 session->transactionId = sme_start_bss_req->transactionId;
739
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530740 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800741 &(sme_start_bss_req->htConfig),
742 sizeof(session->htConfig));
743
Sandeep Puligilla98917432016-06-10 13:50:28 -0700744 qdf_mem_copy(&(session->vht_config),
745 &(sme_start_bss_req->vht_config),
746 sizeof(session->vht_config));
747
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800748 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800749 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800750
751 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530752 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800753 (uint8_t *) &sme_start_bss_req->ssId,
754 (sme_start_bss_req->ssId.length + 1));
755
756 session->bssType = sme_start_bss_req->bssType;
757
758 session->nwType = sme_start_bss_req->nwType;
759
760 session->beaconParams.beaconInterval =
761 sme_start_bss_req->beaconInterval;
762
763 /* Store the channel number in session Table */
764 session->currentOperChannel =
765 sme_start_bss_req->channelId;
766
767 /* Store Persona */
768 session->pePersona = sme_start_bss_req->bssPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +0530769 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800770 FL("PE PERSONA=%d"), session->pePersona);
771
772 /* Update the phymode */
773 session->gLimPhyMode = sme_start_bss_req->nwType;
774
775 session->maxTxPower =
776 cfg_get_regulatory_max_transmit_power(mac_ctx,
777 session->currentOperChannel);
778 /* Store the dot 11 mode in to the session Table */
779 session->dot11mode = sme_start_bss_req->dot11mode;
780#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
781 session->cc_switch_mode =
782 sme_start_bss_req->cc_switch_mode;
783#endif
784 session->htCapability =
785 IS_DOT11_MODE_HT(session->dot11mode);
786 session->vhtCapability =
787 IS_DOT11_MODE_VHT(session->dot11mode);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800788
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700789 pe_debug("HT[%d], VHT[%d]",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800790 session->htCapability, session->vhtCapability);
791
792 if (IS_DOT11_MODE_HE(session->dot11mode)) {
793 lim_update_session_he_capable(mac_ctx, session);
794 lim_copy_bss_he_cap(session, sme_start_bss_req);
795 }
796
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800797 session->txLdpcIniFeatureEnabled =
798 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800799#ifdef WLAN_FEATURE_11W
800 session->limRmfEnabled =
801 sme_start_bss_req->pmfCapable ? 1 : 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700802 pe_debug("Session RMF enabled: %d", session->limRmfEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803#endif
804
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530805 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800806 (void *)&sme_start_bss_req->operationalRateSet,
807 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530808 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800809 (void *)&sme_start_bss_req->extendedRateSet,
810 sizeof(tSirMacRateSet));
811
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700812 if (IS_5G_CH(session->currentOperChannel))
813 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
814 else
815 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
816
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800817 switch (sme_start_bss_req->bssType) {
818 case eSIR_INFRA_AP_MODE:
819 lim_configure_ap_start_bss_session(mac_ctx, session,
820 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700821 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700822 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700823 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700824 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800825 break;
826 case eSIR_IBSS_MODE:
827 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
828 lim_get_short_slot_from_phy_mode(mac_ctx, session,
829 session->gLimPhyMode,
830 &session->shortSlotTimeSupported);
831
832 /*
833 * initialize to "OPEN".
834 * will be updated upon key installation
835 */
836 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700837 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838
839 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700840 case eSIR_NDI_MODE:
841 session->limSystemRole = eLIM_NDI_ROLE;
842 break;
843
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800844
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800845 /*
846 * There is one more mode called auto mode.
847 * which is used no where
848 */
849
850 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
851
852 default:
853 /* not used anywhere...used in scan function */
854 break;
855 }
856
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700857 pe_debug("persona - %d, nss - %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700858 session->pePersona, session->vdev_nss);
859 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800860 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700861 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800862 * parsed (Re)Assoc request structure
863 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700864 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800865 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530866 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700867 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868 if (NULL == session->parsedAssocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700869 pe_warn("AllocateMemory() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800870 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
871 goto free;
872 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873 }
874
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700875 if (!sme_start_bss_req->channelId &&
876 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700877 pe_err("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800878 ret_code = eSIR_SME_INVALID_PARAMETERS;
879 goto free;
880 }
881 channel_number = sme_start_bss_req->channelId;
882#ifdef QCA_HT_2040_COEX
883 if (sme_start_bss_req->obssEnabled)
884 session->htSupportedChannelWidthSet =
885 session->htCapability;
886 else
887#endif
888 session->htSupportedChannelWidthSet =
889 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
890 session->htSecondaryChannelOffset =
891 sme_start_bss_req->sec_ch_offset;
892 session->htRecommendedTxWidthSet =
893 (session->htSecondaryChannelOffset) ? 1 : 0;
Abhishek Singh4294f802017-08-10 16:37:07 +0530894 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800895 FL("cbMode %u"), sme_start_bss_req->cbMode);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800896 if (lim_is_session_he_capable(session) ||
897 session->vhtCapability || session->htCapability) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800898 chanwidth = sme_start_bss_req->vht_channel_width;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700899 pe_debug("vht_channel_width %u htSupportedChannelWidthSet %d",
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800900 sme_start_bss_req->vht_channel_width,
901 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800902 session->ch_width = chanwidth;
903 if (session->htSupportedChannelWidthSet) {
904 session->ch_center_freq_seg0 =
905 sme_start_bss_req->center_freq_seg0;
906 session->ch_center_freq_seg1 =
907 sme_start_bss_req->center_freq_seg1;
908 } else {
909 session->ch_center_freq_seg0 = 0;
910 session->ch_center_freq_seg1 = 0;
911 }
912 }
913
914 if (session->vhtCapability &&
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800915 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800916 session->nss = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700917 pe_debug("nss set to [%d]", session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800918 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700919 pe_debug("vht su tx bformer %d",
Krunal Soni53993f72016-07-08 18:20:03 -0700920 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800921
922 /* Delete pre-auth list if any */
923 lim_delete_pre_auth_list(mac_ctx);
924
Krunal Soni53993f72016-07-08 18:20:03 -0700925 if (session->nss == 1) {
926 session->vht_config.su_beam_former = 0;
927 session->vht_config.tx_stbc = 0;
928 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530929 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -0700930 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800931 /*
932 * keep the RSN/WPA IE information in PE Session Entry
933 * later will be using this to check when received (Re)Assoc req
934 */
935 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
936 &sme_start_bss_req->rsnIE, session);
937
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700938 if (LIM_IS_AP_ROLE(session) ||
939 LIM_IS_IBSS_ROLE(session) ||
940 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800941 session->gLimProtectionControl =
942 sme_start_bss_req->protEnabled;
943 /*
944 * each byte will have the following info
945 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
946 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
947 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530948 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800949 (void *)&sme_start_bss_req->ht_capab,
950 sizeof(uint16_t));
951 /* Initialize WPS PBC session link list */
952 session->pAPWPSPBCSession = NULL;
953 }
954 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530955 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800956 if (NULL == mlm_start_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700957 pe_err("Allocate Memory failed for mlmStartReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800958 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
959 goto free;
960 }
961
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800962 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530963 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800964 (uint8_t *) &sme_start_bss_req->ssId,
965 sme_start_bss_req->ssId.length + 1);
966 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
967 mlm_start_req->obssProtEnabled =
968 sme_start_bss_req->obssProtEnabled;
969
970 mlm_start_req->bssType = session->bssType;
971
972 /* Fill PE session Id from the session Table */
973 mlm_start_req->sessionId = session->peSessionId;
974
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700975 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
976 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800977 /*
978 * Copy the BSSId from sessionTable to
979 * mlmStartReq struct
980 */
981 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
982 } else {
983 /* ibss mode */
984 mac_ctx->lim.gLimIbssCoalescingHappened = false;
985
986 ret_status = wlan_cfg_get_int(mac_ctx,
987 WNI_CFG_IBSS_AUTO_BSSID,
988 &auto_gen_bssid);
989 if (ret_status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700990 pe_err("Get Auto Gen BSSID fail,Status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800991 ret_status);
Abhishek Singh4294f802017-08-10 16:37:07 +0530992 ret_code = eSIR_LOGE_EXCEPTION;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800993 goto free;
994 }
995
996 if (!auto_gen_bssid) {
997 /*
998 * We're not auto generating BSSID.
999 * Instead, get it from session entry
1000 */
1001 sir_copy_mac_addr(mlm_start_req->bssId,
1002 session->bssId);
1003 /*
1004 * Start IBSS group BSSID
1005 * Auto Generating BSSID.
1006 */
1007 auto_gen_bssid = ((mlm_start_req->bssId[0] &
1008 0x01) ? true : false);
1009 }
1010
1011 if (auto_gen_bssid) {
1012 /*
1013 * if BSSID is not any uc id.
1014 * then use locally generated BSSID.
1015 * Autogenerate the BSSID
1016 */
1017 lim_get_random_bssid(mac_ctx,
1018 mlm_start_req->bssId);
1019 mlm_start_req->bssId[0] = 0x02;
1020
1021 /*
1022 * Copy randomly generated BSSID
1023 * to the session Table
1024 */
1025 sir_copy_mac_addr(session->bssId,
1026 mlm_start_req->bssId);
1027 }
1028 }
1029 /* store the channel num in mlmstart req structure */
1030 mlm_start_req->channelNumber = session->currentOperChannel;
1031 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
1032 mlm_start_req->beaconPeriod =
1033 session->beaconParams.beaconInterval;
Arif Hussain671a1902017-03-17 09:08:32 -07001034 mlm_start_req->cac_duration_ms =
1035 sme_start_bss_req->cac_duration_ms;
1036 mlm_start_req->dfs_regdomain =
1037 sme_start_bss_req->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001038 if (LIM_IS_AP_ROLE(session)) {
1039 mlm_start_req->dtimPeriod = session->dtimPeriod;
1040 mlm_start_req->wps_state = session->wps_state;
1041
1042 } else {
1043 if (wlan_cfg_get_int(mac_ctx,
1044 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001045 pe_err("could not retrieve DTIM Period");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001046 mlm_start_req->dtimPeriod = (uint8_t) val;
1047 }
1048
1049 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
1050 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001051 pe_err("could not retrieve Beacon interval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001052 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
1053
1054 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
1055 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001056 pe_err("could not retrieve CFPMaxDuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001057 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1058
1059 /*
1060 * this may not be needed anymore now,
1061 * as rateSet is now included in the
1062 * session entry and MLM has session context.
1063 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301064 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001065 (void *)&session->rateSet,
1066 sizeof(tSirMacRateSet));
1067
1068 /* Now populate the 11n related parameters */
1069 mlm_start_req->nwType = session->nwType;
1070 mlm_start_req->htCapable = session->htCapability;
1071
1072 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1073 /* Unused */
1074 mlm_start_req->dualCTSProtection =
1075 mac_ctx->lim.gHTDualCTSProtection;
1076 mlm_start_req->txChannelWidthSet =
1077 session->htRecommendedTxWidthSet;
1078
1079 session->limRFBand = lim_get_rf_band(channel_number);
1080
1081 /* Initialize 11h Enable Flag */
1082 session->lim11hEnable = 0;
gaolez76d2a162017-03-21 19:23:58 +08001083 if (mlm_start_req->bssType != eSIR_IBSS_MODE &&
1084 (CHAN_HOP_ALL_BANDS_ENABLE ||
1085 SIR_BAND_5_GHZ == session->limRFBand)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001086 if (wlan_cfg_get_int(mac_ctx,
1087 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001088 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001089 else
1090 session->lim11hEnable = val;
1091
1092 if (session->lim11hEnable &&
1093 (eSIR_INFRA_AP_MODE ==
1094 mlm_start_req->bssType)) {
1095 cfg_get_wmi_dfs_master_param =
1096 wlan_cfg_get_int(mac_ctx,
1097 WNI_CFG_DFS_MASTER_ENABLED,
1098 &val);
1099 session->lim11hEnable = val;
1100 }
1101 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1102 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001103 pe_err("Get Fail, CFG DFS ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001104 }
1105
1106 if (!session->lim11hEnable) {
1107 if (cfg_set_int(mac_ctx,
1108 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1109 eSIR_SUCCESS)
1110 /*
1111 * Failed to set the CFG param
1112 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1113 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001114 pe_err("Set LOCAL_POWER_CONSTRAINT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001115 }
1116
1117 session->limPrevSmeState = session->limSmeState;
1118 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1119 MTRACE(mac_trace
1120 (mac_ctx, TRACE_CODE_SME_STATE,
1121 session->peSessionId,
1122 session->limSmeState));
1123
1124 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1125 (uint32_t *) mlm_start_req);
1126 return;
1127 } else {
1128
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001129 pe_err("Received unexpected START_BSS_REQ, in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001130 mac_ctx->lim.gLimSmeState);
1131 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001132 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001133 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1134
1135free:
1136 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001137 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001138 session->pLimStartBssReq = NULL;
1139 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001140 if (NULL != sme_start_bss_req)
1141 qdf_mem_free(sme_start_bss_req);
1142 if (NULL != mlm_start_req)
1143 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001144 if (NULL != session) {
1145 pe_delete_session(mac_ctx, session);
1146 session = NULL;
1147 }
1148 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1149 session, sme_session_id, sme_transaction_id);
1150}
1151
1152/**
1153 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1154 *
1155 * @pMac: Global MAC context
1156 * @pMsg: Message pointer
1157 *
1158 * Wrapper for the function __lim_handle_sme_start_bss_request
1159 * This message will be defered until softmac come out of
1160 * scan mode or if we have detected radar on the current
1161 * operating channel.
1162 *
1163 * return true - If we consumed the buffer
1164 * false - If have defered the message.
1165 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001166static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1167 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001168{
1169 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1170 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1171 /**
1172 * If message defered, buffer is not consumed yet.
1173 * So return false
1174 */
1175 return false;
1176 }
1177
1178 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1179 return true;
1180}
1181
1182/**
1183 * lim_get_random_bssid()
1184 *
1185 * FUNCTION:This function is called to process generate the random number for bssid
1186 * This function is called to process SME_SCAN_REQ message
1187 * from HDD or upper layer application.
1188 *
1189 * LOGIC:
1190 *
1191 * ASSUMPTIONS:
1192 *
1193 * NOTE:
1194 * 1. geneartes the unique random number for bssid in ibss
1195 *
1196 * @param pMac Pointer to Global MAC structure
1197 * @param *data Pointer to bssid buffer
1198 * @return None
1199 */
1200void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1201{
1202 uint32_t random[2];
1203 random[0] = tx_time_get();
1204 random[0] |= (random[0] << 15);
1205 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301206 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001207}
1208
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301209static QDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001210 tpSirSmeScanReq pScanReq)
1211{
1212 tSirScanOffloadReq *pScanOffloadReq;
1213 uint8_t *p;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001214 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001215 uint16_t i, len;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001216 uint16_t addn_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001217 tSirRetStatus status, rc = eSIR_SUCCESS;
1218 tDot11fIEExtCap extracted_extcap = {0};
1219 bool extcap_present = true;
1220
1221 if (pScanReq->uIEFieldLen) {
1222 status = lim_strip_extcap_update_struct(pMac,
1223 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1224 &pScanReq->uIEFieldLen, &extracted_extcap);
1225
1226 if (eSIR_SUCCESS != status) {
1227 extcap_present = false;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001228 pe_debug("Unable to Strip ExtCap IE from Scan Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229 }
1230
1231 if (extcap_present) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001232 pe_debug("Extcap was part of SCAN IE - Updating FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001233 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1234 &extracted_extcap, true);
1235 }
1236 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001237 pe_debug("No IEs in the scan request from supplicant");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001238 }
1239
1240 /**
1241 * The tSirScanOffloadReq will reserve the space for first channel,
1242 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1243 */
1244 len = sizeof(tSirScanOffloadReq) +
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001245 (pScanReq->channelList.numChannels - 1) +
1246 pScanReq->uIEFieldLen;
Naveen Rawat02e12662016-08-31 16:49:27 -07001247
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301248 pScanOffloadReq = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001249 if (NULL == pScanOffloadReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001250 pe_err("AllocateMemory failed for pScanOffloadReq");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301251 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001252 }
1253
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001254 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1255 msg.bodyptr = pScanOffloadReq;
1256 msg.bodyval = 0;
1257
Anurag Chouhanc5548422016-02-24 18:33:27 +05301258 qdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001259
1260 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001261 pe_err("Invalid value (%d) for numSsid",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001262 SIR_SCAN_MAX_NUM_SSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301263 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301264 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001265 }
1266
1267 pScanOffloadReq->numSsid = pScanReq->numSsid;
1268 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1269 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301270 qdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001271 (uint8_t *) pScanReq->ssId[i].ssId,
1272 pScanOffloadReq->ssId[i].length);
1273 }
1274
1275 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301276 qdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001277 pScanOffloadReq->bssType = pScanReq->bssType;
1278 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1279 pScanOffloadReq->scanType = pScanReq->scanType;
1280 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1281 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1282 pScanOffloadReq->restTime = pScanReq->restTime;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05301283 pScanOffloadReq->min_rest_time = pScanReq->min_rest_time;
1284 pScanOffloadReq->idle_time = pScanReq->idle_time;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301285 pScanOffloadReq->scan_adaptive_dwell_mode =
1286 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001287
Paul Zhangd2315472017-02-22 10:02:50 +08001288 for (i = 0; i < pMac->lim.maxBssId; i++) {
1289 tpPESession session_entry =
1290 pe_find_session_by_sme_session_id(pMac, i);
1291 if (session_entry &&
1292 (eLIM_MLM_LINK_ESTABLISHED_STATE ==
1293 session_entry->limMlmState) &&
1294 (session_entry->beaconParams.beaconInterval
1295 < BEACON_INTERVAL_THRESHOLD)) {
1296 pScanOffloadReq->burst_scan_duration =
1297 STA_BURST_SCAN_DURATION;
1298 break;
1299 }
1300 }
1301
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001302 /* for normal scan, the value for p2pScanType should be 0
1303 always */
1304 if (pScanReq->p2pSearch)
1305 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1306
1307 pScanOffloadReq->sessionId = pScanReq->sessionId;
1308 pScanOffloadReq->scan_id = pScanReq->scan_id;
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07001309 pScanOffloadReq->scan_requestor_id = USER_SCAN_REQUESTOR_ID;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301310 pScanOffloadReq->scan_adaptive_dwell_mode =
1311 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312
1313 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001314 pe_err("Invalid pe sessionID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001315 pScanOffloadReq->sessionId);
1316
1317 pScanOffloadReq->channelList.numChannels =
1318 pScanReq->channelList.numChannels;
1319 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1320 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1321 p[i] = pScanReq->channelList.channelNumber[i];
1322
1323 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1324 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1325 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301326 qdf_mem_copy((uint8_t *) pScanOffloadReq +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001327 pScanOffloadReq->uIEFieldOffset,
1328 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1329 pScanReq->uIEFieldLen);
Naveen Rawat02e12662016-08-31 16:49:27 -07001330
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001331 rc = wma_post_ctrl_msg(pMac, &msg);
1332 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001333 pe_err("wma_post_ctrl_msg() return failure");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301334 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301335 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001336 }
1337
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001338 pe_debug("Processed Offload Scan Request Successfully");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301340 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341}
1342
1343/**
1344 * __lim_process_sme_scan_req() - Process the SME Scan Request
1345 * @mac_ctx: Global MAC Context
1346 * @msg_buf: Buffer which contains the request and pertinent parameters
1347 *
1348 * This function is called to process SME_SCAN_REQ message
1349 * from HDD or upper layer application.
1350 *
1351 * Return: None
1352 */
1353
1354static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1355 uint32_t *msg_buf)
1356{
1357 tpSirSmeScanReq scan_req;
1358 uint8_t valid_req = 0;
1359
1360#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1361 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1362 eSIR_SUCCESS, eSIR_SUCCESS);
1363#endif
Sreelakshmi Konamki1bb6f312016-12-08 12:32:01 +05301364 mac_ctx->lim.beacon_probe_rsp_cnt_per_scan = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001365
1366 scan_req = (tpSirSmeScanReq) msg_buf;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001367 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 -08001368 scan_req->scan_id, scan_req->channelList.numChannels,
1369 scan_req->minChannelTime, scan_req->maxChannelTime,
1370 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1371 scan_req->returnFreshResults, scan_req->returnUniqueResults,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301372 lim_scan_type_to_string(scan_req->scanType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001373 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1374 /*
1375 * Since scan req always requires a response, we will overwrite response
1376 * required here. This is added esp to take care of the condition where
1377 * in p2p go case, we hold the scan req and insert single NOA. We send
1378 * the held scan request to FW later on getting start NOA ind from FW so
1379 * we lose state of the gLimRspReqd flag for the scan req if any other
1380 * request comes by then. e.g. While unit testing, we found when insert
1381 * single NOA is done, we see a get stats request which turns the flag
1382 * gLimRspReqd to false; now when we actually start the saved scan req
1383 * for init scan after getting NOA started, the gLimRspReqd being a
1384 * global flag is showing false instead of true value for this saved
1385 * scan req. Since all scan reqs coming to lim require a response,
1386 * there is no harm in setting the global flag gLimRspReqd to true here.
1387 */
1388 mac_ctx->lim.gLimRspReqd = true;
1389
1390 /*
1391 * copy the Self MAC address from SmeReq to the globalplace,
1392 * used for sending probe req
1393 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001394 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1395 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001396 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1397
1398 if (!valid_req || mac_ctx->lim.scan_disabled) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001399 pe_err("Scan disabled %d, Valid Scan Req %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001400 mac_ctx->lim.scan_disabled, valid_req);
1401
1402 if (mac_ctx->lim.gLimRspReqd) {
1403 mac_ctx->lim.gLimRspReqd = false;
1404
1405 lim_send_sme_scan_rsp(mac_ctx,
1406 eSIR_SME_INVALID_PARAMETERS,
1407 scan_req->sessionId,
1408 scan_req->transactionId,
1409 scan_req->scan_id);
1410 }
1411 return;
1412 }
1413
1414 /*
1415 * If scan request is received in idle, joinFailed
1416 * states or in link established state (in STA role)
1417 * or in normal state (in STA-in-IBSS/AP role) with
1418 * 'return fresh scan results' request from HDD or
1419 * it is periodic background scanning request,
1420 * trigger fresh scan request to MLM
1421 */
1422 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1423
1424 mac_ctx->lim.gLim24Band11dScanDone = 0;
1425 mac_ctx->lim.gLim50Band11dScanDone = 0;
1426 mac_ctx->lim.gLimReturnAfterFirstMatch =
1427 scan_req->returnAfterFirstMatch;
1428 mac_ctx->lim.gLimReturnUniqueResults =
1429 ((scan_req->returnUniqueResults) > 0 ? true : false);
1430
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301431 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001432 lim_send_hal_start_scan_offload_req(mac_ctx,
1433 scan_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001434 pe_err("Couldn't send Offload scan request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001435 lim_send_sme_scan_rsp(mac_ctx,
1436 eSIR_SME_INVALID_PARAMETERS,
1437 scan_req->sessionId,
1438 scan_req->transactionId,
1439 scan_req->scan_id);
1440 return;
1441 }
Anurag Chouhanffb21542016-02-17 14:33:03 +05301442 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001443 /* In all other cases return 'cached' scan results */
1444 if (mac_ctx->lim.gLimRspReqd) {
1445 mac_ctx->lim.gLimRspReqd = false;
1446 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1447 scan_req->sessionId,
1448 scan_req->transactionId, scan_req->scan_id);
1449 }
1450 }
1451}
1452
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001453/**
1454 * __lim_process_clear_dfs_channel_list()
1455 *
1456 ***FUNCTION:
1457 ***Clear DFS channel list when country is changed/aquired.
1458 .*This message is sent from SME.
1459 *
1460 ***LOGIC:
1461 *
1462 ***ASSUMPTIONS:
1463 *
1464 ***NOTE:
1465 *
1466 * @param pMac Pointer to Global MAC structure
1467 * @param *pMsgBuf A pointer to the SME message buffer
1468 * @return None
1469 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001470static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1471 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001472{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301473 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001474}
1475
1476/**
1477 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1478 * @mac_ctx: Pointer to Global MAC structure
1479 * @msg_buf: A pointer to the SME message buffer
1480 *
1481 * This function is called to process SME_JOIN_REQ message
1482 * from HDD or upper layer application.
1483 *
1484 * Return: None
1485 */
1486static void
1487__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1488{
1489 tpSirSmeJoinReq sme_join_req = NULL;
1490 tLimMlmJoinReq *mlm_join_req;
1491 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1492 uint32_t val = 0;
1493 uint16_t n_size;
1494 uint8_t session_id;
1495 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301496 uint8_t sme_session_id = 0;
1497 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001498 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001499 uint16_t ie_len;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001500 const uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001501 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001502 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001503
Arif Hussain995fcaf2016-07-18 11:28:22 -07001504 if (!mac_ctx || !msg_buf) {
1505 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1506 FL("JOIN REQ with invalid data"));
1507 return;
1508 }
1509
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001510/* FEATURE_WLAN_DIAG_SUPPORT */
1511#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1512 /*
1513 * Not sending any session, since it is not created yet.
1514 * The response whould have correct state.
1515 */
1516 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1517#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1518
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001519 /*
1520 * Expect Join request in idle state.
1521 * Reassociate request is expected in link established state.
1522 */
1523
1524 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1525 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1526 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1527 msg_buf);
1528
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301529 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001530 if (NULL == sme_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001531 pe_err("AllocateMemory failed for sme_join_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001532 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301533 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001534 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301535 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001536 n_size);
1537
1538 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1539 /* Received invalid eWNI_SME_JOIN_REQ */
1540 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001541 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001542 sme_join_req->sessionId);
1543 ret_code = eSIR_SME_INVALID_PARAMETERS;
1544 goto end;
1545 }
1546
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001547 /*
1548 * Update the capability here itself as this is used in
1549 * lim_extract_ap_capability() below. If not updated issues
1550 * like not honoring power constraint on 1st association after
1551 * driver loading might occur.
1552 */
1553 lim_update_rrm_capability(mac_ctx, sme_join_req);
1554
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001555 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001556 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001557 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001558 &session_id);
1559
1560 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001561 pe_err("Session(%d) Already exists for BSSID: "
1562 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001563 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001564 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001565 session->limSmeState);
1566
1567 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1568 session->smeSessionId == sme_join_req->sessionId) {
1569 /*
1570 * Received eWNI_SME_JOIN_REQ for same
1571 * BSS as currently associated.
1572 * Log the event and send success
1573 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001574 pe_warn("SessionId: %d", session_id);
1575 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001576 /* Send Join success response to host */
1577 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1578 session = NULL;
1579 goto end;
1580 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001581 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582 ret_code = eSIR_SME_REFUSED;
1583 session = NULL;
1584 goto end;
1585 }
1586 } else {
1587 /*
1588 * Session Entry does not exist for given BSSId
1589 * Try to Create a new session
1590 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001591 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001592 &session_id, mac_ctx->lim.maxStation,
1593 eSIR_INFRASTRUCTURE_MODE);
1594 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001595 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001596 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1597 goto end;
1598 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001599 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001600 session_id);
1601 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001602 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001603
1604 /*
1605 * Store Session related parameters
1606 * Store PE session Id in session Table
1607 */
1608 session->peSessionId = session_id;
1609
1610 /* store the smejoin req handle in session table */
1611 session->pLimJoinReq = sme_join_req;
1612
1613 /* Store SME session Id in sessionTable */
1614 session->smeSessionId = sme_join_req->sessionId;
1615
1616 /* Store SME transaction Id in session Table */
1617 session->transactionId = sme_join_req->transactionId;
1618
1619 /* Store beaconInterval */
1620 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001621 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001622
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301623 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001624 sizeof(session->htConfig));
1625
Sandeep Puligilla98917432016-06-10 13:50:28 -07001626 qdf_mem_copy(&(session->vht_config),
1627 &(sme_join_req->vht_config),
1628 sizeof(session->vht_config));
1629
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001630 /* Copying of bssId is already done, while creating session */
1631 sir_copy_mac_addr(session->selfMacAddr,
1632 sme_join_req->selfMacAddr);
1633 session->bssType = sme_join_req->bsstype;
1634
1635 session->statypeForBss = STA_ENTRY_PEER;
1636 session->limWmeEnabled = sme_join_req->isWMEenabled;
1637 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301638 session->wps_registration = sme_join_req->wps_registration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001639
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301640 session->enable_bcast_probe_rsp =
1641 sme_join_req->enable_bcast_probe_rsp;
1642
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001643 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001644 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001645 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1646
Naveen Rawat08db88f2017-09-08 15:07:48 -07001647 vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001648 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001649 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001650
1651 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001652 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001653 session->isCiscoVendorAP = true;
1654 } else {
1655 session->isCiscoVendorAP = false;
1656 }
1657
1658 /* Copy the dot 11 mode in to the session table */
1659
1660 session->dot11mode = sme_join_req->dot11mode;
1661#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1662 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1663#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001664 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001665 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1666 session->enableHtSmps = sme_join_req->enableHtSmps;
1667 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001668 session->send_smps_action =
1669 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001670 /*
1671 * By default supported NSS 1x1 is set to true
1672 * and later on updated while determining session
1673 * supported rates which is the intersection of
1674 * self and peer rates
1675 */
1676 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301677 /*Store Persona */
1678 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001679 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 -08001680 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001681 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001682 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301683 session->supported_nss_1x1,
1684 session->pePersona,
1685 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001686
1687 /*Store Persona */
1688 session->pePersona = sme_join_req->staPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +05301689 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301690 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d force_24ghz_in_ht20 %d"),
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001691 session->pePersona, sme_join_req->cbMode,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301692 session->nwType, session->dot11mode,
1693 sme_join_req->force_24ghz_in_ht20);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001694
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001695 /* Copy The channel Id to the session Table */
1696 session->currentOperChannel = bss_desc->channelId;
1697 if (IS_5G_CH(session->currentOperChannel))
1698 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001699 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001700 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1701 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1702 session->vdev_nss = vdev_type_nss->p2p_cli;
1703 else
1704 session->vdev_nss = vdev_type_nss->sta;
1705 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001706 session->vhtCapability =
1707 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001708 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301709 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001710 session->vht_config.su_beam_formee =
1711 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001712 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001713 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001714 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001715 session->enableVhtpAid =
1716 sme_join_req->enableVhtpAid;
1717 session->enableVhtGid =
1718 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001719 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001720 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001721 }
Krunal Soni53993f72016-07-08 18:20:03 -07001722
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001723 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1724 lim_update_session_he_capable(mac_ctx, session);
1725 lim_copy_join_req_he_cap(session, sme_join_req);
1726 }
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001727
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001728 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301729 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001730 session->vht_config.su_beam_formee,
1731 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001732 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001733 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001734 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001735 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301736 session->force_24ghz_in_ht20 =
1737 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001738 /* cbMode is already merged value of peer and self -
1739 * done by csr in csr_get_cb_mode_from_ies */
1740 session->htSupportedChannelWidthSet =
1741 (sme_join_req->cbMode) ? 1 : 0;
1742 session->htRecommendedTxWidthSet =
1743 session->htSupportedChannelWidthSet;
1744 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1745
1746 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1747 session->ch_center_freq_seg0 =
1748 session->currentOperChannel - 2;
1749 session->ch_width = CH_WIDTH_40MHZ;
1750 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1751 sme_join_req->cbMode) {
1752 session->ch_center_freq_seg0 =
1753 session->currentOperChannel + 2;
1754 session->ch_width = CH_WIDTH_40MHZ;
1755 } else {
1756 session->ch_center_freq_seg0 = 0;
1757 session->ch_width = CH_WIDTH_20MHZ;
1758 }
1759
1760 /* Record if management frames need to be protected */
1761#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001762 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001763 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001764 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001765 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001766#endif
1767
1768#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001769 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001770#endif
1771
1772 /* Copy the SSID from smejoinreq to session entry */
1773 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301774 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001775 session->ssId.length);
1776
1777 /*
1778 * Determin 11r or ESE connection based on input from SME
1779 * which inturn is dependent on the profile the user wants
1780 * to connect to, So input is coming from supplicant
1781 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001782 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001783#ifdef FEATURE_WLAN_ESE
1784 session->isESEconnection = sme_join_req->isESEconnection;
1785#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001786 session->isFastTransitionEnabled =
1787 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001788
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001789 session->isFastRoamIniFeatureEnabled =
1790 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001791 session->txLdpcIniFeatureEnabled =
1792 sme_join_req->txLdpcIniFeatureEnabled;
1793
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301794 lim_update_fils_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001795 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1796 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001797 } else {
1798 /*
1799 * Throw an error and return and make
1800 * sure to delete the session.
1801 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001802 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001803 session->bssType);
1804 ret_code = eSIR_SME_INVALID_PARAMETERS;
1805 goto end;
1806 }
1807
1808 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301809 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001810 &sme_join_req->addIEScan, sizeof(tSirAddie));
1811
1812 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301813 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001814 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1815
1816 val = sizeof(tLimMlmJoinReq) +
1817 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301818 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001819 if (NULL == mlm_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001820 pe_err("AllocateMemory failed for mlmJoinReq");
Nitesh Shah0102cac2016-07-13 14:38:30 +05301821 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1822 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001823 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001824
1825 /* PE SessionId is stored as a part of JoinReq */
1826 mlm_join_req->sessionId = session->peSessionId;
1827
1828 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1829 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1830 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001831 pe_err("couldn't retrieve JoinFailureTimer value"
1832 " setting to default value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833 mlm_join_req->joinFailureTimeout =
1834 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1835 }
1836
1837 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301838 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001839 (void *)&sme_join_req->operationalRateSet,
1840 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301841 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001842 (void *)&sme_join_req->extendedRateSet,
1843 sizeof(tSirMacRateSet));
1844 /*
1845 * this may not be needed anymore now, as rateSet is now
1846 * included in the session entry and MLM has session context.
1847 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301848 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001849 (void *)&session->rateSet,
1850 sizeof(tSirMacRateSet));
1851
1852 session->encryptType = sme_join_req->UCEncryptionType;
1853
1854 mlm_join_req->bssDescription.length =
1855 session->pLimJoinReq->bssDescription.length;
1856
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301857 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001858 (uint8_t *)
1859 &session->pLimJoinReq->bssDescription.bssId,
1860 session->pLimJoinReq->bssDescription.length + 2);
1861
1862 session->limCurrentBssCaps =
1863 session->pLimJoinReq->bssDescription.capabilityInfo;
1864
1865 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1866 session->currentOperChannel);
1867 local_power_constraint = reg_max;
1868
1869 lim_extract_ap_capability(mac_ctx,
1870 (uint8_t *)
1871 session->pLimJoinReq->bssDescription.ieFields,
1872 lim_get_ielen_from_bss_description(
1873 &session->pLimJoinReq->bssDescription),
1874 &session->limCurrentBssQosCaps,
1875 &session->limCurrentBssPropCap,
1876 &session->gLimCurrentBssUapsd,
1877 &local_power_constraint, session);
1878
Krunal Soni53993f72016-07-08 18:20:03 -07001879 /*
1880 * Once the AP capabilities are available then set the
1881 * beam forming capabilities accordingly.
1882 */
1883 if (session->nss == 1) {
1884 session->vht_config.su_beam_former = 0;
1885 session->vht_config.tx_stbc = 0;
1886 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301887 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001888 }
1889
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890 session->maxTxPower = lim_get_max_tx_power(reg_max,
1891 local_power_constraint,
1892 mac_ctx->roam.configParam.nTxPowerCap);
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301893
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001894 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301895 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001896
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301897 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1898 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1899 pe_debug("Update MaxTxPower in join Req to %d",
1900 sme_join_req->powerCap.maxTxPower);
1901 }
1902
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001903 if (session->gLimCurrentBssUapsd) {
1904 session->gUapsdPerAcBitmask =
1905 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001906 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001907 session->gUapsdPerAcBitmask);
1908
1909 /* resetting the dynamic uapsd mask */
1910 session->gUapsdPerAcDeliveryEnableMask = 0;
1911 session->gUapsdPerAcTriggerEnableMask = 0;
1912 }
1913
1914 session->limRFBand =
1915 lim_get_rf_band(session->currentOperChannel);
1916
1917 /* Initialize 11h Enable Flag */
1918 if (SIR_BAND_5_GHZ == session->limRFBand) {
1919 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1920 &val) != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001921 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001922 session->lim11hEnable =
1923 WNI_CFG_11H_ENABLED_STADEF;
1924 } else {
1925 session->lim11hEnable = val;
1926 }
1927 } else {
1928 session->lim11hEnable = 0;
1929 }
1930
1931 /*
1932 * To care of the scenario when STA transitions from
1933 * IBSS to Infrastructure mode.
1934 */
1935 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1936
1937 session->limPrevSmeState = session->limSmeState;
1938 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1939 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1940 session->peSessionId,
1941 session->limSmeState));
1942
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001943 /* Indicate whether spectrum management is enabled */
1944 session->spectrumMgtEnabled =
1945 sme_join_req->spectrumMgtIndicator;
1946
1947 /* Enable the spectrum management if this is a DFS channel */
1948 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001949 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001950 session->currentOperChannel))
1951 session->spectrumMgtEnabled = true;
1952
1953 session->isOSENConnection = sme_join_req->isOSENConnection;
1954
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001955 /* Issue LIM_MLM_JOIN_REQ to MLM */
1956 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1957 (uint32_t *) mlm_join_req);
1958 return;
1959
1960 } else {
1961 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001962 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001963 mac_ctx->lim.gLimSmeState);
1964 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1965 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1966 session = NULL;
1967 goto end;
1968 }
1969
1970end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301971 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1972 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001973
1974 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301975 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001976 sme_join_req = NULL;
1977 if (NULL != session)
1978 session->pLimJoinReq = NULL;
1979 }
1980 if (ret_code != eSIR_SME_SUCCESS) {
1981 if (NULL != session) {
1982 pe_delete_session(mac_ctx, session);
1983 session = NULL;
1984 }
1985 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001986 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987 sme_session_id, ret_code);
1988 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1989 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1990 sme_transaction_id);
1991}
1992
Amar Singhala297bfa2015-10-15 15:07:29 -07001993uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001994 uint8_t iniTxPower)
1995{
1996 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301997 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
1998 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001999 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2000 maxTxPower = txPower;
2001 else if (txPower < MIN_TX_PWR_CAP)
2002 maxTxPower = MIN_TX_PWR_CAP;
2003 else
2004 maxTxPower = MAX_TX_PWR_CAP;
2005
2006 return maxTxPower;
2007}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002008
2009/**
2010 * __lim_process_sme_reassoc_req() - process reassoc req
2011 *
2012 * @mac_ctx: Pointer to Global MAC structure
2013 * @msg_buf: pointer to the SME message buffer
2014 *
2015 * This function is called to process SME_REASSOC_REQ message
2016 * from HDD or upper layer application.
2017 *
2018 * Return: None
2019 */
2020
2021static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2022 uint32_t *msg_buf)
2023{
2024 uint16_t caps;
2025 uint32_t val;
2026 tpSirSmeJoinReq reassoc_req = NULL;
2027 tLimMlmReassocReq *mlm_reassoc_req;
2028 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2029 tpPESession session_entry = NULL;
2030 uint8_t session_id;
2031 uint8_t sme_session_id;
2032 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002033 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002034 uint32_t tele_bcn_en = 0;
2035 uint16_t size;
2036
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002037 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302038 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002039 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002040 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002041
2042 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2043 goto end;
2044 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302045 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002046
2047 if (!lim_is_sme_join_req_valid(mac_ctx,
2048 (tpSirSmeJoinReq)reassoc_req)) {
2049 /*
2050 * Received invalid eWNI_SME_REASSOC_REQ
2051 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002052 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002053
2054 ret_code = eSIR_SME_INVALID_PARAMETERS;
2055 goto end;
2056 }
2057
2058 session_entry = pe_find_session_by_bssid(mac_ctx,
2059 reassoc_req->bssDescription.bssId,
2060 &session_id);
2061 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002062 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002063 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2064 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002065 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002066 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
2067 &sme_session_id, &transaction_id);
2068 session_entry =
2069 pe_find_session_by_sme_session_id(mac_ctx,
2070 sme_session_id);
2071 if (session_entry != NULL)
2072 lim_handle_sme_join_result(mac_ctx,
2073 eSIR_SME_INVALID_PARAMETERS,
2074 eSIR_MAC_UNSPEC_FAILURE_STATUS,
2075 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002076 goto end;
2077 }
2078#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2079 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2080 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2081#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2082 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2083
2084 /* Store the reassoc handle in the session Table */
2085 session_entry->pLimReAssocReq = reassoc_req;
2086
2087 session_entry->dot11mode = reassoc_req->dot11mode;
2088 session_entry->vhtCapability =
2089 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002090
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302091 if (session_entry->vhtCapability) {
2092 if (session_entry->pePersona == QDF_STA_MODE) {
2093 session_entry->vht_config.su_beam_formee =
2094 reassoc_req->vht_config.su_beam_formee;
2095 } else {
2096 reassoc_req->vht_config.su_beam_formee = 0;
2097 }
2098 session_entry->enableVhtpAid =
2099 reassoc_req->enableVhtpAid;
2100 session_entry->enableVhtGid =
2101 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002102 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302103 }
2104
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002105 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302106 session_entry->vhtCapability,
2107 session_entry->vht_config.su_beam_formee,
2108 session_entry->vht_config.su_beam_former);
2109
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002110 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2111 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002112 session_entry->send_smps_action =
2113 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002114 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002115 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002116 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002117 session_entry->send_smps_action,
2118 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002119 /*
2120 * Reassociate request is expected
2121 * in link established state only.
2122 */
2123
2124 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002125 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2126 /*
2127 * May be from 11r FT pre-auth. So lets check it
2128 * before we bail out
2129 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002130 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002131 session_entry->peSessionId);
2132
2133 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302134 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002135 session_entry->limReAssocbssId,
2136 6)) {
2137 lim_print_mac_addr(mac_ctx,
2138 reassoc_req->bssDescription.
2139 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002140 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002141 ret_code = eSIR_SME_INVALID_PARAMETERS;
2142 goto end;
2143 }
2144
2145 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2146 session_entry);
2147 return;
2148 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149 /*
2150 * Should not have received eWNI_SME_REASSOC_REQ
2151 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002152 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002153 session_entry->limSmeState);
2154 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2155
2156 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2157 goto end;
2158 }
2159
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302160 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002161 session_entry->pLimReAssocReq->bssDescription.bssId,
2162 sizeof(tSirMacAddr));
2163
2164 session_entry->limReassocChannelId =
2165 session_entry->pLimReAssocReq->bssDescription.channelId;
2166
2167 session_entry->reAssocHtSupportedChannelWidthSet =
2168 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2169 session_entry->reAssocHtRecommendedTxWidthSet =
2170 session_entry->reAssocHtSupportedChannelWidthSet;
2171 session_entry->reAssocHtSecondaryChannelOffset =
2172 session_entry->pLimReAssocReq->cbMode;
2173
2174 session_entry->limReassocBssCaps =
2175 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2176 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2177 session_entry->currentOperChannel);
2178 local_pwr_constraint = reg_max;
2179
2180 lim_extract_ap_capability(mac_ctx,
2181 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2182 lim_get_ielen_from_bss_description(
2183 &session_entry->pLimReAssocReq->bssDescription),
2184 &session_entry->limReassocBssQosCaps,
2185 &session_entry->limReassocBssPropCap,
2186 &session_entry->gLimCurrentBssUapsd,
2187 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302188 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002189 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302190 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002191 /* Copy the SSID from session entry to local variable */
2192 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302193 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002194 reassoc_req->ssId.ssId,
2195 session_entry->limReassocSSID.length);
2196 if (session_entry->gLimCurrentBssUapsd) {
2197 session_entry->gUapsdPerAcBitmask =
2198 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002199 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002200 session_entry->gUapsdPerAcBitmask);
2201 }
2202
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302203 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002204 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002205 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002206
2207 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2208 goto end;
2209 }
2210
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302211 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002212 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2213
2214 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2215 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002216 eSIR_SUCCESS)
2217 pe_err("could not retrieve ReassocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002218
2219 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002220 eSIR_SUCCESS)
2221 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302222
2223 lim_update_caps_info_for_bss(mac_ctx, &caps,
2224 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002225 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302226
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002227 mlm_reassoc_req->capabilityInfo = caps;
2228
2229 /* Update PE session_id */
2230 mlm_reassoc_req->sessionId = session_id;
2231
2232 /*
2233 * If telescopic beaconing is enabled, set listen interval to
2234 * WNI_CFG_TELE_BCN_MAX_LI
2235 */
2236 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2237 &tele_bcn_en) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002238 pe_err("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002239
2240 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2241
2242 if (tele_bcn_en) {
2243 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2244 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002245 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002246 } else {
2247 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &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 }
2251
2252 mlm_reassoc_req->listenInterval = (uint16_t) val;
2253
2254 /* Indicate whether spectrum management is enabled */
2255 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2256
2257 /* Enable the spectrum management if this is a DFS channel */
2258 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002259 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002260 session_entry->currentOperChannel))
2261 session_entry->spectrumMgtEnabled = true;
2262
2263 session_entry->limPrevSmeState = session_entry->limSmeState;
2264 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2265
2266 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2267 session_entry->peSessionId,
2268 session_entry->limSmeState));
2269
2270 lim_post_mlm_message(mac_ctx,
2271 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2272 return;
2273end:
2274 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302275 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002276 if (session_entry)
2277 session_entry->pLimReAssocReq = NULL;
2278 }
2279
2280 if (session_entry) {
2281 /*
2282 * error occurred after we determined the session so extract
2283 * session and transaction info from there
2284 */
2285 sme_session_id = session_entry->smeSessionId;
2286 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002287 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002288 /*
2289 * error occurred before or during the time we determined
2290 * the session so extract the session and transaction info
2291 * from the message
2292 */
2293 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2294 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002295 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002296 /*
2297 * Send Reassoc failure response to host
2298 * (note session_entry may be NULL, but that's OK)
2299 */
2300 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2301 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2302 session_entry, sme_session_id,
2303 transaction_id);
2304}
2305
2306bool send_disassoc_frame = 1;
2307/**
2308 * __lim_process_sme_disassoc_req()
2309 *
2310 ***FUNCTION:
2311 * This function is called to process SME_DISASSOC_REQ message
2312 * from HDD or upper layer application.
2313 *
2314 ***LOGIC:
2315 *
2316 ***ASSUMPTIONS:
2317 *
2318 ***NOTE:
2319 *
2320 * @param pMac Pointer to Global MAC structure
2321 * @param *pMsgBuf A pointer to the SME message buffer
2322 * @return None
2323 */
2324
2325static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2326{
2327 uint16_t disassocTrigger, reasonCode;
2328 tLimMlmDisassocReq *pMlmDisassocReq;
2329 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2330 tSirSmeDisassocReq smeDisassocReq;
2331 tpPESession psessionEntry = NULL;
2332 uint8_t sessionId;
2333 uint8_t smesessionId;
2334 uint16_t smetransactionId;
2335
2336 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002337 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002338 return;
2339 }
2340
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302341 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002342 smesessionId = smeDisassocReq.sessionId;
2343 smetransactionId = smeDisassocReq.transactionId;
2344 if (!lim_is_sme_disassoc_req_valid(pMac,
2345 &smeDisassocReq,
2346 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002347 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002348 if (pMac->lim.gLimRspReqd) {
2349 pMac->lim.gLimRspReqd = false;
2350
2351 retCode = eSIR_SME_INVALID_PARAMETERS;
2352 disassocTrigger = eLIM_HOST_DISASSOC;
2353 goto sendDisassoc;
2354 }
2355
2356 return;
2357 }
2358
2359 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002360 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002361 &sessionId);
2362 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002363 pe_err("session does not exist for given bssId "
2364 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002365 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002366 retCode = eSIR_SME_INVALID_PARAMETERS;
2367 disassocTrigger = eLIM_HOST_DISASSOC;
2368 goto sendDisassoc;
2369 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002370 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2371 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002372 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2373 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002374 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002375
2376#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2377 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2378 0, smeDisassocReq.reasonCode);
2379#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2380
2381 /* Update SME session Id and SME transaction ID */
2382
2383 psessionEntry->smeSessionId = smesessionId;
2384 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002385 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002386 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002387
2388 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2389 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002390 switch (psessionEntry->limSmeState) {
2391 case eLIM_SME_ASSOCIATED_STATE:
2392 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002393 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002394 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002395 psessionEntry->limPrevSmeState =
2396 psessionEntry->limSmeState;
2397 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002398 /* Delete all TDLS peers connected before leaving BSS */
2399 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002400 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2401 psessionEntry->peSessionId,
2402 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002403 break;
2404
2405 case eLIM_SME_WT_DEAUTH_STATE:
2406 /* PE shall still process the DISASSOC_REQ and proceed with
2407 * link tear down even if it had already sent a DEAUTH_IND to
2408 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2409 * its been set when PE entered WT_DEAUTH_STATE.
2410 */
2411 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2412 MTRACE(mac_trace
2413 (pMac, TRACE_CODE_SME_STATE,
2414 psessionEntry->peSessionId,
2415 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002416 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002417 break;
2418
2419 case eLIM_SME_WT_DISASSOC_STATE:
2420 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2421 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2422 * PE can continue processing DISASSOC_REQ and send the response instead
2423 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2424 * for disassoc frame.
2425 *
2426 * It will send a disassoc, which is ok. However, we can use the global flag
2427 * sendDisassoc to not send disassoc frame.
2428 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002429 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002430 break;
2431
2432 case eLIM_SME_JOIN_FAILURE_STATE: {
2433 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002434 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002435 if (pMac->lim.gLimRspReqd) {
2436 retCode = eSIR_SME_SUCCESS;
2437 disassocTrigger = eLIM_HOST_DISASSOC;
2438 goto sendDisassoc;
2439 }
2440 }
2441 break;
2442 default:
2443 /**
2444 * STA is not currently associated.
2445 * Log error and send response to host
2446 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002447 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002448 psessionEntry->limSmeState);
2449 lim_print_sme_state(pMac, LOGE,
2450 psessionEntry->limSmeState);
2451
2452 if (pMac->lim.gLimRspReqd) {
2453 if (psessionEntry->limSmeState !=
2454 eLIM_SME_WT_ASSOC_STATE)
2455 pMac->lim.gLimRspReqd = false;
2456
2457 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2458 disassocTrigger = eLIM_HOST_DISASSOC;
2459 goto sendDisassoc;
2460 }
2461
2462 return;
2463 }
2464
2465 break;
2466
2467 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002468 /* Fall through */
2469 break;
2470
2471 case eLIM_STA_IN_IBSS_ROLE:
2472 default:
2473 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002474 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002475 GET_LIM_SYSTEM_ROLE(psessionEntry));
2476
2477 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2478 disassocTrigger = eLIM_HOST_DISASSOC;
2479 goto sendDisassoc;
2480 } /* end switch (pMac->lim.gLimSystemRole) */
2481
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302482 disassocTrigger = eLIM_HOST_DISASSOC;
2483 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002484
2485 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002486 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002487 send_disassoc_frame = 0;
2488 }
2489 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002490 pe_debug("Sending Disasscoc with disassoc Trigger"
2491 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002492 disassocTrigger, reasonCode);
2493
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302494 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002495 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002496 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002497 return;
2498 }
2499
Anurag Chouhanc5548422016-02-24 18:33:27 +05302500 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002501 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002502
2503 pMlmDisassocReq->reasonCode = reasonCode;
2504 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2505
2506 /* Update PE session ID */
2507 pMlmDisassocReq->sessionId = sessionId;
2508
2509 lim_post_mlm_message(pMac,
2510 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2511 return;
2512
2513sendDisassoc:
2514 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002515 lim_send_sme_disassoc_ntf(pMac,
2516 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002517 retCode,
2518 disassocTrigger,
2519 1, smesessionId, smetransactionId,
2520 psessionEntry);
2521 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002522 lim_send_sme_disassoc_ntf(pMac,
2523 smeDisassocReq.peer_macaddr.bytes,
2524 retCode, disassocTrigger, 1,
2525 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002526
2527} /*** end __lim_process_sme_disassoc_req() ***/
2528
2529/** -----------------------------------------------------------------
2530 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2531
2532 This function is called to process SME_DISASSOC_CNF message
2533 from HDD or upper layer application.
2534
2535 \param pMac - global mac structure
2536 \param pStaDs - station dph hash node
2537 \return none
2538 \sa
2539 ----------------------------------------------------------------- */
2540static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2541{
2542 tSirSmeDisassocCnf smeDisassocCnf;
2543 uint16_t aid;
2544 tpDphHashNode pStaDs;
2545 tpPESession psessionEntry;
2546 uint8_t sessionId;
2547
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302548 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002549 sizeof(struct sSirSmeDisassocCnf));
2550
2551 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002552 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002553 &sessionId);
2554 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002555 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002556 return;
2557 }
2558
2559 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002560 pe_err("received invalid SME_DISASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002561 return;
2562 }
2563#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2564 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2565 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2566 psessionEntry,
2567 (uint16_t) smeDisassocCnf.statusCode, 0);
2568 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2569 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2570 psessionEntry,
2571 (uint16_t) smeDisassocCnf.statusCode, 0);
2572#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2573
2574 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2575 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002576 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2577 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2578 && (psessionEntry->limSmeState !=
2579 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002580 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002581 psessionEntry->limSmeState);
2582 lim_print_sme_state(pMac, LOGE,
2583 psessionEntry->limSmeState);
2584 return;
2585 }
2586 break;
2587
2588 case eLIM_AP_ROLE:
2589 /* Fall through */
2590 break;
2591
2592 case eLIM_STA_IN_IBSS_ROLE:
2593 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002594 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002595 GET_LIM_SYSTEM_ROLE(psessionEntry));
2596
2597 return;
2598 }
2599
2600 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2601 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2602 LIM_IS_AP_ROLE(psessionEntry)) {
2603 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002604 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002605 &psessionEntry->dph.dphHashTable);
2606 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002607 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2608 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002609 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002610 return;
2611 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302612
2613 if ((pStaDs->mlmStaContext.mlmState ==
2614 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2615 (pStaDs->mlmStaContext.mlmState ==
2616 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002617 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002618 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302619 pStaDs->mlmStaContext.mlmState);
2620 return;
2621 }
2622
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002623 /* Delete FT session if there exists one */
2624 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002625 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2626
2627 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002628 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002629 }
2630
2631 return;
2632}
2633
2634/**
2635 * __lim_process_sme_deauth_req() - process sme deauth req
2636 * @mac_ctx: Pointer to Global MAC structure
2637 * @msg_buf: pointer to the SME message buffer
2638 *
2639 * This function is called to process SME_DEAUTH_REQ message
2640 * from HDD or upper layer application.
2641 *
2642 * Return: None
2643 */
2644
2645static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2646 uint32_t *msg_buf)
2647{
2648 uint16_t deauth_trigger, reason_code;
2649 tLimMlmDeauthReq *mlm_deauth_req;
2650 tSirSmeDeauthReq sme_deauth_req;
2651 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2652 tpPESession session_entry;
2653 uint8_t session_id; /* PE sessionId */
2654 uint8_t sme_session_id;
2655 uint16_t sme_transaction_id;
2656
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302657 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002658 sme_session_id = sme_deauth_req.sessionId;
2659 sme_transaction_id = sme_deauth_req.transactionId;
2660
2661 /*
2662 * We need to get a session first but we don't even know
2663 * if the message is correct.
2664 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002665 session_entry = pe_find_session_by_bssid(mac_ctx,
2666 sme_deauth_req.bssid.bytes,
2667 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002668 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002669 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002670 ret_code = eSIR_SME_INVALID_PARAMETERS;
2671 deauth_trigger = eLIM_HOST_DEAUTH;
2672 goto send_deauth;
2673 }
2674
2675 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2676 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002677 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002678 mac_ctx->lim.gLimRspReqd = false;
2679
2680 ret_code = eSIR_SME_INVALID_PARAMETERS;
2681 deauth_trigger = eLIM_HOST_DEAUTH;
2682 goto send_deauth;
2683 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002684 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2685 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002686 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2687 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002688 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002689#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2690 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2691 session_entry, 0, sme_deauth_req.reasonCode);
2692#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2693
2694 /* Update SME session ID and Transaction ID */
2695 session_entry->smeSessionId = sme_session_id;
2696 session_entry->transactionId = sme_transaction_id;
2697
2698 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2699 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002700 switch (session_entry->limSmeState) {
2701 case eLIM_SME_ASSOCIATED_STATE:
2702 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302703 /* Delete all TDLS peers connected before leaving BSS */
2704 lim_delete_tdls_peers(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002705 case eLIM_SME_WT_ASSOC_STATE:
2706 case eLIM_SME_JOIN_FAILURE_STATE:
2707 case eLIM_SME_IDLE_STATE:
2708 session_entry->limPrevSmeState =
2709 session_entry->limSmeState;
2710 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2711 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2712 session_entry->peSessionId,
2713 session_entry->limSmeState));
2714 /* Send Deauthentication request to MLM below */
2715 break;
2716 case eLIM_SME_WT_DEAUTH_STATE:
2717 case eLIM_SME_WT_DISASSOC_STATE:
2718 /*
2719 * PE Recieved a Deauth/Disassoc frame. Normally it get
2720 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2721 * Which means host is also trying to disconnect.
2722 * PE can continue processing DEAUTH_REQ and send
2723 * the response instead of failing the request.
2724 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2725 * was sent for deauth/disassoc frame.
2726 */
2727 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002728 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002729 break;
2730 default:
2731 /*
2732 * STA is not in a state to deauthenticate with
2733 * peer. Log error and send response to host.
2734 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002735 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002736 session_entry->limSmeState);
2737 lim_print_sme_state(mac_ctx, LOGE,
2738 session_entry->limSmeState);
2739
2740 if (mac_ctx->lim.gLimRspReqd) {
2741 mac_ctx->lim.gLimRspReqd = false;
2742
2743 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2744 deauth_trigger = eLIM_HOST_DEAUTH;
2745
wadesong42968e92017-06-08 14:11:21 +08002746 /*
2747 * here we received deauth request from AP so
2748 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2749 * have ISSUED delSta then mlm state should be
2750 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2751 * delBSS rsp then mlm state should be
2752 * eLIM_MLM_IDLE_STATE so the below condition
2753 * captures the state where delSta not done
2754 * and firmware still in connected state.
2755 */
2756 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002757 eLIM_SME_WT_DEAUTH_STATE &&
2758 session_entry->limMlmState !=
2759 eLIM_MLM_IDLE_STATE &&
2760 session_entry->limMlmState !=
2761 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002762 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002763 goto send_deauth;
2764 }
2765 return;
2766 }
2767 break;
2768
2769 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002770 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002771 if (mac_ctx->lim.gLimRspReqd) {
2772 mac_ctx->lim.gLimRspReqd = false;
2773 ret_code = eSIR_SME_INVALID_PARAMETERS;
2774 deauth_trigger = eLIM_HOST_DEAUTH;
2775 goto send_deauth;
2776 }
2777 return;
2778 case eLIM_AP_ROLE:
2779 break;
2780 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002781 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002782 GET_LIM_SYSTEM_ROLE(session_entry));
2783 if (mac_ctx->lim.gLimRspReqd) {
2784 mac_ctx->lim.gLimRspReqd = false;
2785 ret_code = eSIR_SME_INVALID_PARAMETERS;
2786 deauth_trigger = eLIM_HOST_DEAUTH;
2787 goto send_deauth;
2788 }
2789 return;
2790 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2791
2792 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2793 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002794 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002795 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2796 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2797 } else {
2798 deauth_trigger = eLIM_HOST_DEAUTH;
2799 reason_code = sme_deauth_req.reasonCode;
2800 }
2801
2802 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302803 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002804 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002805 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002806 if (mac_ctx->lim.gLimRspReqd) {
2807 mac_ctx->lim.gLimRspReqd = false;
2808 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2809 deauth_trigger = eLIM_HOST_DEAUTH;
2810 goto send_deauth;
2811 }
2812 return;
2813 }
2814
Anurag Chouhanc5548422016-02-24 18:33:27 +05302815 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002816 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002817
2818 mlm_deauth_req->reasonCode = reason_code;
2819 mlm_deauth_req->deauthTrigger = deauth_trigger;
2820
2821 /* Update PE session Id */
2822 mlm_deauth_req->sessionId = session_id;
2823
2824 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2825 (uint32_t *)mlm_deauth_req);
2826 return;
2827
2828send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002829 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2830 ret_code, deauth_trigger, 1,
2831 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002832}
2833
2834/**
2835 * __lim_process_sme_set_context_req()
2836 *
2837 * @mac_ctx: Pointer to Global MAC structure
2838 * @msg_buf: pointer to the SME message buffer
2839 *
2840 * This function is called to process SME_SETCONTEXT_REQ message
2841 * from HDD or upper layer application.
2842 *
2843 * Return: None
2844 */
2845
2846static void
2847__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2848{
2849 tpSirSmeSetContextReq set_context_req;
2850 tLimMlmSetKeysReq *mlm_set_key_req;
2851 tpPESession session_entry;
2852 uint8_t session_id; /* PE sessionID */
2853 uint8_t sme_session_id;
2854 uint16_t sme_transaction_id;
2855
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002856 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002857 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002858 return;
2859 }
2860
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302861 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002862 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002863 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002864 return;
2865 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302866 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002867 sizeof(struct sSirSmeSetContextReq));
2868 sme_session_id = set_context_req->sessionId;
2869 sme_transaction_id = set_context_req->transactionId;
2870
2871 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002872 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002873 goto end;
2874 }
2875
2876 if (set_context_req->keyMaterial.numKeys >
2877 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002878 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002879 set_context_req->keyMaterial.numKeys);
2880 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002881 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002882 eSIR_SME_INVALID_PARAMETERS, NULL,
2883 sme_session_id, sme_transaction_id);
2884 goto end;
2885 }
2886
2887 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002888 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002889 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002890 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002891 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002892 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002893 eSIR_SME_INVALID_PARAMETERS, NULL,
2894 sme_session_id, sme_transaction_id);
2895 goto end;
2896 }
2897#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2898 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2899 session_entry, 0, 0);
2900#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2901
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002902 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002903 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2904 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002905 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002906 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2907 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302908 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002909 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002910 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002911 goto end;
2912 }
2913 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2914 mlm_set_key_req->numKeys =
2915 set_context_req->keyMaterial.numKeys;
2916 if (mlm_set_key_req->numKeys >
2917 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002918 pe_err("no.of keys exceeded max num of default keys limit");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002919 goto end;
2920 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302921 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002922 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002923
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302924 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002925 (uint8_t *) &set_context_req->keyMaterial.key,
2926 sizeof(tSirKeys) *
2927 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2928 numKeys : 1));
2929
2930 mlm_set_key_req->sessionId = session_id;
2931 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002932 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002933 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002934
2935 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2936 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2937 LIM_IS_AP_ROLE(session_entry)) {
2938 if (set_context_req->keyMaterial.key[0].keyLength) {
2939 uint8_t key_id;
2940 key_id =
2941 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302942 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002943 &session_entry->WEPKeyMaterial[key_id],
2944 (uint8_t *) &set_context_req->keyMaterial,
2945 sizeof(tSirKeyMaterial));
2946 } else {
2947 uint32_t i;
2948 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2949 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302950 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002951 &mlm_set_key_req->key[i],
2952 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2953 sizeof(tSirKeys));
2954 }
2955 }
2956 }
2957 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2958 (uint32_t *) mlm_set_key_req);
2959 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002960 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002961 GET_LIM_SYSTEM_ROLE(session_entry),
2962 session_entry->limSmeState);
2963 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2964
2965 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002966 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002967 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2968 session_entry, sme_session_id,
2969 sme_transaction_id);
2970 }
2971end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302972 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002973 return;
2974}
2975
2976/**
2977 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2978 *
2979 * @mac_ctx: Pointer to Global MAC structure
2980 * @msg_buf: pointer to the SME message buffer
2981 *
2982 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2983 * from HDD or upper layer application.
2984 *
2985 * Return: None
2986 */
2987
Jeff Johnson801f1532016-10-07 07:54:50 -07002988static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2989 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002990{
2991 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2992 tpDphHashNode sta_ds = NULL;
2993 tpPESession session_entry = NULL;
2994 tSap_Event sap_event;
2995 tpWLAN_SAPEventCB sap_event_cb = NULL;
2996 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2997 uint8_t session_id = CSR_SESSION_ID_INVALID;
2998 uint8_t assoc_id = 0;
2999 uint8_t sta_cnt = 0;
3000
3001 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003002 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003003 return;
3004 }
3005
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303006 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003007 sizeof(struct sSirSmeGetAssocSTAsReq));
3008 /*
3009 * Get Associated stations from PE.
3010 * Find PE session Entry
3011 */
3012 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003013 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003014 &session_id);
3015 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003016 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003017 goto lim_assoc_sta_end;
3018 }
3019
3020 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003021 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003022 session_entry->limSmeState,
3023 GET_LIM_SYSTEM_ROLE(session_entry));
3024 goto lim_assoc_sta_end;
3025 }
3026 /* Retrieve values obtained in the request message */
3027 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3028 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3029
3030 if (NULL == assoc_sta_tmp)
3031 goto lim_assoc_sta_end;
3032 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3033 assoc_id++) {
3034 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3035 &session_entry->dph.dphHashTable);
3036 if (NULL == sta_ds)
3037 continue;
3038 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303039 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003040 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303041 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003042 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3043 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3044
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303045 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003046 (uint8_t *)&sta_ds->supportedRates,
3047 sizeof(tSirSupportedRates));
3048 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3049 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3050 assoc_sta_tmp->Support40Mhz =
3051 sta_ds->htDsssCckRate40MHzSupport;
3052
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003053 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003054 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003055 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003056 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003057 pe_debug("Association Id: %d Station Index: %d",
3058 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003059 assoc_sta_tmp++;
3060 sta_cnt++;
3061 }
3062 }
3063lim_assoc_sta_end:
3064 /*
3065 * Call hdd callback with sap event to send the list of
3066 * associated stations from PE
3067 */
3068 if (sap_event_cb != NULL) {
3069 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3070 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303071 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003072 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3073 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3074 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3075 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3076 }
3077}
3078
3079/**
3080 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3081 *
3082 * @mac_ctx: Pointer to Global MAC structure
3083 * @msg_buf: pointer to WPS PBC overlap query message
3084 *
3085 * This function parses get WPS PBC overlap information
3086 * message and call callback to pass WPS PBC overlap
3087 * information back to hdd.
3088 *
3089 * Return: None
3090 */
Jeff Johnson801f1532016-10-07 07:54:50 -07003091static void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3092 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003093{
3094 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3095 tpPESession session_entry = NULL;
3096 tSap_Event sap_event;
3097 tpWLAN_SAPEventCB sap_event_cb = NULL;
3098 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003099 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3100
3101 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003102 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003103 return;
3104 }
3105
3106 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303107 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003108
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303109 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003110 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3111 /*
3112 * Get Associated stations from PE
3113 * Find PE session Entry
3114 */
3115 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003116 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003117 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003118 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003119 goto lim_get_wpspbc_sessions_end;
3120 }
3121
3122 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003123 pe_err("Received unexpected message in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003124 GET_LIM_SYSTEM_ROLE(session_entry));
3125 goto lim_get_wpspbc_sessions_end;
3126 }
3127 /*
3128 * Call hdd callback with sap event to send the
3129 * WPS PBC overlap information
3130 */
3131 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303132 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003133
Anurag Chouhanc5548422016-02-24 18:33:27 +05303134 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003135 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003136 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003137 sap_get_wpspbc_event->UUID_E,
3138 &sap_get_wpspbc_event->wpsPBCOverlap,
3139 session_entry);
3140 } else {
3141 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003142 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003143 session_entry);
3144 /* don't have to inform the HDD/Host */
3145 return;
3146 }
3147
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003148 pe_debug("wpsPBCOverlap %d", sap_get_wpspbc_event->wpsPBCOverlap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003149 lim_print_mac_addr(mac_ctx,
Abhishek Singh4294f802017-08-10 16:37:07 +05303150 sap_get_wpspbc_event->addr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003151
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303152 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003153
3154lim_get_wpspbc_sessions_end:
3155 sap_event_cb =
3156 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3157 if (NULL != sap_event_cb)
3158 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3159}
3160
3161/**
3162 * __lim_counter_measures()
3163 *
3164 * FUNCTION:
3165 * This function is called to "implement" MIC counter measure
3166 * and is *temporary* only
3167 *
3168 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3169 * we don't do the proper STA disassoc sequence since the
3170 * BSS will be stoped anyway
3171 *
3172 ***ASSUMPTIONS:
3173 *
3174 ***NOTE:
3175 *
3176 * @param pMac Pointer to Global MAC structure
3177 * @return None
3178 */
3179
3180static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3181{
3182 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003183 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003184 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3185 mac, psessionEntry, false);
3186};
3187
Jeff Johnson801f1532016-10-07 07:54:50 -07003188static void lim_process_tkip_counter_measures(tpAniSirGlobal pMac,
3189 uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003190{
3191 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3192 tpPESession psessionEntry;
3193 uint8_t sessionId; /* PE sessionId */
3194
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303195 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003196 sizeof(struct sSirSmeTkipCntrMeasReq));
3197
3198 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003199 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003200 if (NULL == psessionEntry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003201 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003202 return;
3203 }
3204
3205 if (tkipCntrMeasReq.bEnable)
3206 __lim_counter_measures(pMac, psessionEntry);
3207
3208 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3209}
3210
3211static void
3212__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3213{
3214 tSirSmeStopBssReq stopBssReq;
3215 tSirRetStatus status;
3216 tLimSmeStates prevState;
3217 tpPESession psessionEntry;
3218 uint8_t smesessionId;
3219 uint8_t sessionId;
3220 uint16_t smetransactionId;
3221 uint8_t i = 0;
3222 tpDphHashNode pStaDs = NULL;
3223
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303224 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003225 smesessionId = stopBssReq.sessionId;
3226 smetransactionId = stopBssReq.transactionId;
3227
3228 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003229 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003230 /* Send Stop BSS response to host */
3231 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3232 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3233 smetransactionId);
3234 return;
3235 }
3236
3237 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003238 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003239 &sessionId);
3240 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003241 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003242 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3243 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3244 smetransactionId);
3245 return;
3246 }
3247#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3248 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3249 0, 0);
3250#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3251
3252 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3253 LIM_IS_STA_ROLE(psessionEntry)) {
3254 /**
3255 * Should not have received STOP_BSS_REQ in states
3256 * other than 'normal' state or on STA in Infrastructure
3257 * mode. Log error and return response to host.
3258 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003259 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003260 psessionEntry->limSmeState,
3261 GET_LIM_SYSTEM_ROLE(psessionEntry));
3262 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3263 /* / Send Stop BSS response to host */
3264 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3265 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3266 smetransactionId);
3267 return;
3268 }
3269
3270 if (LIM_IS_AP_ROLE(psessionEntry))
3271 lim_wpspbc_close(pMac, psessionEntry);
3272
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003273 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003274 stopBssReq.reasonCode);
3275
3276 prevState = psessionEntry->limSmeState;
3277
3278 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3279 MTRACE(mac_trace
3280 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3281 psessionEntry->limSmeState));
3282
3283 /* Update SME session Id and Transaction Id */
3284 psessionEntry->smeSessionId = smesessionId;
3285 psessionEntry->transactionId = smetransactionId;
3286
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003287 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3288 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3289 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003290 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3291 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3292 /* Send disassoc all stations associated thru TKIP */
3293 __lim_counter_measures(pMac, psessionEntry);
3294 else
3295 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003296 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3297 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003298 }
3299
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003300 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3301 /* Free the buffer allocated in START_BSS_REQ */
3302 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3303 psessionEntry->addIeParams.probeRespDataLen = 0;
3304 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003305
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003306 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3307 psessionEntry->addIeParams.assocRespDataLen = 0;
3308 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003309
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003310 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3311 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3312 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003313
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003314 /*
3315 * lim_del_bss is also called as part of coalescing,
3316 * when we send DEL BSS followed by Add Bss msg.
3317 */
3318 pMac->lim.gLimIbssCoalescingHappened = false;
3319 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003320 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3321 pStaDs =
3322 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3323 if (NULL == pStaDs)
3324 continue;
3325 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3326 if (eSIR_SUCCESS == status) {
3327 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3328 pStaDs->assocId, psessionEntry);
3329 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3330 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003331 pe_err("lim_del_sta failed with Status: %d", status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303332 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003333 }
3334 }
3335 /* send a delBss to HAL and wait for a response */
3336 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3337
3338 if (status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003339 pe_err("delBss failed for bss %d", psessionEntry->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003340 psessionEntry->limSmeState = prevState;
3341
3342 MTRACE(mac_trace
3343 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3344 psessionEntry->limSmeState));
3345
3346 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3347 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3348 smetransactionId);
3349 }
3350}
3351
3352/**
3353 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3354 * @pMac: Global MAC context
3355 * @pMsg: Message from SME
3356 *
3357 * Wrapper for the function __lim_handle_sme_stop_bss_request
3358 * This message will be defered until softmac come out of
3359 * scan mode. Message should be handled even if we have
3360 * detected radar in the current operating channel.
3361 *
3362 * Return: true - If we consumed the buffer
3363 * false - If have defered the message.
3364 */
3365
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003366static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3367 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003368{
3369 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3370 /**
3371 * If message defered, buffer is not consumed yet.
3372 * So return false
3373 */
3374 return false;
3375 }
3376 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3377 return true;
3378} /*** end __lim_process_sme_stop_bss_req() ***/
3379
3380void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3381 uint32_t body, tpPESession psessionEntry)
3382{
3383
3384 (void)body;
3385 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3386 lim_ibss_delete(pMac, psessionEntry);
3387 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3388 lim_delete_pre_auth_list(pMac);
3389 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3390 psessionEntry->smeSessionId,
3391 psessionEntry->transactionId);
3392 return;
3393}
3394
3395/**
3396 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3397 *
3398 * @mac_ctx: pointer to mac context
3399 * @msg_type: message type
3400 * @msg_buf: pointer to the SME message buffer
3401 *
3402 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3403 * in BTAMP AP.
3404 *
3405 * Return: None
3406 */
3407
3408void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3409 uint32_t *msg_buf)
3410{
3411 tSirSmeAssocCnf assoc_cnf;
3412 tpDphHashNode sta_ds = NULL;
3413 tpPESession session_entry = NULL;
3414 uint8_t session_id;
3415 tpSirAssocReq assoc_req;
3416
3417 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003418 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003419 goto end;
3420 }
3421
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303422 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003423 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003424 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003425 goto end;
3426 }
3427
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003428 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003429 &session_id);
3430 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003431 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003432 goto end;
3433 }
3434
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003435 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3437 (session_entry->limSmeState !=
3438 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003439 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003440 msg_type, session_entry->limSmeState,
3441 GET_LIM_SYSTEM_ROLE(session_entry));
3442 goto end;
3443 }
3444 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3445 &session_entry->dph.dphHashTable);
3446 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003447 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003448 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303449 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003450
3451 /*
3452 * send a DISASSOC_IND message to WSM to make sure
3453 * the state in WSM and LIM is the same
3454 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003455 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003456 eSIR_SME_STA_NOT_ASSOCIATED,
3457 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3458 session_entry->smeSessionId,
3459 session_entry->transactionId,
3460 session_entry);
3461 goto end;
3462 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303463 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003464 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303465 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003466 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003467 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303468 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003469 goto end;
3470 }
3471
3472 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3473 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3474 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3475 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3476 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003477 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3478 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003479 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303480 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003481 goto end;
3482 }
3483 /*
3484 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3485 * has been received
3486 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003487 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003488 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3489 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3490
3491 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3492 /*
3493 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3494 * when it had received Assoc Request frame. Now, PE just needs
3495 * to send association rsp frame to the requesting BTAMP-STA.
3496 */
3497 sta_ds->mlmStaContext.mlmState =
3498 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003499 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003500 sta_ds->assocId);
3501 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3502 sta_ds->assocId, sta_ds->staAddr,
3503 sta_ds->mlmStaContext.subType, sta_ds,
3504 session_entry);
3505 goto end;
3506 } else {
3507 /*
3508 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3509 * to be associated since the HAL sta entry is created for
3510 * denied STA we need to remove this HAL entry.
3511 * So to do that set updateContext to 1
3512 */
3513 if (!sta_ds->mlmStaContext.updateContext)
3514 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003515 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003516 assoc_cnf.statusCode, sta_ds->assocId);
3517 lim_reject_association(mac_ctx, sta_ds->staAddr,
3518 sta_ds->mlmStaContext.subType,
3519 true, sta_ds->mlmStaContext.authType,
3520 sta_ds->assocId, true,
Varun Reddy Yeturu8c68b472017-06-15 16:05:38 -07003521 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003522 session_entry);
3523 }
3524end:
3525 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3526 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3527 assoc_req = (tpSirAssocReq)
3528 session_entry->parsedAssocReq[sta_ds->assocId];
3529 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303530 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003531 assoc_req->assocReqFrame = NULL;
3532 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303533 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003534 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3535 }
3536}
3537
3538static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3539{
3540 tpDphHashNode pStaDs;
3541 tSirMacAddr peerMac;
3542 tpSirAddtsReq pSirAddts;
3543 uint32_t timeout;
3544 tpPESession psessionEntry;
3545 uint8_t sessionId; /* PE sessionId */
3546 uint8_t smesessionId;
3547 uint16_t smetransactionId;
3548
3549 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003550 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003551 return;
3552 }
3553
3554 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3555 &smetransactionId);
3556
3557 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3558
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003559 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3560 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003561 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003562 pe_err("Session Does not exist for given bssId");
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303563 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3564 NULL, pSirAddts->req.tspec,
3565 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003566 return;
3567 }
3568#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3569 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3570 0);
3571#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3572
3573 /* if sta
3574 * - verify assoc state
3575 * - send addts request to ap
3576 * - wait for addts response from ap
3577 * if ap, just ignore with error log
3578 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003579 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3580 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3581 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003582
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003583 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003584 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303585 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003587
3588 pStaDs =
3589 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3590 &psessionEntry->dph.dphHashTable);
3591
3592 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003593 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303594 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003595 }
3596
3597 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3598 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003599 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303600 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003601 }
3602
3603 pSirAddts->req.wsmTspecPresent = 0;
3604 pSirAddts->req.wmeTspecPresent = 0;
3605 pSirAddts->req.lleTspecPresent = 0;
3606
3607 if ((pStaDs->wsmEnabled) &&
3608 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3609 SIR_MAC_ACCESSPOLICY_EDCA))
3610 pSirAddts->req.wsmTspecPresent = 1;
3611 else if (pStaDs->wmeEnabled)
3612 pSirAddts->req.wmeTspecPresent = 1;
3613 else if (pStaDs->lleEnabled)
3614 pSirAddts->req.lleTspecPresent = 1;
3615 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003616 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303617 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618 }
3619
3620 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3621 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003622 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003623 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303624 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003625 }
3626
3627 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003628 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003629 pMac->lim.gLimAddtsReq.req.dialogToken,
3630 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3631 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3632 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303633 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003634 }
3635
3636 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3637
3638 /* save the addts request */
3639 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303640 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003641 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3642
3643 /* ship out the message now */
3644 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3645 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303646 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003647 /* start a timer to wait for the response */
3648 if (pSirAddts->timeout)
3649 timeout = pSirAddts->timeout;
3650 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3651 eSIR_SUCCESS) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303652 pe_debug("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003653 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303654 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003655 }
3656
3657 timeout = SYS_MS_TO_TICKS(timeout);
3658 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3659 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003660 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303661 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003662 }
3663 pMac->lim.gLimAddtsRspTimerCount++;
3664 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3665 pMac->lim.gLimAddtsRspTimerCount) !=
3666 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003667 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303668 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003669 }
3670 MTRACE(mac_trace
3671 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3672 eLIM_ADDTS_RSP_TIMER));
3673
3674 /* add the sessionId to the timer object */
3675 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3676 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3677 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003678 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303679 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003680 }
3681 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303682
3683send_failure_addts_rsp:
3684 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3685 psessionEntry, pSirAddts->req.tspec,
3686 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003687}
3688
3689static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3690{
3691 tSirMacAddr peerMacAddr;
3692 uint8_t ac;
3693 tSirMacTSInfo *pTsinfo;
3694 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3695 tpDphHashNode pStaDs = NULL;
3696 tpPESession psessionEntry;
3697 uint8_t sessionId;
3698 uint32_t status = eSIR_SUCCESS;
3699 uint8_t smesessionId;
3700 uint16_t smetransactionId;
3701
3702 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3703 &smetransactionId);
3704
3705 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003706 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003707 &sessionId);
3708 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003709 pe_err("Session Does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003710 status = eSIR_FAILURE;
3711 goto end;
3712 }
3713#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3714 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3715 0);
3716#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3717
3718 if (eSIR_SUCCESS !=
3719 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003720 pe_err("lim_validate_delts_req failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003721 status = eSIR_FAILURE;
3722 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3723 smesessionId, smetransactionId);
3724 return;
3725 }
3726
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003727 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3728 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003729 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3730
3731 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3732 pDeltsReq->req.wmeTspecPresent,
3733 &pDeltsReq->req.tsinfo,
3734 &pDeltsReq->req.tspec, psessionEntry);
3735
3736 pTsinfo =
3737 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3738 tsinfo : &pDeltsReq->req.tsinfo;
3739
3740 /* We've successfully send DELTS frame to AP. Update the
3741 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3742 * is no longer trigger enabled or delivery enabled
3743 */
3744 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3745 pTsinfo, CLEAR_UAPSD_MASK);
3746
3747 /* We're deleting the TSPEC, so this particular AC is no longer
3748 * admitted. PE needs to downgrade the EDCA
3749 * parameters(for the AC for which TS is being deleted) to the
3750 * next best AC for which ACM is not enabled, and send the
3751 * updated values to HAL.
3752 */
3753 ac = upToAc(pTsinfo->traffic.userPrio);
3754
3755 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3756 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3757 ~(1 << ac);
3758 } else if (pTsinfo->traffic.direction ==
3759 SIR_MAC_DIRECTION_DNLINK) {
3760 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3761 ~(1 << ac);
3762 } else if (pTsinfo->traffic.direction ==
3763 SIR_MAC_DIRECTION_BIDIR) {
3764 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3765 ~(1 << ac);
3766 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3767 ~(1 << ac);
3768 }
3769
3770 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3771 psessionEntry);
3772
3773 pStaDs =
3774 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3775 &psessionEntry->dph.dphHashTable);
3776 if (pStaDs != NULL) {
3777 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3778 pStaDs->bssId);
3779 status = eSIR_SUCCESS;
3780 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003781 pe_err("Self entry missing in Hash Table");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003782 status = eSIR_FAILURE;
3783 }
3784#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003785 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003786#endif
3787
3788 /* send an sme response back */
3789end:
3790 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3791 smesessionId, smetransactionId);
3792}
3793
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303794void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003795{
3796 /* fetch the sessionEntry based on the sessionId */
3797 tpPESession psessionEntry;
3798 psessionEntry = pe_find_session_by_session_id(pMac,
3799 pMac->lim.limTimers.gLimAddtsRspTimer.
3800 sessionId);
3801 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003802 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003803 return;
3804 }
3805
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003806 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003807 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003808 GET_LIM_SYSTEM_ROLE(psessionEntry));
3809 pMac->lim.gLimAddtsSent = false;
3810 return;
3811 }
3812
3813 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003814 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003815 return;
3816 }
3817
3818 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003819 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003820 pMac->lim.gLimAddtsRspTimerCount);
3821 return;
3822 }
3823 /* this a real response timeout */
3824 pMac->lim.gLimAddtsSent = false;
3825 pMac->lim.gLimAddtsRspTimerCount++;
3826
3827 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3828 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3829 psessionEntry->smeSessionId,
3830 psessionEntry->transactionId);
3831}
3832
3833/**
3834 * __lim_process_sme_get_statistics_request()
3835 *
3836 ***FUNCTION:
3837 *
3838 *
3839 ***NOTE:
3840 *
3841 * @param pMac Pointer to Global MAC structure
3842 * @param *pMsgBuf A pointer to the SME message buffer
3843 * @return None
3844 */
3845static void
3846__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3847{
3848 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003849 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003850
3851 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3852
3853 msgQ.type = WMA_GET_STATISTICS_REQ;
3854
3855 msgQ.reserved = 0;
3856 msgQ.bodyptr = pMsgBuf;
3857 msgQ.bodyval = 0;
3858 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3859
3860 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303861 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003862 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003863 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003864 return;
3865 }
3866
3867 return;
3868}
3869
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003870#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003871/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003872 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003873 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003874 * @pMac: Pointer to Global MAC structure
3875 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003876 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003877 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003878 */
3879static void
3880__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3881{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003882 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003883
3884 msgQ.type = WMA_TSM_STATS_REQ;
3885 msgQ.reserved = 0;
3886 msgQ.bodyptr = pMsgBuf;
3887 msgQ.bodyval = 0;
3888 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3889
3890 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303891 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003892 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003893 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003894 return;
3895 }
3896}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003897#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003898
3899static void
3900__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3901{
3902 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
3903 tpPESession psessionEntry;
3904 uint8_t sessionId; /* PE sessionID */
3905
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003906 pe_debug("received UPDATE_APWPSIEs_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003907
3908 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003909 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003910 return;
3911 }
3912
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303913 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003914 if (NULL == pUpdateAPWPSIEsReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003915 pe_err("call to AllocateMemory failed for pUpdateAPWPSIEsReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003916 return;
3917 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303918 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003919 sizeof(struct sSirUpdateAPWPSIEsReq));
3920
3921 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08003922 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003923 &sessionId);
3924 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003925 pe_warn("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003926 goto end;
3927 }
3928
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303929 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003930 sizeof(tSirAPWPSIEs));
3931
3932 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3933 lim_send_beacon_ind(pMac, psessionEntry);
3934
3935end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303936 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003937 return;
3938}
3939
Naveen Rawat8029a402017-06-01 10:54:19 -07003940static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3941 struct update_config *msg)
3942{
3943 tpPESession pe_session;
3944
3945 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3946 if (msg == NULL) {
3947 pe_err("Buffer is Pointing to NULL");
3948 return;
3949 }
3950
3951 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3952 msg->sme_session_id);
3953 if (pe_session == NULL) {
3954 pe_warn("Session does not exist for given BSSID");
3955 return;
3956 }
3957
3958 switch (msg->capab) {
3959 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3960 pe_session->htConfig.ht_rx_ldpc = msg->value;
3961 break;
3962 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3963 pe_session->htConfig.ht_tx_stbc = msg->value;
3964 break;
3965 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3966 pe_session->htConfig.ht_rx_stbc = msg->value;
3967 break;
3968 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3969 pe_session->htConfig.ht_sgi20 = msg->value;
3970 break;
3971 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3972 pe_session->htConfig.ht_sgi40 = msg->value;
3973 break;
3974 }
3975
3976 if (LIM_IS_AP_ROLE(pe_session)) {
3977 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3978 lim_send_beacon_ind(mac_ctx, pe_session);
3979 }
3980}
3981
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003982void
3983lim_send_vdev_restart(tpAniSirGlobal pMac,
3984 tpPESession psessionEntry, uint8_t sessionId)
3985{
3986 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003987 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003988 tSirRetStatus retCode = eSIR_SUCCESS;
3989
3990 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003991 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003992 return;
3993 }
3994
3995 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303996 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003997 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003998 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003999 return;
4000 }
4001
4002 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4003 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004004 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004005
4006 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4007 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4008 msgQ.bodyval = 0;
4009
4010 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4011 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004012 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304013 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004014 }
4015}
4016
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304017/**
4018 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
4019 * @mac_ctx: Pointer to Global MAC structure
4020 * @msg_buf: Pointer to SME message buffer
4021 *
4022 * Return: None
4023 */
4024static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
4025 uint32_t *msg_buf)
4026{
4027 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004028 struct scheduler_msg wma_msg = {0};
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304029 tSirRetStatus status;
4030 tSirRoamOffloadScanReq *req_buffer;
4031 uint16_t local_ie_len;
4032 uint8_t *local_ie_buf;
4033
4034 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
4035 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
4036 req_buffer->sessionId);
4037
4038 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
4039 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004040 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05304041 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304042 return;
4043 }
4044
4045 local_ie_len = req_buffer->assoc_ie.length;
4046 /* Update ext cap IE if present */
4047 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07004048 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
4049 local_ie_buf, &local_ie_len)) {
4050 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07004051 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
4052 req_buffer->assoc_ie.length = local_ie_len;
4053 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
4054 local_ie_buf, local_ie_len);
4055 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304056 }
4057 qdf_mem_free(local_ie_buf);
4058
4059 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
4060 wma_msg.bodyptr = req_buffer;
4061
4062 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
4063 if (eSIR_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004064 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304065 qdf_mem_free(req_buffer);
4066 }
4067}
4068
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304069/*
4070 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
4071 * @mac_ctx: Pointer to global mac context
4072 * @session: Pointer to PE session
4073 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
4074 * 1 - Disable broadcast SSID
4075 *
4076 * Return: None
4077 */
4078static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
4079 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004080{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004081 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004082 session->ssidHidden, ssid_hidden);
4083
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004084 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304085 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004086 } else {
4087 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05304088 return;
4089 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004090
4091 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304092 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004093
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004094 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304095}
4096
4097/**
4098 * __lim_process_sme_session_update - process SME session update msg
4099 *
4100 * @mac_ctx: Pointer to global mac context
4101 * @msg_buf: Pointer to the received message buffer
4102 *
4103 * Return: None
4104 */
4105static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
4106 uint32_t *msg_buf)
4107{
4108 struct sir_update_session_param *msg;
4109 tpPESession session;
4110
4111 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004112 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304113 return;
4114 }
4115
4116 msg = (struct sir_update_session_param *) msg_buf;
4117
4118 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
4119 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004120 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304121 msg->session_id);
4122 return;
4123 }
4124
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004125 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304126 msg->param_type, msg->param_val);
4127 switch (msg->param_type) {
4128 case SIR_PARAM_SSID_HIDDEN:
4129 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
4130 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05304131 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
4132 session->ignore_assoc_disallowed = msg->param_val;
4133 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304134 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004135 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304136 break;
4137 }
4138}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004139
4140static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4141{
4142 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4143 tpPESession psessionEntry;
4144 uint8_t sessionId; /* PE sessionID */
4145
4146 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004147 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004148 return;
4149 }
4150
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304151 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004152 if (NULL == pUpdateAPWPARSNIEsReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004153 pe_err("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004154 return;
4155 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304156 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004157 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4158
4159 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004160 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004161 &sessionId);
4162 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004163 pe_warn("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004164 goto end;
4165 }
4166
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304167 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004168 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4169
4170 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4171 &psessionEntry->
4172 pLimStartBssReq->rsnIE,
4173 psessionEntry);
4174
4175 psessionEntry->pLimStartBssReq->privacy = 1;
4176 psessionEntry->privacy = 1;
4177
4178 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4179 lim_send_beacon_ind(pMac, psessionEntry);
4180
4181end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304182 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004183 return;
4184} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4185
4186/*
4187 Update the beacon Interval dynamically if beaconInterval is different in MCC
4188 */
4189static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4190{
4191 tpSirChangeBIParams pChangeBIParams;
4192 tpPESession psessionEntry;
4193 uint8_t sessionId = 0;
4194 tUpdateBeaconParams beaconParams;
4195
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004196 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004197
4198 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004199 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004200 return;
4201 }
4202
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304203 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004204 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4205
4206 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004207 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004208 &sessionId);
4209 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004210 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004211 return;
4212 }
4213
4214 /*Update sessionEntry Beacon Interval */
4215 if (psessionEntry->beaconParams.beaconInterval !=
4216 pChangeBIParams->beaconInterval) {
4217 psessionEntry->beaconParams.beaconInterval =
4218 pChangeBIParams->beaconInterval;
4219 }
4220
4221 /*Update sch beaconInterval */
4222 if (pMac->sch.schObject.gSchBeaconInterval !=
4223 pChangeBIParams->beaconInterval) {
4224 pMac->sch.schObject.gSchBeaconInterval =
4225 pChangeBIParams->beaconInterval;
4226
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004227 pe_debug("LIM send update BeaconInterval Indication: %d",
4228 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004229
4230 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4231 /* Update beacon */
4232 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4233
4234 beaconParams.bssIdx = psessionEntry->bssIdx;
4235 /* Set change in beacon Interval */
4236 beaconParams.beaconInterval =
4237 pChangeBIParams->beaconInterval;
4238 beaconParams.paramChangeBitmap =
4239 PARAM_BCN_INTERVAL_CHANGED;
4240 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4241 }
4242 }
4243
4244 return;
4245} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4246
4247#ifdef QCA_HT_2040_COEX
4248static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4249 uint32_t *pMsgBuf)
4250{
4251 tpSirSetHT2040Mode pSetHT2040Mode;
4252 tpPESession psessionEntry;
4253 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004254 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004255 tUpdateVHTOpMode *pHtOpMode = NULL;
4256 uint16_t staId = 0;
4257 tpDphHashNode pStaDs = NULL;
4258
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004259 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004260 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004261 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004262 return;
4263 }
4264
4265 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4266
4267 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004268 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004269 &sessionId);
4270 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004271 pe_debug("Session does not exist for given BSSID");
4272 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004273 return;
4274 }
4275
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004276 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004277 pSetHT2040Mode->cbMode);
4278 /*Update sessionEntry HT related fields */
4279 switch (pSetHT2040Mode->cbMode) {
4280 case PHY_SINGLE_CHANNEL_CENTERED:
4281 psessionEntry->htSecondaryChannelOffset =
4282 PHY_SINGLE_CHANNEL_CENTERED;
4283 psessionEntry->htRecommendedTxWidthSet = 0;
4284 if (pSetHT2040Mode->obssEnabled)
4285 psessionEntry->htSupportedChannelWidthSet
4286 = eHT_CHANNEL_WIDTH_40MHZ;
4287 else
4288 psessionEntry->htSupportedChannelWidthSet
4289 = eHT_CHANNEL_WIDTH_20MHZ;
4290 break;
4291 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4292 psessionEntry->htSecondaryChannelOffset =
4293 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4294 psessionEntry->htRecommendedTxWidthSet = 1;
4295 break;
4296 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4297 psessionEntry->htSecondaryChannelOffset =
4298 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4299 psessionEntry->htRecommendedTxWidthSet = 1;
4300 break;
4301 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004302 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004303 return;
4304 }
4305
4306 /* Update beacon */
4307 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4308 lim_send_beacon_ind(pMac, psessionEntry);
4309
4310 /* update OP Mode for each associated peer */
4311 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4312 pStaDs = dph_get_hash_entry(pMac, staId,
4313 &psessionEntry->dph.dphHashTable);
4314 if (NULL == pStaDs)
4315 continue;
4316
4317 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304318 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004319 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004320 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004321 return;
4322 }
4323 pHtOpMode->opMode =
4324 (psessionEntry->htSecondaryChannelOffset ==
4325 PHY_SINGLE_CHANNEL_CENTERED) ?
4326 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4327 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304328 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004329 sizeof(tSirMacAddr));
4330 pHtOpMode->smesessionId = sessionId;
4331
4332 msg.type = WMA_UPDATE_OP_MODE;
4333 msg.reserved = 0;
4334 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004335 if (!QDF_IS_STATUS_SUCCESS
4336 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
4337 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304338 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004339 return;
4340 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004341 pe_debug("Notifed FW about OP mode: %d for staId=%d",
4342 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004343
4344 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004345 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004346 }
4347
4348 return;
4349}
4350#endif
4351
4352/* -------------------------------------------------------------------- */
4353/**
4354 * __lim_process_report_message
4355 *
4356 * FUNCTION: Processes the next received Radio Resource Management message
4357 *
4358 * LOGIC:
4359 *
4360 * ASSUMPTIONS:
4361 *
4362 * NOTE:
4363 *
4364 * @param None
4365 * @return None
4366 */
4367
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004368static void __lim_process_report_message(tpAniSirGlobal pMac,
4369 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004370{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004371 switch (pMsg->type) {
4372 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4373 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4374 break;
4375 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004376 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004377 break;
4378 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004379 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004380 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004381}
4382
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004383/* -------------------------------------------------------------------- */
4384/**
4385 * lim_send_set_max_tx_power_req
4386 *
4387 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4388 *
4389 * LOGIC:
4390 *
4391 * ASSUMPTIONS:
4392 *
4393 * NOTE:
4394 *
4395 * @param txPower txPower to be set.
4396 * @param pSessionEntry session entry.
4397 * @return None
4398 */
4399tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004400lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004401 tpPESession pSessionEntry)
4402{
4403 tpMaxTxPowerParams pMaxTxParams = NULL;
4404 tSirRetStatus retCode = eSIR_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004405 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004406
4407 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004408 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004409 return eSIR_FAILURE;
4410 }
4411
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304412 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004413 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004414 pe_err("Unable to allocate memory for pMaxTxParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004415 return eSIR_MEM_ALLOC_FAILED;
4416
4417 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004418 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304419 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304420 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304421 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004422 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304423 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004424
4425 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4426 msgQ.bodyptr = pMaxTxParams;
4427 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004428 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004429 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4430 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4431 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004432 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304433 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004434 }
4435 return retCode;
4436}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004437
4438/**
4439 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4440 *
4441 * @mac_ctx: Pointer to Global MAC structure
4442 * @msg_buf: pointer to the SME message buffer
4443 *
4444 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4445 * from SME. It Register this information within PE.
4446 *
4447 * Return: None
4448 */
4449static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4450 uint32_t *msg_buf)
4451{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304452 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004453 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4454 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4455 struct mgmt_frm_reg_info *next = NULL;
4456 bool match = false;
4457
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004458 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004459 sme_req->registerFrame, sme_req->frameType,
4460 sme_req->matchLen);
4461 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304462 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304463 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4464 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304465 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004466
4467 while (lim_mgmt_regn != NULL) {
4468 if (lim_mgmt_regn->frameType != sme_req->frameType)
4469 goto skip_match;
4470 if (sme_req->matchLen) {
4471 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304472 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004473 sme_req->matchData,
4474 lim_mgmt_regn->matchLen))) {
4475 /* found match! */
4476 match = true;
4477 break;
4478 }
4479 } else {
4480 /* found match! */
4481 match = true;
4482 break;
4483 }
4484skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304485 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304486 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004487 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304488 (qdf_list_node_t *)lim_mgmt_regn,
4489 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304490 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004491 lim_mgmt_regn = next;
4492 next = NULL;
4493 }
4494 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304495 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004496 if (QDF_STATUS_SUCCESS ==
4497 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004498 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004499 (qdf_list_node_t *)lim_mgmt_regn))
4500 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304501 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004502 }
4503
4504 if (sme_req->registerFrame) {
4505 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304506 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004507 sme_req->matchLen);
4508 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004509 lim_mgmt_regn->frameType = sme_req->frameType;
4510 lim_mgmt_regn->matchLen = sme_req->matchLen;
4511 lim_mgmt_regn->sessionId = sme_req->sessionId;
4512 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304513 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004514 sme_req->matchData,
4515 sme_req->matchLen);
4516 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304517 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004518 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304519 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004520 gLimMgmtFrameRegistratinQueue,
4521 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304522 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004523 &mac_ctx->lim.lim_frame_register_lock);
4524 }
4525 }
4526 return;
4527}
4528
4529static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4530{
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004531 pe_debug("Dereg msgType %d", pMac->lim.gDeferMsgTypeForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004532 pMac->lim.gDeferMsgTypeForNOA = 0;
4533 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4534 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304535 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004536 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4537 }
4538}
4539
4540/**
4541 * lim_process_regd_defd_sme_req_after_noa_start()
4542 *
4543 * mac_ctx: Pointer to Global MAC structure
4544 *
4545 * This function is called to process deferred sme req message
4546 * after noa start.
4547 *
4548 * Return: None
4549 */
4550void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4551{
4552 bool buf_consumed = true;
4553
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004554 pe_debug("Process defd sme req %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004555 mac_ctx->lim.gDeferMsgTypeForNOA);
4556
4557 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4558 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004559 pe_warn("start rcvd from FW when no sme deferred msg pending. Do nothing");
4560 pe_warn("It may happen when NOA start ind and timeout happen at the same time");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004561 return;
4562 }
4563 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4564 case eWNI_SME_SCAN_REQ:
4565 __lim_process_sme_scan_req(mac_ctx,
4566 mac_ctx->lim.gpDefdSmeMsgForNOA);
4567 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004568 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4569 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4570 mac_ctx->lim.gpDefdSmeMsgForNOA);
4571 /*
4572 * lim_process_remain_on_chnl_req doesnt want us to free
4573 * the buffer since it is freed in lim_remain_on_chn_rsp.
4574 * this change is to avoid "double free"
4575 */
4576 if (false == buf_consumed)
4577 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4578 break;
4579 case eWNI_SME_JOIN_REQ:
4580 __lim_process_sme_join_req(mac_ctx,
4581 mac_ctx->lim.gpDefdSmeMsgForNOA);
4582 break;
4583 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004584 pe_err("Unknown deferred msg type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004585 mac_ctx->lim.gDeferMsgTypeForNOA);
4586 break;
4587 }
4588 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4589}
4590
4591static void
4592__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4593{
4594 tpSirResetAPCapsChange pResetCapsChange;
4595 tpPESession psessionEntry;
4596 uint8_t sessionId = 0;
4597 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004598 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004599 return;
4600 }
4601
4602 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4603 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004604 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4605 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004606 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004607 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004608 return;
4609 }
4610
4611 psessionEntry->limSentCapsChangeNtf = false;
4612 return;
4613}
4614
4615/**
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304616 * lim_register_p2p_ack_ind_cb() - Save the p2p ack indication callback.
4617 * @mac_ctx: Mac pointer
4618 * @msg_buf: Msg pointer containing the callback
4619 *
4620 * This function is used to save the p2p ack indication callback in PE.
4621 *
4622 * Return: None
4623 */
4624static void lim_register_p2p_ack_ind_cb(tpAniSirGlobal mac_ctx,
4625 uint32_t *msg_buf)
4626{
4627 struct sir_sme_p2p_ack_ind_cb_req *sme_req =
4628 (struct sir_sme_p2p_ack_ind_cb_req *)msg_buf;
4629
4630 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004631 pe_err("msg_buf is null");
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304632 return;
4633 }
4634 if (sme_req->callback)
4635 mac_ctx->p2p_ack_ind_cb =
4636 sme_req->callback;
4637 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004638 pe_err("sme_req->callback is null");
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304639}
4640
4641/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304642 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4643 * indication callback in PE.
4644 * @mac_ptr: Mac pointer
4645 * @msg_buf: Msg pointer containing the callback
4646 *
4647 * This function is used save the Management frame
4648 * indication callback in PE.
4649 *
4650 * Return: None
4651 */
4652static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4653 uint32_t *msg_buf)
4654{
4655 struct sir_sme_mgmt_frame_cb_req *sme_req =
4656 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4657
4658 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004659 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304660 return;
4661 }
4662 if (sme_req->callback)
4663 mac_ctx->mgmt_frame_ind_cb =
4664 (sir_mgmt_frame_ind_callback)sme_req->callback;
4665 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004666 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304667}
4668
4669/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304670 *__lim_process_send_disassoc_frame: function processes disassoc frame
4671 * @mac_ctx: pointer to mac context
4672 * @msg_buf: message buffer
4673 *
4674 * function processes disassoc request received from SME
4675 *
4676 * return: none
4677 */
4678static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4679 uint32_t *msg_buf)
4680{
4681 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4682 tSirRetStatus status;
4683 tpPESession session_entry = NULL;
4684 uint8_t sme_session_id;
4685 uint16_t sme_trans_id;
4686
4687 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004688 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304689 return;
4690 }
4691
4692 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4693 &sme_trans_id);
4694
4695 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4696 &sme_send_disassoc_frame_req,
4697 (uint8_t *)msg_buf);
4698
4699 if ((eSIR_FAILURE == status) ||
4700 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4701 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004702 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304703 return;
4704 }
4705
4706 session_entry = pe_find_session_by_sme_session_id(
4707 mac_ctx, sme_session_id);
4708 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004709 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304710 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4711 return;
4712 }
4713
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004714 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 +05304715 sme_send_disassoc_frame_req.msg_type,
4716 sme_send_disassoc_frame_req.length,
4717 sme_send_disassoc_frame_req.session_id,
4718 sme_send_disassoc_frame_req.trans_id,
4719 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4720 sme_send_disassoc_frame_req.reason,
4721 sme_send_disassoc_frame_req.wait_for_ack);
4722
4723 lim_send_disassoc_mgmt_frame(mac_ctx,
4724 sme_send_disassoc_frame_req.reason,
4725 sme_send_disassoc_frame_req.peer_mac,
4726 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4727}
4728
4729/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004730 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4731 * @mac_ctx: Pointer to Global MAC structure
4732 * @pdev_id: pdev id to set the IE.
4733 * @nss: Nss values to prepare the HT IE.
4734 *
4735 * Prepares the HT IE with self capabilities for different
4736 * Nss values and sends the set HT IE req to FW.
4737 *
4738 * Return: None
4739 */
4740static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4741 uint8_t nss)
4742{
4743 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004744 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004745 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004746 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004747 tHtCaps *p_ht_cap;
4748 int i;
4749
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004750 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004751 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4752 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004753 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004754 return;
4755 }
4756 ie_params->nss = i;
4757 ie_params->pdev_id = pdev_id;
4758 ie_params->ie_type = DOT11_HT_IE;
4759 /* 2 for IE len and EID */
4760 ie_params->ie_len = 2 + sizeof(tHtCaps);
4761 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4762 if (NULL == ie_params->ie_ptr) {
4763 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004764 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004765 return;
4766 }
4767 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4768 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4769 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4770 ie_params->ie_len);
4771
4772 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004773 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4774 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004775 if (NULL == p_ie) {
4776 qdf_mem_free(ie_params->ie_ptr);
4777 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004778 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004779 return;
4780 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004781 p_ht_cap = (tHtCaps *)&p_ie[2];
4782 p_ht_cap->supportedMCSSet[1] = 0;
4783 p_ht_cap->txSTBC = 0;
4784 }
4785
4786 msg.type = WMA_SET_PDEV_IE_REQ;
4787 msg.bodyptr = ie_params;
4788 msg.bodyval = 0;
4789
4790 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4791 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004792 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004793 qdf_mem_free(ie_params->ie_ptr);
4794 qdf_mem_free(ie_params);
4795 return;
4796 }
4797 }
4798}
4799
4800/**
4801 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4802 * @mac_ctx: Pointer to Global MAC structure
4803 * @pdev_id: pdev id to set the IE.
4804 * @nss: Nss values to prepare the VHT IE.
4805 *
4806 * Prepares the VHT IE with self capabilities for different
4807 * Nss values and sends the set VHT IE req to FW.
4808 *
4809 * Return: None
4810 */
4811static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4812 uint8_t nss)
4813{
4814 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004815 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004816 tSirRetStatus rc = eSIR_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004817 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004818 tSirMacVHTCapabilityInfo *vht_cap;
4819 int i;
4820 tSirVhtMcsInfo *vht_mcs;
4821
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004822 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004823 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4824 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004825 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004826 return;
4827 }
4828 ie_params->nss = i;
4829 ie_params->pdev_id = pdev_id;
4830 ie_params->ie_type = DOT11_VHT_IE;
4831 /* 2 for IE len and EID */
4832 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4833 sizeof(tSirVhtMcsInfo);
4834 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4835 if (NULL == ie_params->ie_ptr) {
4836 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004837 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004838 return;
4839 }
4840 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4841 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4842 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4843 ie_params->ie_len);
4844
4845 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004846 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4847 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004848 if (NULL == p_ie) {
4849 qdf_mem_free(ie_params->ie_ptr);
4850 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004851 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004852 return;
4853 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004854 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4855 vht_cap->txSTBC = 0;
4856 vht_mcs =
4857 (tSirVhtMcsInfo *)&p_ie[2 +
4858 sizeof(tSirMacVHTCapabilityInfo)];
4859 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4860 vht_mcs->rxHighest =
4861 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4862 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4863 vht_mcs->txHighest =
4864 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4865 }
4866 msg.type = WMA_SET_PDEV_IE_REQ;
4867 msg.bodyptr = ie_params;
4868 msg.bodyval = 0;
4869
4870 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4871 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004872 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004873 qdf_mem_free(ie_params->ie_ptr);
4874 qdf_mem_free(ie_params);
4875 return;
4876 }
4877 }
4878}
4879
4880/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004881 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4882 * @mac_ctx: Pointer to Global MAC structure
4883 * @msg_buf: Pointer to the SME message buffer
4884 *
4885 * This function is called by limProcessMessageQueue(). This function sets the
4886 * VDEV IEs to the FW.
4887 *
4888 * Return: None
4889 */
4890static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4891 uint32_t *msg_buf)
4892{
4893 struct sir_set_vdev_ies_per_band *p_msg =
4894 (struct sir_set_vdev_ies_per_band *)msg_buf;
4895
4896 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004897 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004898 return;
4899 }
4900
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004901 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004902 p_msg->vdev_id);
4903 /* intentionally using NULL here so that self capabilty are sent */
4904 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4905 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004906 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004907}
4908
4909/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004910 * lim_process_set_pdev_IEs() - process the set pdev IE req
4911 * @mac_ctx: Pointer to Global MAC structure
4912 * @msg_buf: Pointer to the SME message buffer
4913 *
4914 * This function is called by limProcessMessageQueue(). This
4915 * function sets the PDEV IEs to the FW.
4916 *
4917 * Return: None
4918 */
4919static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4920{
4921 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4922
4923 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4924
4925 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004926 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004927 return;
4928 }
4929
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004930 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004931 ht_vht_cfg->nss);
4932 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4933
4934 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4935 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4936 ht_vht_cfg->nss);
4937}
4938
4939/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304940 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4941 *
4942 * access policy
4943 * @mac_ctx: pointer to mac context
4944 * @msg: message buffer
4945 *
4946 * function processes vendor IE and access policy from SME and updates PE
4947 *
4948 * session entry
4949 *
4950 * return: none
4951*/
4952static void lim_process_sme_update_access_policy_vendor_ie(
4953 tpAniSirGlobal mac_ctx,
4954 uint32_t *msg)
4955{
4956 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4957 struct sPESession *pe_session_entry;
4958 uint8_t num_bytes;
4959
4960 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004961 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304962 return;
4963 }
4964 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4965 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4966 update_vendor_ie->sme_session_id);
4967
4968 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004969 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304970 update_vendor_ie->sme_session_id);
4971 return;
4972 }
4973 if (pe_session_entry->access_policy_vendor_ie)
4974 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4975
4976 num_bytes = update_vendor_ie->ie[1] + 2;
4977 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4978
4979 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004980 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304981 return;
4982 }
4983 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4984 &update_vendor_ie->ie[0], num_bytes);
4985
4986 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4987}
4988
4989/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004990 * lim_process_sme_req_messages()
4991 *
4992 ***FUNCTION:
4993 * This function is called by limProcessMessageQueue(). This
4994 * function processes SME request messages from HDD or upper layer
4995 * application.
4996 *
4997 ***LOGIC:
4998 *
4999 ***ASSUMPTIONS:
5000 *
5001 ***NOTE:
5002 *
5003 * @param pMac Pointer to Global MAC structure
5004 * @param msgType Indicates the SME message type
5005 * @param *pMsgBuf A pointer to the SME message buffer
5006 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5007 * false - if pMsgBuf is not to be freed.
5008 */
5009
Rajeev Kumarfeb96382017-01-22 19:42:09 -08005010bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
5011 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005012{
5013 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
5014 uint32_t *pMsgBuf = pMsg->bodyptr;
5015 tpSirSmeScanReq pScanReq;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005016
5017 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005018 lim_msg_str(pMsg->type), pMsg->type,
5019 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5020 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005021
5022 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5023 /* If no insert NOA required then execute the code below */
5024
5025 switch (pMsg->type) {
5026 case eWNI_SME_SYS_READY_IND:
5027 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
5028 break;
5029
5030 case eWNI_SME_START_BSS_REQ:
5031 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
5032 break;
5033
5034 case eWNI_SME_SCAN_REQ:
5035 __lim_process_sme_scan_req(pMac, pMsgBuf);
5036 break;
5037
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005038 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5039 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
5040 break;
5041
5042 case eWNI_SME_UPDATE_NOA:
5043 __lim_process_sme_no_a_update(pMac, pMsgBuf);
5044 break;
5045 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5046 __lim_process_clear_dfs_channel_list(pMac, pMsg);
5047 break;
5048 case eWNI_SME_JOIN_REQ:
5049 __lim_process_sme_join_req(pMac, pMsgBuf);
5050 break;
5051
5052 case eWNI_SME_REASSOC_REQ:
5053 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
5054 break;
5055
5056 case eWNI_SME_DISASSOC_REQ:
5057 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
5058 break;
5059
5060 case eWNI_SME_DISASSOC_CNF:
5061 case eWNI_SME_DEAUTH_CNF:
5062 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
5063 break;
5064
5065 case eWNI_SME_DEAUTH_REQ:
5066 __lim_process_sme_deauth_req(pMac, pMsgBuf);
5067 break;
5068
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05305069 case eWNI_SME_SEND_DISASSOC_FRAME:
5070 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
5071 break;
5072
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005073 case eWNI_SME_SETCONTEXT_REQ:
5074 __lim_process_sme_set_context_req(pMac, pMsgBuf);
5075 break;
5076
5077 case eWNI_SME_STOP_BSS_REQ:
5078 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
5079 break;
5080
5081 case eWNI_SME_ASSOC_CNF:
5082 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005083 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005084 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5085 pMsgBuf);
5086 break;
5087
5088 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005089 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005090 __lim_process_sme_addts_req(pMac, pMsgBuf);
5091 break;
5092
5093 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005094 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005095 __lim_process_sme_delts_req(pMac, pMsgBuf);
5096 break;
5097
5098 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005099 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005100 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5101 break;
5102
5103 case eWNI_SME_GET_STATISTICS_REQ:
5104 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5105 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5106 bufConsumed = false;
5107 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005108#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005109 case eWNI_SME_GET_TSM_STATS_REQ:
5110 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5111 bufConsumed = false;
5112 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005113#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005114 case eWNI_SME_GET_ASSOC_STAS_REQ:
5115 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5116 break;
5117 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5118 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5119 break;
5120
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05305121 case eWNI_SME_SESSION_UPDATE_PARAM:
5122 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005123 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05305124 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
5125 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
5126 bufConsumed = false;
5127 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005128 case eWNI_SME_UPDATE_APWPSIE_REQ:
5129 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5130 break;
5131 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5132 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5133 break;
5134
5135 case eWNI_SME_SET_APWPARSNIEs_REQ:
5136 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5137 break;
5138
5139 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5140 /* Update the beaconInterval */
5141 __lim_process_sme_change_bi(pMac, pMsgBuf);
5142 break;
5143
5144#ifdef QCA_HT_2040_COEX
5145 case eWNI_SME_SET_HT_2040_MODE:
5146 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5147 break;
5148#endif
5149
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005150 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5151 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5152 __lim_process_report_message(pMac, pMsg);
5153 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005154
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005155 case eWNI_SME_FT_PRE_AUTH_REQ:
5156 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5157 break;
5158 case eWNI_SME_FT_UPDATE_KEY:
5159 lim_process_ft_update_key(pMac, pMsgBuf);
5160 break;
5161
5162 case eWNI_SME_FT_AGGR_QOS_REQ:
5163 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5164 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005165
5166 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5167 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5168 break;
5169#ifdef FEATURE_WLAN_TDLS
5170 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5171 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5172 break;
5173 case eWNI_SME_TDLS_ADD_STA_REQ:
5174 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5175 break;
5176 case eWNI_SME_TDLS_DEL_STA_REQ:
5177 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5178 break;
5179 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5180 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5181 break;
5182#endif
5183 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5184 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5185 break;
5186
5187 case eWNI_SME_CHANNEL_CHANGE_REQ:
5188 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5189 break;
5190
5191 case eWNI_SME_START_BEACON_REQ:
5192 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5193 break;
5194
5195 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5196 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5197 break;
5198
5199 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5200 lim_process_update_add_ies(pMac, pMsgBuf);
5201 break;
5202
5203 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5204 lim_process_modify_add_ies(pMac, pMsgBuf);
5205 break;
5206 case eWNI_SME_SET_HW_MODE_REQ:
5207 lim_process_set_hw_mode(pMac, pMsgBuf);
5208 break;
5209 case eWNI_SME_NSS_UPDATE_REQ:
5210 lim_process_nss_update_request(pMac, pMsgBuf);
5211 break;
5212 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5213 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5214 break;
5215 case eWNI_SME_SET_IE_REQ:
5216 lim_process_set_ie_req(pMac, pMsgBuf);
5217 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305218 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5219 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5220 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305221 case eWNI_SME_EXT_CHANGE_CHANNEL:
5222 lim_process_ext_change_channel(pMac, pMsgBuf);
5223 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005224 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5225 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5226 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005227 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5228 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005229 break;
5230 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5231 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5232 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07005233 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005234 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005235 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005236 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005237 break;
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305238 case eWNI_SME_REGISTER_P2P_ACK_CB:
5239 lim_register_p2p_ack_ind_cb(pMac, pMsgBuf);
5240 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305241 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5242 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5243 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07005244 case eWNI_SME_UPDATE_CONFIG:
5245 lim_process_sme_update_config(pMac,
5246 (struct update_config *)pMsgBuf);
5247 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005248 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305249 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005250 pMsg->bodyptr = NULL;
5251 break;
5252 } /* switch (msgType) */
5253
5254 return bufConsumed;
5255} /*** end lim_process_sme_req_messages() ***/
5256
5257/**
5258 * lim_process_sme_start_beacon_req()
5259 *
5260 ***FUNCTION:
5261 * This function is called by limProcessMessageQueue(). This
5262 * function processes SME request messages from HDD or upper layer
5263 * application.
5264 *
5265 ***LOGIC:
5266 *
5267 ***ASSUMPTIONS:
5268 *
5269 ***NOTE:
5270 *
5271 * @param pMac Pointer to Global MAC structure
5272 * @param msgType Indicates the SME message type
5273 * @param *pMsgBuf A pointer to the SME message buffer
5274 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5275 * false - if pMsgBuf is not to be freed.
5276 */
5277static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5278{
5279 tpSirStartBeaconIndication pBeaconStartInd;
5280 tpPESession psessionEntry;
5281 uint8_t sessionId; /* PE sessionID */
5282
5283 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005284 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005285 return;
5286 }
5287
5288 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5289 psessionEntry = pe_find_session_by_bssid(pMac,
5290 pBeaconStartInd->bssid,
5291 &sessionId);
5292 if (psessionEntry == NULL) {
5293 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005294 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005295 return;
5296 }
5297
5298 if (pBeaconStartInd->beaconStartStatus == true) {
5299 /*
5300 * Currently this Indication comes from SAP
5301 * to start Beacon Tx on a DFS channel
5302 * since beaconing has to be done on DFS
5303 * channel only after CAC WAIT is completed.
5304 * On a DFS Channel LIM does not start beacon
5305 * Tx right after the WMA_ADD_BSS_RSP.
5306 */
5307 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05305308 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005309 FL("Start Beacon with ssid %s Ch %d"),
5310 psessionEntry->ssId.ssId,
5311 psessionEntry->currentOperChannel);
5312 lim_send_beacon_ind(pMac, psessionEntry);
5313 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005314 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005315 return;
5316 }
5317}
5318
5319/**
5320 * lim_process_sme_channel_change_request() - process sme ch change req
5321 *
5322 * @mac_ctx: Pointer to Global MAC structure
5323 * @msg_buf: pointer to the SME message buffer
5324 *
5325 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5326 *
5327 * Return: None
5328 */
5329static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5330 uint32_t *msg_buf)
5331{
5332 tpSirChanChangeRequest ch_change_req;
5333 tpPESession session_entry;
5334 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005335 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005336 uint32_t val = 0;
5337
5338 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005339 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005340 return;
5341 }
5342 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5343
5344 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5345 ch_change_req->targetChannel);
5346
5347 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5348 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005349 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005350 return;
5351 }
5352
5353 session_entry = pe_find_session_by_bssid(mac_ctx,
5354 ch_change_req->bssid, &session_id);
5355 if (session_entry == NULL) {
5356 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005357 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005358 return;
5359 }
5360
5361 if (session_entry->currentOperChannel ==
5362 ch_change_req->targetChannel) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005363 pe_err("target CH is same as current CH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005364 return;
5365 }
5366
5367 if (LIM_IS_AP_ROLE(session_entry))
5368 session_entry->channelChangeReasonCode =
5369 LIM_SWITCH_CHANNEL_SAP_DFS;
5370 else
5371 session_entry->channelChangeReasonCode =
5372 LIM_SWITCH_CHANNEL_OPERATION;
5373
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005374 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005375 session_entry->currentOperChannel,
5376 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005377 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005378
5379 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005380 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005381 session_entry->ch_center_freq_seg0 =
5382 ch_change_req->center_freq_seg_0;
5383 session_entry->ch_center_freq_seg1 =
5384 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005385 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005386 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005387 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005388 session_entry->htRecommendedTxWidthSet =
5389 session_entry->htSupportedChannelWidthSet;
5390 session_entry->currentOperChannel =
5391 ch_change_req->targetChannel;
5392 session_entry->limRFBand =
5393 lim_get_rf_band(session_entry->currentOperChannel);
5394 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08005395 if (CHAN_HOP_ALL_BANDS_ENABLE ||
5396 SIR_BAND_5_GHZ == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005397 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5398 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005399 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005400 }
5401
5402 session_entry->lim11hEnable = val;
5403 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305404 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005405 &ch_change_req->operational_rateset,
5406 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305407 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005408 &ch_change_req->extended_rateset,
5409 sizeof(session_entry->extRateSet));
5410 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5411 session_entry->ch_center_freq_seg0,
5412 session_entry->ch_center_freq_seg1,
5413 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07005414 max_tx_pwr, session_entry->peSessionId,
5415 ch_change_req->cac_duration_ms,
5416 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005417}
5418
5419/******************************************************************************
5420* lim_start_bss_update_add_ie_buffer()
5421*
5422***FUNCTION:
5423* This function checks the src buffer and its length and then malloc for
5424* dst buffer update the same
5425*
5426***LOGIC:
5427*
5428***ASSUMPTIONS:
5429*
5430***NOTE:
5431*
5432* @param pMac Pointer to Global MAC structure
5433* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5434* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5435* @param *pSrcData_buff A pointer of uint8_t src buffer
5436* @param srcDataLen src buffer length
5437******************************************************************************/
5438
5439static void
5440lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5441 uint8_t **pDstData_buff,
5442 uint16_t *pDstDataLen,
5443 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5444{
5445
5446 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5447 *pDstDataLen = srcDataLen;
5448
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305449 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005450
5451 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005452 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005453 return;
5454 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305455 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005456 } else {
5457 *pDstData_buff = NULL;
5458 *pDstDataLen = 0;
5459 }
5460}
5461
5462/******************************************************************************
5463* lim_update_add_ie_buffer()
5464*
5465***FUNCTION:
5466* This function checks the src buffer and length if src buffer length more
5467* than dst buffer length then free the dst buffer and malloc for the new src
5468* length, and update the dst buffer and length. But if dst buffer is bigger
5469* than src buffer length then it just update the dst buffer and length
5470*
5471***LOGIC:
5472*
5473***ASSUMPTIONS:
5474*
5475***NOTE:
5476*
5477* @param pMac Pointer to Global MAC structure
5478* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5479* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5480* @param *pSrcData_buff A pointer of uint8_t src buffer
5481* @param srcDataLen src buffer length
5482******************************************************************************/
5483
5484static void
5485lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5486 uint8_t **pDstData_buff,
5487 uint16_t *pDstDataLen,
5488 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5489{
5490
5491 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005492 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005493 return;
5494 }
5495
5496 if (srcDataLen > *pDstDataLen) {
5497 *pDstDataLen = srcDataLen;
5498 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305499 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005500 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305501 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005502
5503 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005504 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005505 *pDstDataLen = 0;
5506 return;
5507 }
5508 }
5509
5510 /* copy the content of buffer into dst buffer
5511 */
5512 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305513 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005514
5515}
5516
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005517/**
5518 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5519 * @pMac : Pointer to Global MAC structure
5520 * @pDstData_buff : A pointer to pointer of dst buffer
5521 * @pDstDataLen : A pointer to pointer of dst buffer length
5522 * @pModifyIE : A pointer to tSirModifyIE
5523 *
5524 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5525 *
5526 * Return:
5527 * True or false depending upon whether IE is updated or not
5528 */
5529static bool
5530lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5531 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5532{
Hong Shi1553d692016-09-28 12:16:19 +08005533 int32_t oui_length;
5534 uint8_t *ibss_ie = NULL;
5535 uint8_t *vendor_ie;
5536#define MAC_VENDOR_OUI "\x00\x16\x32"
5537#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005538
5539 ibss_ie = pModifyIE->pIEBuffer;
5540 oui_length = pModifyIE->oui_length;
5541
5542 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005543 pe_err("Invalid set IBSS vendor IE command length %d",
5544 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005545 return false;
5546 }
5547
Hong Shi1553d692016-09-28 12:16:19 +08005548 /*
5549 * Why replace only beacon OUI data here:
5550 * 1. other ie (such as wpa) shall not be overwritten here.
5551 * 2. per spec, beacon oui ie might be set twice and original one
5552 * shall be updated.
5553 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005554 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005555 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5556 if (vendor_ie) {
5557 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5558 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5559 pModifyIE->ieBufferlength);
5560 } else {
5561 uint16_t new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5562 uint8_t *new_ptr = qdf_mem_malloc(new_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005563
Hong Shi1553d692016-09-28 12:16:19 +08005564 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005565 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005566 return false;
5567 }
5568 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5569 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5570 pModifyIE->ieBufferlength);
5571 qdf_mem_free(*pDstData_buff);
5572 *pDstDataLen = new_length;
5573 *pDstData_buff = new_ptr;
5574 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005575 return true;
5576}
5577
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005578/*
5579* lim_process_modify_add_ies() - process modify additional IE req.
5580*
5581* @mac_ctx: Pointer to Global MAC structure
5582* @msg_buf: pointer to the SME message buffer
5583*
5584* This function update the PE buffers for additional IEs.
5585*
5586* Return: None
5587*/
5588static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5589 uint32_t *msg_buf)
5590{
5591 tpSirModifyIEsInd modify_add_ies;
5592 tpPESession session_entry;
5593 uint8_t session_id;
5594 bool ret = false;
5595 tSirAddIeParams *add_ie_params;
5596
5597 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005598 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005599 return;
5600 }
5601
5602 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5603 /* Incoming message has smeSession, use BSSID to find PE session */
5604 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005605 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005606
5607 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005608 pe_err("Session not found for given bssid"
5609 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005610 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005611 goto end;
5612 }
5613 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5614 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5615 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005616 pe_err("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005617 modify_add_ies->modifyIE.pIEBuffer,
5618 modify_add_ies->modifyIE.ieBufferlength,
5619 modify_add_ies->modifyIE.ieID,
5620 modify_add_ies->modifyIE.ieIDLen,
5621 modify_add_ies->updateType);
5622 goto end;
5623 }
5624 add_ie_params = &session_entry->addIeParams;
5625 switch (modify_add_ies->updateType) {
5626 case eUPDATE_IE_PROBE_RESP:
5627 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005628 if (LIM_IS_IBSS_ROLE(session_entry)) {
5629 lim_update_ibss_prop_add_ies(mac_ctx,
5630 &add_ie_params->probeRespData_buff,
5631 &add_ie_params->probeRespDataLen,
5632 &modify_add_ies->modifyIE);
5633 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005634 break;
5635 case eUPDATE_IE_ASSOC_RESP:
5636 /* assoc resp IE */
5637 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305638 QDF_TRACE(QDF_MODULE_ID_PE,
5639 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005640 "assoc resp add ie not present %d"),
5641 add_ie_params->assocRespDataLen);
5642 }
5643 /* search through the buffer and modify the IE */
5644 break;
5645 case eUPDATE_IE_PROBE_BCN:
5646 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005647 if (LIM_IS_IBSS_ROLE(session_entry)) {
5648 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5649 &add_ie_params->probeRespBCNData_buff,
5650 &add_ie_params->probeRespBCNDataLen,
5651 &modify_add_ies->modifyIE);
5652 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005653 if (ret == true && modify_add_ies->modifyIE.notify) {
5654 lim_handle_param_update(mac_ctx,
5655 modify_add_ies->updateType);
5656 }
5657 break;
5658 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005659 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005660 modify_add_ies->updateType);
5661 break;
5662 }
5663end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305664 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005665 modify_add_ies->modifyIE.pIEBuffer = NULL;
5666}
5667
5668/*
5669* lim_process_update_add_ies() - process additional IE update req
5670*
5671* @mac_ctx: Pointer to Global MAC structure
5672* @msg_buf: pointer to the SME message buffer
5673*
5674* This function update the PE buffers for additional IEs.
5675*
5676* Return: None
5677*/
5678static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5679 uint32_t *msg_buf)
5680{
5681 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5682 uint8_t session_id;
5683 tpPESession session_entry;
5684 tSirAddIeParams *addn_ie;
5685 uint16_t new_length = 0;
5686 uint8_t *new_ptr = NULL;
5687 tSirUpdateIE *update_ie;
5688
5689 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005690 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005691 return;
5692 }
5693 update_ie = &update_add_ies->updateIE;
5694 /* incoming message has smeSession, use BSSID to find PE session */
5695 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005696 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005697
5698 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005699 pe_err("Session not found for given bssid"
5700 MAC_ADDRESS_STR,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005701 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005702 goto end;
5703 }
5704 addn_ie = &session_entry->addIeParams;
5705 /* if len is 0, upper layer requested freeing of buffer */
5706 if (0 == update_ie->ieBufferlength) {
5707 switch (update_add_ies->updateType) {
5708 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305709 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005710 addn_ie->probeRespData_buff = NULL;
5711 addn_ie->probeRespDataLen = 0;
5712 break;
5713 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305714 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005715 addn_ie->assocRespData_buff = NULL;
5716 addn_ie->assocRespDataLen = 0;
5717 break;
5718 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305719 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005720 addn_ie->probeRespBCNData_buff = NULL;
5721 addn_ie->probeRespBCNDataLen = 0;
5722
5723 if (update_ie->notify)
5724 lim_handle_param_update(mac_ctx,
5725 update_add_ies->updateType);
5726 break;
5727 default:
5728 break;
5729 }
5730 return;
5731 }
5732 switch (update_add_ies->updateType) {
5733 case eUPDATE_IE_PROBE_RESP:
5734 if (update_ie->append) {
5735 /*
5736 * In case of append, allocate new memory
5737 * with combined length
5738 */
5739 new_length = update_ie->ieBufferlength +
5740 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305741 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005742 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005743 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005744 goto end;
5745 }
5746 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305747 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005748 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305749 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005750 update_ie->pAdditionIEBuffer,
5751 update_ie->ieBufferlength);
5752 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305753 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005754 /* adjust length accordingly */
5755 addn_ie->probeRespDataLen = new_length;
5756 /* save refernece of local buffer in PE session */
5757 addn_ie->probeRespData_buff = new_ptr;
5758 goto end;
5759 }
5760 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5761 &addn_ie->probeRespDataLen,
5762 update_ie->pAdditionIEBuffer,
5763 update_ie->ieBufferlength);
5764 break;
5765 case eUPDATE_IE_ASSOC_RESP:
5766 /* assoc resp IE */
5767 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5768 &addn_ie->assocRespDataLen,
5769 update_ie->pAdditionIEBuffer,
5770 update_ie->ieBufferlength);
5771 break;
5772 case eUPDATE_IE_PROBE_BCN:
5773 /* probe resp Bcn IE */
5774 lim_update_add_ie_buffer(mac_ctx,
5775 &addn_ie->probeRespBCNData_buff,
5776 &addn_ie->probeRespBCNDataLen,
5777 update_ie->pAdditionIEBuffer,
5778 update_ie->ieBufferlength);
5779 if (update_ie->notify)
5780 lim_handle_param_update(mac_ctx,
5781 update_add_ies->updateType);
5782 break;
5783 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005784 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005785 break;
5786 }
5787end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305788 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005789 update_ie->pAdditionIEBuffer = NULL;
5790}
5791
5792/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305793 * send_extended_chan_switch_action_frame()- function to send ECSA
5794 * action frame for each sta connected to SAP/GO and AP in case of
5795 * STA .
5796 * @mac_ctx: pointer to global mac structure
5797 * @new_channel: new channel to switch to.
5798 * @ch_bandwidth: BW of channel to calculate op_class
5799 * @session_entry: pe session
5800 *
5801 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5802 *
5803 * Return: void
5804 */
5805
5806static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5807 uint16_t new_channel, uint8_t ch_bandwidth,
5808 tpPESession session_entry)
5809{
5810 uint16_t op_class;
5811 uint8_t switch_mode = 0, i;
5812 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005813 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305814
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005815 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305816 mac_ctx->scan.countryCodeCurrent,
5817 new_channel,
5818 ch_bandwidth);
5819
5820 if (LIM_IS_AP_ROLE(session_entry) &&
5821 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005822 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305823
gaoleze2920bd2017-03-21 17:38:42 +08005824 switch_count = session_entry->gLimChannelSwitch.switchCount;
5825
Abhishek Singh518323d2015-10-19 17:42:01 +05305826 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005827 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305828 psta =
5829 session_entry->dph.dphHashTable.pDphNodeArray + i;
5830 if (psta && psta->added)
5831 lim_send_extended_chan_switch_action_frame(
5832 mac_ctx,
5833 psta->staAddr,
5834 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005835 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305836 }
5837 } else if (LIM_IS_STA_ROLE(session_entry)) {
5838 lim_send_extended_chan_switch_action_frame(mac_ctx,
5839 session_entry->bssId,
5840 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005841 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305842 }
5843
5844}
5845
5846/**
gaolez76d2a162017-03-21 19:23:58 +08005847 * lim_send_chan_switch_action_frame()- Send an action frame
5848 * containing CSA IE or ECSA IE depending on the connected
5849 * sta capability.
5850 *
5851 * @mac_ctx: pointer to global mac structure
5852 * @new_channel: new channel to switch to.
5853 * @ch_bandwidth: BW of channel to calculate op_class
5854 * @session_entry: pe session
5855 *
5856 * Return: void
5857 */
5858static
5859void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5860 uint16_t new_channel,
5861 uint8_t ch_bandwidth,
5862 tpPESession session_entry)
5863{
5864 uint16_t op_class;
5865 uint8_t switch_mode = 0, i;
5866 uint8_t switch_count;
5867 tpDphHashNode psta;
5868 tpDphHashNode dph_node_array_ptr;
5869
5870 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5871
5872 op_class = wlan_reg_dmn_get_opclass_from_channel(
5873 mac_ctx->scan.countryCodeCurrent,
5874 new_channel, ch_bandwidth);
5875
5876 if (LIM_IS_AP_ROLE(session_entry) &&
5877 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5878 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5879
5880 switch_count = session_entry->gLimChannelSwitch.switchCount;
5881
5882 if (LIM_IS_AP_ROLE(session_entry)) {
5883 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5884 psta = dph_node_array_ptr + i;
5885 if (!(psta && psta->added))
5886 continue;
5887 if (session_entry->lim_non_ecsa_cap_num == 0)
5888 lim_send_extended_chan_switch_action_frame
5889 (mac_ctx, psta->staAddr, switch_mode,
5890 op_class, new_channel, switch_count,
5891 session_entry);
5892 else
5893 lim_send_channel_switch_mgmt_frame
5894 (mac_ctx, psta->staAddr, switch_mode,
5895 new_channel, switch_count,
5896 session_entry);
5897 }
5898 } else if (LIM_IS_STA_ROLE(session_entry)) {
5899 lim_send_extended_chan_switch_action_frame
5900 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5901 new_channel, switch_count, session_entry);
5902 }
5903}
5904
5905/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005906 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5907 *
5908 * @mac_ctx: Pointer to Global MAC structure
5909 * @msg_buf: pointer to the SME message buffer
5910 *
5911 * This function processes SME request messages from HDD or upper layer
5912 * application.
5913 *
5914 * Return: None
5915 */
5916static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5917 uint32_t *msg_buf)
5918{
5919 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5920 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005921 uint8_t session_id;
5922 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005923 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005924
5925 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005926 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005927 return;
5928 }
5929
5930 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5931 session_entry = pe_find_session_by_bssid(mac_ctx,
5932 dfs_csa_ie_req->bssid, &session_id);
5933 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005934 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005935 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5936 return;
5937 }
5938
5939 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005940 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005941 GET_LIM_SYSTEM_ROLE(session_entry));
5942 return;
5943 }
5944
5945 /* target channel */
5946 session_entry->gLimChannelSwitch.primaryChannel =
5947 dfs_csa_ie_req->targetChannel;
5948
5949 /* Channel switch announcement needs to be included in beacon */
5950 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005951 session_entry->gLimChannelSwitch.switchCount =
5952 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005953 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005954 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305955 session_entry->gLimChannelSwitch.sec_ch_offset =
5956 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005957 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005958 session_entry->gLimChannelSwitch.switchMode =
5959 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005960
5961 /*
5962 * Validate if SAP is operating HT or VHT mode and set the Channel
5963 * Switch Wrapper element with the Wide Band Switch subelement.
5964 */
5965 if (true != session_entry->vhtCapability)
5966 goto skip_vht;
5967
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005968 /* Now encode the Wider Ch BW element depending on the ch width */
5969 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005970 switch (dfs_csa_ie_req->ch_params.ch_width) {
5971 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005972 /*
5973 * Wide channel BW sublement in channel wrapper element is not
5974 * required in case of 20 Mhz operation. Currently It is set
5975 * only set in case of 40/80 Mhz Operation.
5976 */
5977 session_entry->dfsIncludeChanWrapperIe = false;
5978 wider_bw_ch_switch->newChanWidth =
5979 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5980 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005981 case CH_WIDTH_40MHZ:
5982 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005983 wider_bw_ch_switch->newChanWidth =
5984 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5985 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005986 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005987 session_entry->dfsIncludeChanWrapperIe = true;
5988 wider_bw_ch_switch->newChanWidth =
5989 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5990 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005991 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005992 session_entry->dfsIncludeChanWrapperIe = true;
5993 wider_bw_ch_switch->newChanWidth =
5994 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5995 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005996 case CH_WIDTH_80P80MHZ:
5997 session_entry->dfsIncludeChanWrapperIe = true;
5998 wider_bw_ch_switch->newChanWidth =
5999 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08006000 /*
6001 * This is not applicable for 20/40/80 Mhz.
6002 * Only used when we support 80+80 Mhz operation.
6003 * In case of 80+80 Mhz, this parameter indicates
6004 * center channel frequency index of 80 Mhz channel of
6005 * frequency segment 1.
6006 */
6007 wider_bw_ch_switch->newCenterChanFreq1 =
6008 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006009 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006010 default:
6011 session_entry->dfsIncludeChanWrapperIe = false;
6012 /*
6013 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
6014 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
6015 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006016 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006017 break;
6018 }
6019 /* Fetch the center channel based on the channel width */
6020 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006021 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006022skip_vht:
6023 /* Send CSA IE request from here */
6024 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6025 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006026 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006027 return;
6028 }
6029
6030 /*
6031 * First beacon update request is sent here, the remaining updates are
6032 * done when the FW responds back after sending the first beacon after
6033 * the template update
6034 */
6035 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306036
6037 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
6038 ch_offset = BW80;
6039 else
6040 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
6041
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006042 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306043 session_entry->gLimChannelSwitch.switchCount,
6044 session_entry->gLimChannelSwitch.primaryChannel,
6045 session_entry->gLimChannelSwitch.ch_width,
6046 session_entry->dfsIncludeChanWrapperIe,
6047 ch_offset);
6048
gaolez76d2a162017-03-21 19:23:58 +08006049 /* Send ECSA/CSA Action frame after updating the beacon */
6050 if (CHAN_HOP_ALL_BANDS_ENABLE)
6051 lim_send_chan_switch_action_frame(mac_ctx,
6052 session_entry->gLimChannelSwitch.primaryChannel,
6053 ch_offset, session_entry);
6054 else
6055 send_extended_chan_switch_action_frame(mac_ctx,
6056 session_entry->gLimChannelSwitch.primaryChannel,
6057 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006058 session_entry->gLimChannelSwitch.switchCount--;
6059}
6060
6061/**
Abhishek Singh518323d2015-10-19 17:42:01 +05306062 * lim_process_ext_change_channel()- function to send ECSA
6063 * action frame for STA/CLI .
6064 * @mac_ctx: pointer to global mac structure
6065 * @msg: params from sme for new channel.
6066 *
6067 * This function is called to send ECSA frame for STA/CLI.
6068 *
6069 * Return: void
6070 */
6071
6072static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
6073 uint32_t *msg)
6074{
6075 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
6076 (struct sir_sme_ext_cng_chan_req *) msg;
6077 tpPESession session_entry = NULL;
6078
6079 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006080 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05306081 return;
6082 }
6083 session_entry =
6084 pe_find_session_by_sme_session_id(mac_ctx,
6085 ext_chng_channel->session_id);
6086 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006087 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05306088 ext_chng_channel->session_id);
6089 return;
6090 }
6091 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006092 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05306093 return;
6094 }
6095 send_extended_chan_switch_action_frame(mac_ctx,
6096 ext_chng_channel->new_channel,
6097 0, session_entry);
6098}
6099
6100/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006101 * lim_process_nss_update_request() - process sme nss update req
6102 *
6103 * @mac_ctx: Pointer to Global MAC structure
6104 * @msg_buf: pointer to the SME message buffer
6105 *
6106 * This function processes SME request messages from HDD or upper layer
6107 * application.
6108 *
6109 * Return: None
6110 */
6111static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
6112 uint32_t *msg_buf)
6113{
6114 struct sir_nss_update_request *nss_update_req_ptr;
6115 tpPESession session_entry = NULL;
6116
6117 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006118 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006119 return;
6120 }
6121
6122 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05306123 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006124 nss_update_req_ptr->vdev_id);
6125 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006126 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006127 nss_update_req_ptr->vdev_id);
6128 return;
6129 }
6130
6131 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006132 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006133 GET_LIM_SYSTEM_ROLE(session_entry));
6134 return;
6135 }
6136
6137 /* populate nss field in the beacon */
6138 session_entry->gLimOperatingMode.present = 1;
6139 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05306140 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
6141
6142 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
6143 (session_entry->ch_width > CH_WIDTH_80MHZ))
6144 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
6145
6146 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
6147
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006148 /* Send nss update request from here */
6149 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6150 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006151 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006152 return;
6153 }
6154
6155 lim_send_beacon_ind(mac_ctx, session_entry);
6156}
6157
6158/**
6159 * lim_process_set_ie_req() - process sme set IE request
6160 *
6161 * @mac_ctx: Pointer to Global MAC structure
6162 * @msg_buf: pointer to the SME message buffer
6163 *
6164 * This function processes SME request messages from HDD or upper layer
6165 * application.
6166 *
6167 * Return: None
6168 */
6169static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6170{
6171 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306172 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006173
6174 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006175 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006176 return;
6177 }
6178
6179 msg = (struct send_extcap_ie *)msg_buf;
6180 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306181 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006182 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006183
6184}